use of com.yahoo.elide.datastores.aggregation.metadata.MetaDataStore in project elide by yahoo.
the class DefaultQueryPlanMergerTest method testSimpleMerge.
@Test
public void testSimpleMerge() {
Queryable source = mock(Queryable.class);
// A root source.
when(source.getSource()).thenReturn(source);
MetricProjection m1 = mock(MetricProjection.class);
MetricProjection m2 = mock(MetricProjection.class);
when(m1.getName()).thenReturn("m1");
when(m2.getName()).thenReturn("m2");
DimensionProjection d1 = mock(DimensionProjection.class);
DimensionProjection d2 = mock(DimensionProjection.class);
when(d1.getName()).thenReturn("d1");
when(d2.getName()).thenReturn("d2");
TimeDimensionProjection t1 = mock(TimeDimensionProjection.class);
TimeDimensionProjection t2 = mock(TimeDimensionProjection.class);
when(t1.getName()).thenReturn("t1");
when(t2.getName()).thenReturn("t2");
QueryPlan a = QueryPlan.builder().source(source).metricProjection(m1).dimensionProjection(d1).timeDimensionProjection(t1).build();
QueryPlan b = QueryPlan.builder().source(source).metricProjection(m2).dimensionProjection(d2).timeDimensionProjection(t2).build();
MetaDataStore metaDataStore = mock(MetaDataStore.class);
DefaultQueryPlanMerger merger = new DefaultQueryPlanMerger(metaDataStore);
QueryPlan c = merger.merge(a, b);
assertEquals(List.of(m2, m1), c.getMetricProjections());
assertEquals(List.of(d2, d1), c.getDimensionProjections());
assertEquals(List.of(t2, t1), c.getTimeDimensionProjections());
}
use of com.yahoo.elide.datastores.aggregation.metadata.MetaDataStore in project elide by yahoo.
the class DefaultQueryPlanMergerTest method testCannotMergeMismatchedUnnestedWhere.
@Test
public void testCannotMergeMismatchedUnnestedWhere() {
MetaDataStore metaDataStore = mock(MetaDataStore.class);
DefaultQueryPlanMerger merger = new DefaultQueryPlanMerger(metaDataStore);
QueryPlan a = mock(QueryPlan.class);
QueryPlan b = mock(QueryPlan.class);
when(a.canNest(any())).thenReturn(false);
when(b.canNest(any())).thenReturn(false);
when(a.nestDepth()).thenReturn(1);
when(b.nestDepth()).thenReturn(1);
FilterExpression expression = mock(FilterExpression.class);
when(a.getWhereFilter()).thenReturn(expression);
when(b.getWhereFilter()).thenReturn(null);
assertFalse(merger.canMerge(a, b));
assertFalse(merger.canMerge(b, a));
}
use of com.yahoo.elide.datastores.aggregation.metadata.MetaDataStore in project elide by yahoo.
the class DefaultQueryPlanMergerTest method testCanMerge.
@Test
public void testCanMerge() {
MetaDataStore metaDataStore = mock(MetaDataStore.class);
DefaultQueryPlanMerger merger = new DefaultQueryPlanMerger(metaDataStore);
QueryPlan a = mock(QueryPlan.class);
QueryPlan b = mock(QueryPlan.class);
when(a.canNest(any())).thenReturn(false);
when(b.canNest(any())).thenReturn(false);
when(a.nestDepth()).thenReturn(1);
when(b.nestDepth()).thenReturn(1);
FilterExpression expression = mock(FilterExpression.class);
when(a.getWhereFilter()).thenReturn(expression);
when(b.getWhereFilter()).thenReturn(expression);
TimeDimensionProjection p1 = mock(TimeDimensionProjection.class);
Map<String, Argument> args1 = new HashMap<>();
args1.put("foo", Argument.builder().name("a").value(100).build());
when(p1.getName()).thenReturn("name");
when(p1.getArguments()).thenReturn(args1);
TimeDimensionProjection p2 = mock(TimeDimensionProjection.class);
Map<String, Argument> args2 = new HashMap<>();
args2.put("foo", Argument.builder().name("a").value(100).build());
when(p2.getName()).thenReturn("name");
when(p2.getArguments()).thenReturn(args2);
when(a.getTimeDimensionProjections()).thenReturn(List.of(p1));
when(b.getTimeDimensionProjections()).thenReturn(List.of(p2));
when(b.getTimeDimensionProjection(eq("name"))).thenReturn(p2);
when(a.getTimeDimensionProjection(eq("name"))).thenReturn(p1);
assertTrue(merger.canMerge(a, b));
assertTrue(merger.canMerge(b, a));
}
use of com.yahoo.elide.datastores.aggregation.metadata.MetaDataStore in project elide by yahoo.
the class DefaultQueryPlanMergerTest method testCannotMergeMismatchedTimeDimension.
@Test
public void testCannotMergeMismatchedTimeDimension() {
MetaDataStore metaDataStore = mock(MetaDataStore.class);
DefaultQueryPlanMerger merger = new DefaultQueryPlanMerger(metaDataStore);
QueryPlan a = mock(QueryPlan.class);
QueryPlan b = mock(QueryPlan.class);
when(a.canNest(any())).thenReturn(false);
when(b.canNest(any())).thenReturn(false);
when(a.nestDepth()).thenReturn(1);
when(b.nestDepth()).thenReturn(1);
TimeDimensionProjection p1 = mock(TimeDimensionProjection.class);
Map<String, Argument> args1 = new HashMap<>();
when(p1.getName()).thenReturn("name");
when(p1.getArguments()).thenReturn(args1);
TimeDimensionProjection p2 = mock(TimeDimensionProjection.class);
Map<String, Argument> args2 = new HashMap<>();
args2.put("foo", Argument.builder().name("a").value(100).build());
when(p2.getName()).thenReturn("name");
when(p2.getArguments()).thenReturn(args2);
when(a.getTimeDimensionProjections()).thenReturn(List.of(p1));
when(b.getTimeDimensionProjections()).thenReturn(List.of(p2));
when(b.getTimeDimensionProjection(eq("name"))).thenReturn(p2);
when(a.getTimeDimensionProjection(eq("name"))).thenReturn(p1);
assertFalse(merger.canMerge(a, b));
assertFalse(merger.canMerge(b, a));
}
use of com.yahoo.elide.datastores.aggregation.metadata.MetaDataStore in project elide by yahoo.
the class DefaultQueryPlanMergerTest method testCannotMergeNoNesting.
@Test
public void testCannotMergeNoNesting() {
MetaDataStore metaDataStore = mock(MetaDataStore.class);
DefaultQueryPlanMerger merger = new DefaultQueryPlanMerger(metaDataStore);
QueryPlan a = mock(QueryPlan.class);
QueryPlan b = mock(QueryPlan.class);
when(a.canNest(any())).thenReturn(false);
when(b.canNest(any())).thenReturn(true);
when(a.nestDepth()).thenReturn(1);
when(b.nestDepth()).thenReturn(2);
assertFalse(merger.canMerge(a, b));
assertFalse(merger.canMerge(b, a));
}
Aggregations