Search in sources :

Example 51 with Query

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

the class SkipOptimizerTest method testNegatingOptimizer.

@Test
public void testNegatingOptimizer() {
    when(optimizer.hint()).thenReturn("JoinBeforeAggregate");
    when(optimizer.negateHint()).thenReturn("NoJoinBeforeAggregate");
    Query query = TestQuery.WHERE_AND.getQuery();
    engine.explain(query);
    verify(optimizer, never()).optimize(any());
}
Also used : Query(com.yahoo.elide.datastores.aggregation.query.Query) SQLUnitTest(com.yahoo.elide.datastores.aggregation.framework.SQLUnitTest) Test(org.junit.jupiter.api.Test)

Example 52 with Query

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

the class PostgresExplainQueryTest method testExplainHavingMetricsAndDims.

@Test
public void testExplainHavingMetricsAndDims() throws Exception {
    Query query = TestQuery.HAVING_METRICS_AND_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 " + "AND MAX(\"example_PlayerStats\".\"highScore\") > :XXX)";
    compareQueryLists(expectedQueryStr, engine.explain(query));
    testQueryExecution(TestQuery.HAVING_METRICS_AND_DIMS.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 53 with Query

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

the class PrestoDBExplainQueryTest method testJoinWithMetrics.

@Test
public void testJoinWithMetrics() throws Exception {
    Query query = TestQuery.METRIC_JOIN.getQuery();
    String expectedQueryStr = "SELECT " + "MAX(\"example_VideoGame_playerStats_XXX\".\"highScore\") / SUM(\"example_VideoGame\".\"timeSpent\") AS \"normalizedHighScore\" " + "FROM \"videoGames\" AS \"example_VideoGame\" " + "LEFT OUTER JOIN \"playerStats\" AS \"example_VideoGame_playerStats_XXX\" " + "ON \"example_VideoGame\".\"player_id\" = \"example_VideoGame_playerStats_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 54 with Query

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

the class PrestoDBExplainQueryTest method testExplainHavingMetricsAndDims.

@Test
public void testExplainHavingMetricsAndDims() throws Exception {
    Query query = TestQuery.HAVING_METRICS_AND_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 " + "AND MAX(\"example_PlayerStats\".\"highScore\") > :XXX)";
    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 55 with Query

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

the class PrestoDBExplainQueryTest 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));
}
Also used : Query(com.yahoo.elide.datastores.aggregation.query.Query) 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