Search in sources :

Example 11 with RSQLFilterDialect

use of com.yahoo.elide.core.filter.dialect.RSQLFilterDialect in project elide by yahoo.

the class StandardTestBinder method configure.

@Override
protected void configure() {
    EntityDictionary dictionary = EntityDictionary.builder().injector(injector::inject).checks(TestCheckMappings.MAPPINGS).build();
    bind(dictionary).to(EntityDictionary.class);
    // Elide instance
    bindFactory(new Factory<Elide>() {

        @Override
        public Elide provide() {
            DefaultFilterDialect defaultFilterStrategy = new DefaultFilterDialect(dictionary);
            RSQLFilterDialect rsqlFilterStrategy = RSQLFilterDialect.builder().dictionary(dictionary).build();
            MultipleFilterDialect multipleFilterStrategy = new MultipleFilterDialect(Arrays.asList(rsqlFilterStrategy, defaultFilterStrategy), Arrays.asList(rsqlFilterStrategy, defaultFilterStrategy));
            Elide elide = new Elide(new ElideSettingsBuilder(IntegrationTest.getDataStore()).withAuditLogger(auditLogger).withJoinFilterDialect(multipleFilterStrategy).withSubqueryFilterDialect(multipleFilterStrategy).withEntityDictionary(dictionary).withISO8601Dates("yyyy-MM-dd'T'HH:mm'Z'", Calendar.getInstance().getTimeZone()).build());
            elide.doScans();
            return elide;
        }

        @Override
        public void dispose(Elide elide) {
        }
    }).to(Elide.class).named("elide");
    bind(BILLING_SERVICE).to(BillingService.class);
}
Also used : ElideSettingsBuilder(com.yahoo.elide.ElideSettingsBuilder) MultipleFilterDialect(com.yahoo.elide.core.filter.dialect.jsonapi.MultipleFilterDialect) DefaultFilterDialect(com.yahoo.elide.core.filter.dialect.jsonapi.DefaultFilterDialect) Elide(com.yahoo.elide.Elide) EntityDictionary(com.yahoo.elide.core.dictionary.EntityDictionary) RSQLFilterDialect(com.yahoo.elide.core.filter.dialect.RSQLFilterDialect)

Example 12 with RSQLFilterDialect

use of com.yahoo.elide.core.filter.dialect.RSQLFilterDialect in project elide by yahoo.

the class SubscriptionWebSocketConfigurator method buildElide.

protected Elide buildElide(DataStore store, EntityDictionary dictionary) {
    RSQLFilterDialect rsqlFilterStrategy = RSQLFilterDialect.builder().dictionary(dictionary).build();
    ElideSettingsBuilder builder = new ElideSettingsBuilder(store).withAuditLogger(auditLogger).withErrorMapper(errorMapper).withBaseUrl(baseUrl).withJoinFilterDialect(rsqlFilterStrategy).withSubqueryFilterDialect(rsqlFilterStrategy).withEntityDictionary(dictionary).withISO8601Dates("yyyy-MM-dd'T'HH:mm'Z'", Calendar.getInstance().getTimeZone());
    if (verboseErrors) {
        builder = builder.withVerboseErrors();
    }
    Elide elide = new Elide(builder.build());
    elide.doScans();
    return elide;
}
Also used : ElideSettingsBuilder(com.yahoo.elide.ElideSettingsBuilder) Elide(com.yahoo.elide.Elide) RSQLFilterDialect(com.yahoo.elide.core.filter.dialect.RSQLFilterDialect)

Example 13 with RSQLFilterDialect

use of com.yahoo.elide.core.filter.dialect.RSQLFilterDialect 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 14 with RSQLFilterDialect

use of com.yahoo.elide.core.filter.dialect.RSQLFilterDialect 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)

Example 15 with RSQLFilterDialect

use of com.yahoo.elide.core.filter.dialect.RSQLFilterDialect in project elide by yahoo.

