use of com.yahoo.elide.datastores.aggregation.filter.visitor.SplitFilterExpressionVisitor in project elide by yahoo.
the class EntityProjectionTranslator method splitFilters.
/**
* Gets whereFilter and havingFilter based on provided filter expression from {@link EntityProjection}.
*/
private void splitFilters() {
FilterExpression filterExpression = entityProjection.getFilterExpression();
if (filterExpression == null) {
whereFilter = null;
havingFilter = null;
return;
}
SplitFilterExpressionVisitor visitor = new SplitFilterExpressionVisitor(queriedTable);
FilterConstraints constraints = filterExpression.accept(visitor);
whereFilter = constraints.getWhereExpression();
havingFilter = constraints.getHavingExpression();
}
use of com.yahoo.elide.datastores.aggregation.filter.visitor.SplitFilterExpressionVisitor in project elide by yahoo.
the class EntityProjectionTranslatorTest method testWherePromotion.
@Test
public void testWherePromotion() throws ParseException {
FilterExpression originalFilter = filterParser.parseFilterExpression("overallRating==Good,lowScore[foo:bar]<45", playerStatsType, false);
EntityProjection projection = basicProjection.copyOf().filterExpression(originalFilter).build();
EntityProjectionTranslator translator = new EntityProjectionTranslator(engine, playerStatsTable, projection, scope, true);
Query query = translator.getQuery();
SplitFilterExpressionVisitor visitor = new SplitFilterExpressionVisitor(playerStatsTable);
FilterConstraints constraints = originalFilter.accept(visitor);
FilterExpression whereFilter = constraints.getWhereExpression();
FilterExpression havingFilter = constraints.getHavingExpression();
assertEquals(whereFilter, query.getWhereFilter());
assertEquals(havingFilter, query.getHavingFilter());
}
use of com.yahoo.elide.datastores.aggregation.filter.visitor.SplitFilterExpressionVisitor in project elide by yahoo.
the class DefaultQueryValidatorTest method testHavingFilterOnDimensionTable.
@Test
public void testHavingFilterOnDimensionTable() throws ParseException {
FilterExpression originalFilter = filterParser.parseFilterExpression("country.isoCode==USA,lowScore<45", playerStatsType, false);
SplitFilterExpressionVisitor visitor = new SplitFilterExpressionVisitor(playerStatsTable);
FilterConstraints constraints = originalFilter.accept(visitor);
FilterExpression whereFilter = constraints.getWhereExpression();
FilterExpression havingFilter = constraints.getHavingExpression();
Query query = Query.builder().source(playerStatsTable).metricProjection(playerStatsTable.getMetricProjection("lowScore")).whereFilter(whereFilter).havingFilter(havingFilter).build();
validateQuery(query, "Invalid operation: Relationship traversal not supported for analytic queries.");
}
use of com.yahoo.elide.datastores.aggregation.filter.visitor.SplitFilterExpressionVisitor in project elide by yahoo.
the class DefaultQueryValidatorTest method testInvalidColumnValueInFilter.
@Test
public void testInvalidColumnValueInFilter() throws ParseException {
FilterExpression originalFilter = filterParser.parseFilterExpression("countryIsoCode==Invalid,lowScore<45", playerStatsType, false);
SplitFilterExpressionVisitor visitor = new SplitFilterExpressionVisitor(playerStatsTable);
FilterConstraints constraints = originalFilter.accept(visitor);
FilterExpression whereFilter = constraints.getWhereExpression();
FilterExpression havingFilter = constraints.getHavingExpression();
Query query = Query.builder().source(playerStatsTable).metricProjection(playerStatsTable.getMetricProjection("lowScore")).dimensionProjection(playerStatsTable.getDimensionProjection("countryIsoCode")).whereFilter(whereFilter).havingFilter(havingFilter).build();
validateQuery(query, "Invalid operation: Column 'countryIsoCode' values must match one of these values: [HKG, USA]");
}
use of com.yahoo.elide.datastores.aggregation.filter.visitor.SplitFilterExpressionVisitor in project elide by yahoo.
the class DefaultQueryValidatorTest method testValidRegexColumnValueInFilter.
@Test
public void testValidRegexColumnValueInFilter() throws ParseException {
FilterExpression originalFilter = filterParser.parseFilterExpression("countryIsoCode=in=('*H'),lowScore<45", playerStatsType, false);
SplitFilterExpressionVisitor visitor = new SplitFilterExpressionVisitor(playerStatsTable);
FilterConstraints constraints = originalFilter.accept(visitor);
FilterExpression whereFilter = constraints.getWhereExpression();
FilterExpression havingFilter = constraints.getHavingExpression();
Query query = Query.builder().source(playerStatsTable).metricProjection(playerStatsTable.getMetricProjection("lowScore")).dimensionProjection(playerStatsTable.getDimensionProjection("countryIsoCode")).whereFilter(whereFilter).havingFilter(havingFilter).build();
validateQueryDoesNotThrow(query);
}
Aggregations