Search in sources :

Example 6 with CubeFilter

use of io.hetu.core.spi.cube.CubeFilter 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

CubeFilter (io.hetu.core.spi.cube.CubeFilter)6 SqlParser (io.prestosql.sql.parser.SqlParser)4 Expression (io.prestosql.sql.tree.Expression)4 ParsingOptions (io.prestosql.sql.parser.ParsingOptions)3 OriginalExpressionUtils.castToRowExpression (io.prestosql.sql.relational.OriginalExpressionUtils.castToRowExpression)3 ConstantExpression (io.prestosql.spi.relation.ConstantExpression)2 ExpressionDomainTranslator (io.prestosql.sql.planner.ExpressionDomainTranslator)2 OriginalExpressionUtils.castToExpression (io.prestosql.sql.relational.OriginalExpressionUtils.castToExpression)2 ComparisonExpression (io.prestosql.sql.tree.ComparisonExpression)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 ImmutableList (com.google.common.collect.ImmutableList)1 Futures.immediateFuture (com.google.common.util.concurrent.Futures.immediateFuture)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 StarTreeMetadataBuilder (io.hetu.core.cube.startree.tree.StarTreeMetadataBuilder)1 CubeAggregateFunction (io.hetu.core.spi.cube.CubeAggregateFunction)1 CubeMetadata (io.hetu.core.spi.cube.CubeMetadata)1 CubeMetadataBuilder (io.hetu.core.spi.cube.CubeMetadataBuilder)1 CubeStatus (io.hetu.core.spi.cube.CubeStatus)1 AggregationSignature (io.hetu.core.spi.cube.aggregator.AggregationSignature)1