Search in sources :

Example 1 with PlayerStatsWithRequiredFilter

use of example.PlayerStatsWithRequiredFilter in project elide by yahoo.

the class AggregationDataStoreTransactionTest method testMissingRequiredColumnFilter.

@Test
public void testMissingRequiredColumnFilter() throws Exception {
    Type<PlayerStatsWithRequiredFilter> tableType = ClassType.of(PlayerStatsWithRequiredFilter.class);
    EntityDictionary dictionary = EntityDictionary.builder().build();
    dictionary.bindEntity(PlayerStatsWithRequiredFilter.class);
    SQLTable table = new SQLTable(new Namespace(DEFAULT_NAMESPACE), tableType, dictionary);
    Query query = Query.builder().column(SQLMetricProjection.builder().name("highScore").build()).source(table).build();
    AggregationDataStoreTransaction tx = new AggregationDataStoreTransaction(queryEngine, cache, queryLogger);
    assertThrows(BadRequestException.class, () -> tx.addColumnFilterArguments(table, query, dictionary));
}
Also used : PlayerStatsWithRequiredFilter(example.PlayerStatsWithRequiredFilter) NativeQuery(com.yahoo.elide.datastores.aggregation.queryengines.sql.query.NativeQuery) Query(com.yahoo.elide.datastores.aggregation.query.Query) SQLTable(com.yahoo.elide.datastores.aggregation.queryengines.sql.metadata.SQLTable) EntityDictionary(com.yahoo.elide.core.dictionary.EntityDictionary) Namespace(com.yahoo.elide.datastores.aggregation.metadata.models.Namespace) SQLUnitTest(com.yahoo.elide.datastores.aggregation.framework.SQLUnitTest) Test(org.junit.jupiter.api.Test)

Example 2 with PlayerStatsWithRequiredFilter

use of example.PlayerStatsWithRequiredFilter in project elide by yahoo.

the class AggregationDataStoreTransactionTest method testRequiredColumnFilterArguments.

@Test
public void testRequiredColumnFilterArguments() throws Exception {
    Type<PlayerStatsWithRequiredFilter> tableType = ClassType.of(PlayerStatsWithRequiredFilter.class);
    EntityDictionary dictionary = EntityDictionary.builder().build();
    dictionary.bindEntity(PlayerStatsWithRequiredFilter.class);
    SQLTable table = new SQLTable(new Namespace(DEFAULT_NAMESPACE), tableType, dictionary);
    RSQLFilterDialect filterDialect = RSQLFilterDialect.builder().dictionary(dictionary).build();
    FilterExpression where = filterDialect.parse(tableType, new HashSet<>(), "recordedDate>2019-07-12T00:00Z", NO_VERSION);
    Query query = Query.builder().column(SQLMetricProjection.builder().name("highScore").alias("highScore").build()).whereFilter(where).source(table).build();
    AggregationDataStoreTransaction tx = new AggregationDataStoreTransaction(queryEngine, cache, queryLogger);
    Query modifiedQuery = tx.addColumnFilterArguments(table, query, dictionary);
    Map<String, Argument> columnArguments = modifiedQuery.getColumnProjection("highScore").getArguments();
    assertTrue(columnArguments.containsKey("recordedDate"));
    assertEquals(1, columnArguments.size());
}
Also used : NativeQuery(com.yahoo.elide.datastores.aggregation.queryengines.sql.query.NativeQuery) Query(com.yahoo.elide.datastores.aggregation.query.Query) Argument(com.yahoo.elide.core.request.Argument) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Namespace(com.yahoo.elide.datastores.aggregation.metadata.models.Namespace) PlayerStatsWithRequiredFilter(example.PlayerStatsWithRequiredFilter) SQLTable(com.yahoo.elide.datastores.aggregation.queryengines.sql.metadata.SQLTable) FilterExpression(com.yahoo.elide.core.filter.expression.FilterExpression) EntityDictionary(com.yahoo.elide.core.dictionary.EntityDictionary) RSQLFilterDialect(com.yahoo.elide.core.filter.dialect.RSQLFilterDialect) SQLUnitTest(com.yahoo.elide.datastores.aggregation.framework.SQLUnitTest) Test(org.junit.jupiter.api.Test)

Example 3 with PlayerStatsWithRequiredFilter

use of example.PlayerStatsWithRequiredFilter in project elide by yahoo.

the class AggregationDataStoreTransactionTest method testRequiredTableFilterArguments.

@Test
public void testRequiredTableFilterArguments() throws Exception {
    Type<PlayerStatsWithRequiredFilter> tableType = ClassType.of(PlayerStatsWithRequiredFilter.class);
    EntityDictionary dictionary = EntityDictionary.builder().build();
    dictionary.bindEntity(PlayerStatsWithRequiredFilter.class);
    SQLTable table = new SQLTable(new Namespace(DEFAULT_NAMESPACE), tableType, dictionary);
    RSQLFilterDialect filterDialect = RSQLFilterDialect.builder().dictionary(dictionary).build();
    FilterExpression where = filterDialect.parse(tableType, new HashSet<>(), "recordedDate>=2019-07-12T00:00Z;recordedDate<2030-07-12T00:00Z", NO_VERSION);
    Query query = Query.builder().source(table).whereFilter(where).build();
    AggregationDataStoreTransaction tx = new AggregationDataStoreTransaction(queryEngine, cache, queryLogger);
    Query modifiedQuery = tx.addTableFilterArguments(table, query, dictionary);
    Map<String, Argument> tableArguments = modifiedQuery.getArguments();
    assertTrue(tableArguments.containsKey("start"));
    assertTrue(tableArguments.containsKey("end"));
    assertEquals(2, tableArguments.size());
}
Also used : NativeQuery(com.yahoo.elide.datastores.aggregation.queryengines.sql.query.NativeQuery) Query(com.yahoo.elide.datastores.aggregation.query.Query) Argument(com.yahoo.elide.core.request.Argument) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Namespace(com.yahoo.elide.datastores.aggregation.metadata.models.Namespace) PlayerStatsWithRequiredFilter(example.PlayerStatsWithRequiredFilter) SQLTable(com.yahoo.elide.datastores.aggregation.queryengines.sql.metadata.SQLTable) FilterExpression(com.yahoo.elide.core.filter.expression.FilterExpression) EntityDictionary(com.yahoo.elide.core.dictionary.EntityDictionary) RSQLFilterDialect(com.yahoo.elide.core.filter.dialect.RSQLFilterDialect) SQLUnitTest(com.yahoo.elide.datastores.aggregation.framework.SQLUnitTest) Test(org.junit.jupiter.api.Test)

Aggregations

EntityDictionary (com.yahoo.elide.core.dictionary.EntityDictionary)3 SQLUnitTest (com.yahoo.elide.datastores.aggregation.framework.SQLUnitTest)3 Namespace (com.yahoo.elide.datastores.aggregation.metadata.models.Namespace)3 Query (com.yahoo.elide.datastores.aggregation.query.Query)3 SQLTable (com.yahoo.elide.datastores.aggregation.queryengines.sql.metadata.SQLTable)3 NativeQuery (com.yahoo.elide.datastores.aggregation.queryengines.sql.query.NativeQuery)3 PlayerStatsWithRequiredFilter (example.PlayerStatsWithRequiredFilter)3 Test (org.junit.jupiter.api.Test)3 RSQLFilterDialect (com.yahoo.elide.core.filter.dialect.RSQLFilterDialect)2 FilterExpression (com.yahoo.elide.core.filter.expression.FilterExpression)2 Argument (com.yahoo.elide.core.request.Argument)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2