use of com.yahoo.elide.datastores.aggregation.query.Query in project elide by yahoo.
the class DruidExplainQueryTest method testExplainHavingMetricsOrDims.
@Test
public void testExplainHavingMetricsOrDims() throws Exception {
Query query = TestQuery.HAVING_METRICS_OR_DIMS.getQuery();
String expectedQueryStr = "SELECT MAX(\"example_PlayerStats\".\"highScore\") AS \"highScore\"," + "\"example_PlayerStats\".\"overallRating\" AS \"overallRating\" " + "FROM \"playerStats\" AS \"example_PlayerStats\" " + "GROUP BY \"example_PlayerStats\".\"overallRating\" " + "HAVING (\"example_PlayerStats\".\"overallRating\" IS NOT NULL " + "OR MAX(\"example_PlayerStats\".\"highScore\") > :XXX)";
compareQueryLists(expectedQueryStr, engine.explain(query));
testQueryExecution(TestQuery.HAVING_METRICS_OR_DIMS.getQuery());
}
use of com.yahoo.elide.datastores.aggregation.query.Query in project elide by yahoo.
the class DruidExplainQueryTest method testInnerJoin.
@Test
public void testInnerJoin() throws Exception {
Query query = TestQuery.INNER_JOIN.getQuery();
String expectedQueryStr = "SELECT DISTINCT \"example_VideoGame_playerInnerJoin_XXX\".\"name\" AS \"playerNameInnerJoin\" FROM \"videoGames\" AS \"example_VideoGame\"" + " INNER JOIN \"players\" AS \"example_VideoGame_playerInnerJoin_XXX\" ON \"example_VideoGame\".\"player_id\"" + " = \"example_VideoGame_playerInnerJoin_XXX\".\"id\"";
compareQueryLists(expectedQueryStr, engine.explain(query));
testQueryExecution(query);
}
use of com.yahoo.elide.datastores.aggregation.query.Query in project elide by yahoo.
the class DruidExplainQueryTest method testExplainHavingMetricsOnly.
@Test
public void testExplainHavingMetricsOnly() throws Exception {
Query query = TestQuery.HAVING_METRICS_ONLY.getQuery();
String expectedQueryStr = "SELECT MIN(\"example_PlayerStats\".\"lowScore\") AS \"lowScore\" " + "FROM \"playerStats\" AS \"example_PlayerStats\" " + "HAVING MIN(\"example_PlayerStats\".\"lowScore\") > :XXX";
compareQueryLists(expectedQueryStr, engine.explain(query));
testQueryExecution(TestQuery.HAVING_METRICS_ONLY.getQuery());
}
use of com.yahoo.elide.datastores.aggregation.query.Query in project elide by yahoo.
the class DruidExplainQueryTest method testWhereWithArguments.
@Test
public void testWhereWithArguments() {
Query query = TestQuery.WHERE_WITH_ARGUMENTS.getQuery();
String queryStr = engine.explain(query).get(0);
queryStr = repeatedWhitespacePattern.matcher(queryStr).replaceAll(" ");
String expectedStr = getExpectedWhereWithArgumentsSQL().replace(BACKTICK, DOUBLE_QUOTE);
assertEquals(expectedStr, queryStr);
testQueryExecution(query);
}
use of com.yahoo.elide.datastores.aggregation.query.Query in project elide by yahoo.
the class EntityHydratorTest method testNullEnumHydration.
@Test
void testNullEnumHydration() throws Exception {
ResultSet resultSet = mock(ResultSet.class);
ResultSetMetaData resultSetMetaData = mock(ResultSetMetaData.class);
when(resultSet.next()).thenReturn(true, false);
when(resultSet.getObject("overallRating")).thenReturn(null);
when(resultSetMetaData.getColumnCount()).thenReturn(1);
Query query = Query.builder().source(playerStatsTable).dimensionProjection(playerStatsTable.getDimensionProjection("overallRating")).build();
EntityHydrator hydrator = new EntityHydrator(resultSet, query, dictionary);
Iterator<Object> iterator = hydrator.iterator();
assertTrue(iterator.hasNext());
PlayerStats stats = (PlayerStats) iterator.next();
assertNull(stats.getOverallRating());
assertFalse(iterator.hasNext());
assertThrows(NoSuchElementException.class, () -> hydrator.iterator().next());
}
Aggregations