use of com.yahoo.elide.datastores.aggregation.query.Query in project elide by yahoo.
the class EntityProjectionTranslatorTest method testBasicTranslation.
@Test
public void testBasicTranslation() {
EntityProjectionTranslator translator = new EntityProjectionTranslator(engine, playerStatsTable, basicProjection, scope, true);
Query query = translator.getQuery();
assertEquals(playerStatsTable, query.getSource());
assertEquals(1, query.getMetricProjections().size());
String actual = query.getMetricProjections().stream().map(MetricProjection::getAlias).findFirst().orElse(null);
assertEquals("lowScore", actual);
assertEquals(1, query.getAllDimensionProjections().size());
List<ColumnProjection> dimensions = new ArrayList<>(query.getAllDimensionProjections());
assertEquals("overallRating", dimensions.get(0).getName());
}
use of com.yahoo.elide.datastores.aggregation.query.Query in project elide by yahoo.
the class EntityProjectionTranslatorTest method testQueryArguments.
@Test
public void testQueryArguments() {
EntityProjectionTranslator translator = new EntityProjectionTranslator(engine, playerStatsTable, basicProjection, scope, true);
Query query = translator.getQuery();
Argument queryArg = query.getArguments().get("foo");
assertEquals("bar", queryArg.getValue());
Argument lowScoreArg = query.getColumnProjection("lowScore").getArguments().get("foo");
assertEquals("bar", lowScoreArg.getValue());
}
use of com.yahoo.elide.datastores.aggregation.query.Query in project elide by yahoo.
the class EntityProjectionTranslatorTest method testHavingClauseMetricsMissingFromProjection.
@Test
public void testHavingClauseMetricsMissingFromProjection() throws ParseException {
FilterExpression filter = filterParser.parseFilterExpression("lowScore>45", playerStatsType, false);
EntityProjection projection = EntityProjection.builder().type(PlayerStats.class).filterExpression(filter).attribute(Attribute.builder().type(long.class).name("highScore").build()).attribute(Attribute.builder().type(String.class).name("overallRating").build()).build();
EntityProjectionTranslator translator = new EntityProjectionTranslator(engine, playerStatsTable, projection, scope, true);
Query query = translator.getQuery();
List<String> metricNames = query.getMetricProjections().stream().map(MetricProjection::getName).collect(Collectors.toList());
assertEquals(metricNames, Arrays.asList("highScore", "lowScore"));
}
use of com.yahoo.elide.datastores.aggregation.query.Query in project elide by yahoo.
the class EntityProjectionTranslatorTest method testTimeDimension.
@Test
public void testTimeDimension() {
EntityProjection projection = basicProjection.copyOf().attribute(Attribute.builder().type(Date.class).name("recordedDate").build()).build();
EntityProjectionTranslator translator = new EntityProjectionTranslator(engine, playerStatsTable, projection, scope, true);
Query query = translator.getQuery();
List<TimeDimensionProjection> timeDimensions = new ArrayList<>(query.getTimeDimensionProjections());
assertEquals(1, timeDimensions.size());
assertEquals("recordedDate", timeDimensions.get(0).getAlias());
assertEquals(TimeGrain.DAY, timeDimensions.get(0).getGrain());
}
use of com.yahoo.elide.datastores.aggregation.query.Query in project elide by yahoo.
the class QueryKeyExtractorTest method testMinimalQuery.
@Test
public void testMinimalQuery() {
// check for proper handling of unset Query fields
Query query = Query.builder().source(playerStatsTable).metricProjection(playerStatsTable.getMetricProjection("highScore")).build();
assertEquals("example_PlayerStats;{highScore;{}}{}{};;;;", QueryKeyExtractor.extractKey(query));
}
Aggregations