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