use of com.yahoo.elide.datastores.aggregation.query.Query in project elide by yahoo.
the class H2ExplainQueryTest method testCrossJoin.
@Test
public void testCrossJoin() throws Exception {
Query query = TestQuery.CROSS_JOIN.getQuery();
String expectedQueryStr = "SELECT DISTINCT `example_VideoGame_playerCrossJoin_XXX`.`name` AS `playerNameCrossJoin` FROM `videoGames` AS `example_VideoGame`" + " CROSS JOIN `players` AS `example_VideoGame_playerCrossJoin_XXX`";
compareQueryLists(expectedQueryStr, engine.explain(query));
testQueryExecution(query);
}
use of com.yahoo.elide.datastores.aggregation.query.Query in project elide by yahoo.
the class H2ExplainQueryTest 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 H2ExplainQueryTest method testNestedMetricWithPaginationQuery.
@Test
public void testNestedMetricWithPaginationQuery() {
Query query = TestQuery.NESTED_METRIC_WITH_PAGINATION_QUERY.getQuery();
String exptectedQueryStr1 = "SELECT COUNT(*) FROM " + "(SELECT `example_PlayerStats_XXX`.`overallRating`, " + "`example_PlayerStats_XXX`.`recordedDate` " + "FROM (SELECT MAX(`example_PlayerStats`.`highScore`) AS `highScore`," + "`example_PlayerStats`.`overallRating` AS `overallRating`," + "PARSEDATETIME(FORMATDATETIME(`example_PlayerStats`.`recordedDate`, 'yyyy-MM-dd'), 'yyyy-MM-dd') AS `recordedDate_XXX`," + "PARSEDATETIME(FORMATDATETIME(`example_PlayerStats`.`recordedDate`, 'yyyy-MM-01'), 'yyyy-MM-dd') AS `recordedDate` " + "FROM `playerStats` AS `example_PlayerStats` " + "GROUP BY `example_PlayerStats`.`overallRating`, " + "PARSEDATETIME(FORMATDATETIME(`example_PlayerStats`.`recordedDate`, 'yyyy-MM-dd'), 'yyyy-MM-dd'), " + "PARSEDATETIME(FORMATDATETIME(`example_PlayerStats`.`recordedDate`, 'yyyy-MM-01'), 'yyyy-MM-dd') ) " + "AS `example_PlayerStats_XXX` " + "GROUP BY `example_PlayerStats_XXX`.`overallRating`, " + "`example_PlayerStats_XXX`.`recordedDate` ) AS `pagination_subquery`\n";
String exptectedQueryStr2 = "SELECT AVG(`example_PlayerStats_XXX`.`highScore`) " + "AS `dailyAverageScorePerPeriod`,`example_PlayerStats_XXX`.`overallRating` AS `overallRating`," + "`example_PlayerStats_XXX`.`recordedDate` AS `recordedDate` " + "FROM (SELECT MAX(`example_PlayerStats`.`highScore`) AS `highScore`," + "`example_PlayerStats`.`overallRating` AS `overallRating`," + "PARSEDATETIME(FORMATDATETIME(`example_PlayerStats`.`recordedDate`, 'yyyy-MM-dd'), 'yyyy-MM-dd') AS `recordedDate_XXX`," + "PARSEDATETIME(FORMATDATETIME(`example_PlayerStats`.`recordedDate`, 'yyyy-MM-01'), 'yyyy-MM-dd') AS `recordedDate` " + "FROM `playerStats` AS `example_PlayerStats` GROUP BY " + "`example_PlayerStats`.`overallRating`, " + "PARSEDATETIME(FORMATDATETIME(`example_PlayerStats`.`recordedDate`, 'yyyy-MM-dd'), 'yyyy-MM-dd'), " + "PARSEDATETIME(FORMATDATETIME(`example_PlayerStats`.`recordedDate`, 'yyyy-MM-01'), 'yyyy-MM-dd') ) " + "AS `example_PlayerStats_XXX` GROUP BY " + "`example_PlayerStats_XXX`.`overallRating`, " + "`example_PlayerStats_XXX`.`recordedDate` " + "LIMIT 1 OFFSET 0\n";
List<String> expectedQueryList = new ArrayList<>();
expectedQueryList.add(exptectedQueryStr1);
expectedQueryList.add(exptectedQueryStr2);
compareQueryLists(expectedQueryList, engine.explain(query));
testQueryExecution(TestQuery.NESTED_METRIC_WITH_PAGINATION_QUERY.getQuery());
}
use of com.yahoo.elide.datastores.aggregation.query.Query in project elide by yahoo.
the class H2ExplainQueryTest 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 H2ExplainQueryTest method testNestedMetricQuery.
@Test
public void testNestedMetricQuery() {
Query query = TestQuery.NESTED_METRIC_QUERY.getQuery();
String exptectedQueryStr = getExpectedNestedMetricQuery();
List<String> expectedQueryList = new ArrayList<>();
expectedQueryList.add(exptectedQueryStr);
compareQueryLists(expectedQueryList, engine.explain(query));
testQueryExecution(TestQuery.NESTED_METRIC_QUERY.getQuery());
}
Aggregations