Search in sources :

Example 1 with SplitFilterExpressionVisitor

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();
}
Also used : SplitFilterExpressionVisitor(com.yahoo.elide.datastores.aggregation.filter.visitor.SplitFilterExpressionVisitor) FilterConstraints(com.yahoo.elide.datastores.aggregation.filter.visitor.FilterConstraints) FilterExpression(com.yahoo.elide.core.filter.expression.FilterExpression)

Example 2 with SplitFilterExpressionVisitor

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());
}
Also used : EntityProjection(com.yahoo.elide.core.request.EntityProjection) Query(com.yahoo.elide.datastores.aggregation.query.Query) SplitFilterExpressionVisitor(com.yahoo.elide.datastores.aggregation.filter.visitor.SplitFilterExpressionVisitor) FilterConstraints(com.yahoo.elide.datastores.aggregation.filter.visitor.FilterConstraints) FilterExpression(com.yahoo.elide.core.filter.expression.FilterExpression) SQLUnitTest(com.yahoo.elide.datastores.aggregation.framework.SQLUnitTest) Test(org.junit.jupiter.api.Test)

Example 3 with SplitFilterExpressionVisitor

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.");
}
Also used : Query(com.yahoo.elide.datastores.aggregation.query.Query) SplitFilterExpressionVisitor(com.yahoo.elide.datastores.aggregation.filter.visitor.SplitFilterExpressionVisitor) FilterConstraints(com.yahoo.elide.datastores.aggregation.filter.visitor.FilterConstraints) FilterExpression(com.yahoo.elide.core.filter.expression.FilterExpression) SQLUnitTest(com.yahoo.elide.datastores.aggregation.framework.SQLUnitTest) Test(org.junit.jupiter.api.Test)

Example 4 with SplitFilterExpressionVisitor

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]");
}
Also used : Query(com.yahoo.elide.datastores.aggregation.query.Query) SplitFilterExpressionVisitor(com.yahoo.elide.datastores.aggregation.filter.visitor.SplitFilterExpressionVisitor) FilterConstraints(com.yahoo.elide.datastores.aggregation.filter.visitor.FilterConstraints) FilterExpression(com.yahoo.elide.core.filter.expression.FilterExpression) SQLUnitTest(com.yahoo.elide.datastores.aggregation.framework.SQLUnitTest) Test(org.junit.jupiter.api.Test)

Example 5 with SplitFilterExpressionVisitor

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);
}
Also used : Query(com.yahoo.elide.datastores.aggregation.query.Query) SplitFilterExpressionVisitor(com.yahoo.elide.datastores.aggregation.filter.visitor.SplitFilterExpressionVisitor) FilterConstraints(com.yahoo.elide.datastores.aggregation.filter.visitor.FilterConstraints) FilterExpression(com.yahoo.elide.core.filter.expression.FilterExpression) SQLUnitTest(com.yahoo.elide.datastores.aggregation.framework.SQLUnitTest) Test(org.junit.jupiter.api.Test)

Aggregations

FilterExpression (com.yahoo.elide.core.filter.expression.FilterExpression)6 FilterConstraints (com.yahoo.elide.datastores.aggregation.filter.visitor.FilterConstraints)6 SplitFilterExpressionVisitor (com.yahoo.elide.datastores.aggregation.filter.visitor.SplitFilterExpressionVisitor)6 SQLUnitTest (com.yahoo.elide.datastores.aggregation.framework.SQLUnitTest)5 Query (com.yahoo.elide.datastores.aggregation.query.Query)5 Test (org.junit.jupiter.api.Test)5 EntityProjection (com.yahoo.elide.core.request.EntityProjection)1