Search in sources :

Example 91 with Query

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);
}
Also used : Query(com.yahoo.elide.datastores.aggregation.query.Query) Test(org.junit.jupiter.api.Test) SQLUnitTest(com.yahoo.elide.datastores.aggregation.framework.SQLUnitTest)

Example 92 with 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());
}
Also used : Query(com.yahoo.elide.datastores.aggregation.query.Query) Test(org.junit.jupiter.api.Test) SQLUnitTest(com.yahoo.elide.datastores.aggregation.framework.SQLUnitTest)

Example 93 with Query

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());
}
Also used : Query(com.yahoo.elide.datastores.aggregation.query.Query) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test) SQLUnitTest(com.yahoo.elide.datastores.aggregation.framework.SQLUnitTest)

Example 94 with Query

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);
}
Also used : Query(com.yahoo.elide.datastores.aggregation.query.Query) Test(org.junit.jupiter.api.Test) SQLUnitTest(com.yahoo.elide.datastores.aggregation.framework.SQLUnitTest)

Example 95 with 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());
}
Also used : Query(com.yahoo.elide.datastores.aggregation.query.Query) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test) SQLUnitTest(com.yahoo.elide.datastores.aggregation.framework.SQLUnitTest)

Aggregations

Query (com.yahoo.elide.datastores.aggregation.query.Query)242 Test (org.junit.jupiter.api.Test)229 SQLUnitTest (com.yahoo.elide.datastores.aggregation.framework.SQLUnitTest)214 SQLTable (com.yahoo.elide.datastores.aggregation.queryengines.sql.metadata.SQLTable)51 FilterExpression (com.yahoo.elide.core.filter.expression.FilterExpression)46 Argument (com.yahoo.elide.core.request.Argument)43 ArrayList (java.util.ArrayList)42 FilterPredicate (com.yahoo.elide.core.filter.predicates.FilterPredicate)37 Path (com.yahoo.elide.core.Path)35 Day (com.yahoo.elide.datastores.aggregation.timegrains.Day)31 AndFilterExpression (com.yahoo.elide.core.filter.expression.AndFilterExpression)29 SortingImpl (com.yahoo.elide.core.sort.SortingImpl)29 PlayerStats (example.PlayerStats)29 TreeMap (java.util.TreeMap)29 OrFilterExpression (com.yahoo.elide.core.filter.expression.OrFilterExpression)28 HashMap (java.util.HashMap)26 Date (java.util.Date)19 HashSet (java.util.HashSet)17 ToString (lombok.ToString)16 SQLDimensionProjection (com.yahoo.elide.datastores.aggregation.queryengines.sql.query.SQLDimensionProjection)14