Search in sources :

Example 56 with Query

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

the class PrestoDBExplainQueryTest 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));
}
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 57 with Query

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

the class PrestoDBExplainQueryTest 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\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 58 with Query

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

the class PrestoDBExplainQueryTest method testNestedMetricWithWhereQuery.

@Test
public void testNestedMetricWithWhereQuery() {
    Query query = TestQuery.NESTED_METRIC_WITH_WHERE_QUERY.getQuery();
    String exptectedQueryStr = getExpectedNestedMetricWithWhereQuery().replace(BACKTICK, DOUBLE_QUOTE);
    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)

Example 59 with Query

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

the class PrestoDBExplainQueryTest method testNestedMetricWithAliasesQuery.

@Test
public void testNestedMetricWithAliasesQuery() {
    Query query = TestQuery.NESTED_METRIC_WITH_ALIASES_QUERY.getQuery();
    String queryStr = engine.explain(query).get(0);
    queryStr = repeatedWhitespacePattern.matcher(queryStr).replaceAll(" ");
    queryStr = queryStr.replaceAll(":[a-zA-Z0-9_]+", ":XXX");
    queryStr = queryStr.replaceAll("PlayerStats_\\d+", "PlayerStats_XXX");
    queryStr = queryStr.replaceAll("PlayerStats_country_\\d+", "PlayerStats_country_XXX");
    String expectedStr = getExpectedNestedMetricWithAliasesSQL(true).replace(BACKTICK, DOUBLE_QUOTE);
    assertEquals(expectedStr, queryStr);
}
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 60 with Query

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

the class PrestoDBExplainQueryTest method testNestedMetricQuery.

@Test
public void testNestedMetricQuery() {
    Query query = TestQuery.NESTED_METRIC_QUERY.getQuery();
    String exptectedQueryStr = getExpectedNestedMetricQuery().replace(BACKTICK, DOUBLE_QUOTE);
    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