Search in sources :

Example 96 with Query

use of com.yahoo.elide.datastores.aggregation.query.Query in project elide by yahoo.

the class H2ExplainQueryTest method testLeftJoin.

@Test
public void testLeftJoin() throws Exception {
    Query query = TestQuery.LEFT_JOIN.getQuery();
    String expectedQueryStr = "SELECT DISTINCT `example_VideoGame_player_XXX`.`name` AS `playerName` FROM `videoGames` AS `example_VideoGame`" + " LEFT OUTER JOIN `players` AS `example_VideoGame_player_XXX` ON `example_VideoGame`.`player_id`" + " = `example_VideoGame_player_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 97 with Query

use of com.yahoo.elide.datastores.aggregation.query.Query in project elide by yahoo.

the class H2ExplainQueryTest method testExplainWhereAnd.

@Test
public void testExplainWhereAnd() throws Exception {
    Query query = TestQuery.WHERE_AND.getQuery();
    String expectedQueryStr = "SELECT MAX(`example_PlayerStats`.`highScore`) AS `highScore`," + "`example_PlayerStats`.`overallRating` AS `overallRating` " + "FROM `playerStats` AS `example_PlayerStats` " + "LEFT OUTER JOIN `countries` AS `example_PlayerStats_country_XXX` " + "ON `example_PlayerStats`.`country_id` = `example_PlayerStats_country_XXX`.`id` " + "WHERE (`example_PlayerStats`.`overallRating` IS NOT NULL AND `example_PlayerStats_country_XXX`.`iso_code` IN (:XXX)) " + " GROUP BY `example_PlayerStats`.`overallRating`\n";
    compareQueryLists(expectedQueryStr, engine.explain(query));
    testQueryExecution(TestQuery.WHERE_AND.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 98 with Query

use of com.yahoo.elide.datastores.aggregation.query.Query in project elide by yahoo.

the class H2ExplainQueryTest method testPaginationMetricsOnly.

@Test
public void testPaginationMetricsOnly() throws Exception {
    // pagination query should be empty since there is no dimension projection
    Query query = TestQuery.PAGINATION_METRIC_ONLY.getQuery();
    String expectedQueryStr = "SELECT MIN(`example_PlayerStats`.`lowScore`) AS `lowScore` " + "FROM `playerStats` AS `example_PlayerStats` " + "LIMIT 5 OFFSET 10\n";
    compareQueryLists(expectedQueryStr, engine.explain(query));
    testQueryExecution(TestQuery.PAGINATION_METRIC_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 99 with Query

use of com.yahoo.elide.datastores.aggregation.query.Query in project elide by yahoo.

the class H2ExplainQueryTest method textExplainWhereOr.

@Test
public void textExplainWhereOr() throws Exception {
    Query query = TestQuery.WHERE_OR.getQuery();
    String expectedQueryStr = "SELECT MAX(`example_PlayerStats`.`highScore`) AS `highScore`," + "`example_PlayerStats`.`overallRating` AS `overallRating` " + "FROM `playerStats` AS `example_PlayerStats` " + "LEFT OUTER JOIN `countries` AS `example_PlayerStats_country_XXX` " + "ON `example_PlayerStats`.`country_id` = `example_PlayerStats_country_XXX`.`id` " + "WHERE (`example_PlayerStats`.`overallRating` IS NOT NULL OR `example_PlayerStats_country_XXX`.`iso_code` IN (:XXX)) " + " GROUP BY `example_PlayerStats`.`overallRating`\n";
    compareQueryLists(expectedQueryStr, engine.explain(query));
    testQueryExecution(TestQuery.WHERE_OR.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 100 with Query

use of com.yahoo.elide.datastores.aggregation.query.Query in project elide by yahoo.

the class HiveExplainQueryTest method testNestedMetricWithHavingQuery.

@Test
public void testNestedMetricWithHavingQuery() {
    Query query = TestQuery.NESTED_METRIC_WITH_HAVING_QUERY.getQuery();
    String exptectedQueryStr = getExpectedNestedMetricWithHavingQuery();
    List<String> expectedQueryList = new ArrayList<>();
    expectedQueryList.add(exptectedQueryStr);
    compareQueryLists(expectedQueryList, engine.explain(query));
}
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