Search in sources :

Example 16 with ParsingOptions

use of io.prestosql.sql.parser.ParsingOptions in project hetu-core by openlookeng.

the class TreeAssertions method assertFormattedSql.

public static void assertFormattedSql(SqlParser sqlParser, Node expected) {
    ParsingOptions parsingOptions = new ParsingOptions(AS_DOUBLE);
    assertFormattedSql(sqlParser, parsingOptions, expected);
}
Also used : ParsingOptions(io.prestosql.sql.parser.ParsingOptions)

Example 17 with ParsingOptions

use of io.prestosql.sql.parser.ParsingOptions in project hetu-core by openlookeng.

the class CubeFinishOperator method mergePredicates.

private CubeFilter mergePredicates(CubeFilter existing, String newPredicateString) {
    String sourceTablePredicate = existing == null ? null : existing.getSourceTablePredicate();
    if (newPredicateString == null && sourceTablePredicate == null) {
        return null;
    } else if (newPredicateString == null) {
        return new CubeFilter(sourceTablePredicate, null);
    }
    SqlParser sqlParser = new SqlParser();
    Expression newPredicate = sqlParser.createExpression(newPredicateString, new ParsingOptions());
    if (!updateMetadata.isOverwrite() && existing != null && existing.getCubePredicate() != null) {
        newPredicate = ExpressionUtils.or(sqlParser.createExpression(existing.getCubePredicate(), new ParsingOptions()), newPredicate);
    }
    // Merge new data predicate with existing predicate string
    CubeRangeCanonicalizer canonicalizer = new CubeRangeCanonicalizer(metadata, session, types);
    newPredicate = canonicalizer.mergePredicates(newPredicate);
    String formatExpression = newPredicate.equals(BooleanLiteral.TRUE_LITERAL) ? null : ExpressionFormatter.formatExpression(newPredicate, Optional.empty());
    return formatExpression == null && sourceTablePredicate == null ? null : new CubeFilter(sourceTablePredicate, formatExpression);
}
Also used : Expression(io.prestosql.sql.tree.Expression) ParsingOptions(io.prestosql.sql.parser.ParsingOptions) CubeFilter(io.hetu.core.spi.cube.CubeFilter) SqlParser(io.prestosql.sql.parser.SqlParser)

Aggregations

ParsingOptions (io.prestosql.sql.parser.ParsingOptions)17 SqlParser (io.prestosql.sql.parser.SqlParser)10 Expression (io.prestosql.sql.tree.Expression)10 ComparisonExpression (io.prestosql.sql.tree.ComparisonExpression)5 CubeFilter (io.hetu.core.spi.cube.CubeFilter)4 Symbol (io.prestosql.spi.plan.Symbol)4 OriginalExpressionUtils.castToExpression (io.prestosql.sql.relational.OriginalExpressionUtils.castToExpression)4 OriginalExpressionUtils.castToRowExpression (io.prestosql.sql.relational.OriginalExpressionUtils.castToRowExpression)4 ParsingException (io.prestosql.sql.parser.ParsingException)3 ExpressionDomainTranslator (io.prestosql.sql.planner.ExpressionDomainTranslator)3 TypeProvider (io.prestosql.sql.planner.TypeProvider)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 CallExpression (io.prestosql.spi.relation.CallExpression)2 ConstantExpression (io.prestosql.spi.relation.ConstantExpression)2 RowExpression (io.prestosql.spi.relation.RowExpression)2 VariableReferenceExpression (io.prestosql.spi.relation.VariableReferenceExpression)2 ArithmeticBinaryExpression (io.prestosql.sql.tree.ArithmeticBinaryExpression)2 BetweenPredicate (io.prestosql.sql.tree.BetweenPredicate)2 QualifiedName (io.prestosql.sql.tree.QualifiedName)2