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);
}
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;
}
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());
}
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());
}
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));
}
Aggregations