the class QueryKeyExtractorTest method testFullQuery.

@Test
public void testFullQuery() throws Exception {
    RSQLFilterDialect filterParser = RSQLFilterDialect.builder().dictionary(dictionary).build();
    Map<String, Sorting.SortOrder> sortMap = new TreeMap<>();
    sortMap.put("playerName", Sorting.SortOrder.asc);
    Query query = Query.builder().source(playerStatsTable).metricProjection(playerStatsTable.getMetricProjection("highScore")).dimensionProjection(playerStatsTable.getDimensionProjection("overallRating")).timeDimensionProjection(playerStatsTable.getTimeDimensionProjection("recordedDate")).whereFilter(filterParser.parseFilterExpression("countryNickName=='Uncle Sam'", ClassType.of(PlayerStats.class), false)).havingFilter(filterParser.parseFilterExpression("highScore > 300", ClassType.of(PlayerStats.class), false)).sorting(new SortingImpl(sortMap, PlayerStats.class, dictionary)).pagination(new ImmutablePagination(0, 2, false, true)).build();
    assertEquals(// table name
    "example_PlayerStats;" + // columns
    "{highScore;{}}" + // group by
    "{overallRating;{}}" + // time dimensions
    "{recordedDate;{}}" + // where
    "{P;{{example.PlayerStats;java.lang.String;countryNickName;}}IN;9;Uncle Sam;}" + // having
    "{P;{{example.PlayerStats;long;highScore;}}GT;3;300;}" + // sort
    "{example.PlayerStats;{{example.PlayerStats;java.lang.String;playerName;}}asc;}" + // pagination
    "{0;2;1;}", QueryKeyExtractor.extractKey(query));
}
Also used : Query(com.yahoo.elide.datastores.aggregation.query.Query) SortingImpl(com.yahoo.elide.core.sort.SortingImpl) ImmutablePagination(com.yahoo.elide.datastores.aggregation.query.ImmutablePagination) PlayerStats(example.PlayerStats) TreeMap(java.util.TreeMap) RSQLFilterDialect(com.yahoo.elide.core.filter.dialect.RSQLFilterDialect) SQLUnitTest(com.yahoo.elide.datastores.aggregation.framework.SQLUnitTest) Test(org.junit.jupiter.api.Test)

Aggregations

RSQLFilterDialect (com.yahoo.elide.core.filter.dialect.RSQLFilterDialect)19 FilterExpression (com.yahoo.elide.core.filter.expression.FilterExpression)12 Test (org.junit.jupiter.api.Test)12 Book (example.Book)10 PersistentResource (com.yahoo.elide.core.PersistentResource)7 AndFilterExpression (com.yahoo.elide.core.filter.expression.AndFilterExpression)7 NotFilterExpression (com.yahoo.elide.core.filter.expression.NotFilterExpression)7 OrFilterExpression (com.yahoo.elide.core.filter.expression.OrFilterExpression)7 PermissionExecutor (com.yahoo.elide.core.security.PermissionExecutor)7 EntityDictionary (com.yahoo.elide.core.dictionary.EntityDictionary)6 Elide (com.yahoo.elide.Elide)5 ElideSettingsBuilder (com.yahoo.elide.ElideSettingsBuilder)5 DataStoreTransaction (com.yahoo.elide.core.datastore.DataStoreTransaction)5 SQLUnitTest (com.yahoo.elide.datastores.aggregation.framework.SQLUnitTest)3 Query (com.yahoo.elide.datastores.aggregation.query.Query)3 Author (example.Author)3 RequestScope (com.yahoo.elide.core.RequestScope)2 TestRequestScope (com.yahoo.elide.core.TestRequestScope)2 DefaultFilterDialect (com.yahoo.elide.core.filter.dialect.jsonapi.DefaultFilterDialect)2 MultipleFilterDialect (com.yahoo.elide.core.filter.dialect.jsonapi.MultipleFilterDialect)2