@Override protected ExtractionResult visitInPredicate(InPredicate node, Boolean complement) { if (!(node.getValueList() instanceof InListExpression)) { return super.visitInPredicate(node, complement); } InListExpression valueList = (InListExpression) node.getValueList(); checkState(!valueList.getValues().isEmpty(), "InListExpression should never be empty"); ImmutableList.Builder<Expression> disjuncts = ImmutableList.builder(); for (Expression expression : valueList.getValues()) { disjuncts.add(new ComparisonExpression(EQUAL, node.getValue(), expression)); } ExtractionResult extractionResult = process(or(disjuncts.build()), complement); // preserve original IN predicate as remaining predicate if (extractionResult.tupleDomain.isAll()) { Expression originalPredicate = node; if (complement) { originalPredicate = new NotExpression(originalPredicate); } return new ExtractionResult(extractionResult.tupleDomain, originalPredicate); } return extractionResult; }
case LESS_THAN_OR_EQUAL: case NOT_EQUAL: return new ExtractionResult(TupleDomain.none(), TRUE_LITERAL); return new ExtractionResult( TupleDomain.withColumnDomains(ImmutableMap.of(column, domain)), TRUE_LITERAL); return new ExtractionResult( TupleDomain.withColumnDomains(ImmutableMap.of(column, domain)), TRUE_LITERAL);
switch (operator) { case AND: return new ExtractionResult( leftTupleDomain.intersect(rightTupleDomain), combineConjuncts(leftResult.getRemainingExpression(), rightResult.getRemainingExpression())); return new ExtractionResult(columnUnionedTupleDomain, remainingExpression);
switch (type) { case AND: return new ExtractionResult( leftTupleDomain.intersect(rightTupleDomain), combineConjuncts(leftResult.getRemainingExpression(), rightResult.getRemainingExpression())); return new ExtractionResult(columnUnionedTupleDomain, remainingExpression);
case LESS_THAN_OR_EQUAL: case NOT_EQUAL: return new ExtractionResult(TupleDomain.none(), TRUE_LITERAL); return new ExtractionResult( TupleDomain.withColumnDomains(ImmutableMap.of(column, domain)), TRUE_LITERAL); return new ExtractionResult( TupleDomain.withColumnDomains(ImmutableMap.of(column, domain)), TRUE_LITERAL);
@Override protected ExtractionResult visitIsNotNullPredicate(IsNotNullPredicate node, Boolean complement) { if (!(node.getValue() instanceof QualifiedNameReference)) { return super.visitIsNotNullPredicate(node, complement); } Symbol symbol = Symbol.fromQualifiedName(((QualifiedNameReference) node.getValue()).getName()); Type columnType = checkedTypeLookup(symbol); Domain domain = complementIfNecessary(Domain.notNull(columnType), complement); return new ExtractionResult( TupleDomain.withColumnDomains(ImmutableMap.of(symbol, domain)), TRUE_LITERAL); }
@Override protected ExtractionResult visitIsNullPredicate(IsNullPredicate node, Boolean complement) { if (!(node.getValue() instanceof QualifiedNameReference)) { return super.visitIsNullPredicate(node, complement); } Symbol symbol = Symbol.fromQualifiedName(((QualifiedNameReference) node.getValue()).getName()); Type columnType = checkedTypeLookup(symbol); Domain domain = complementIfNecessary(Domain.onlyNull(columnType), complement); return new ExtractionResult( TupleDomain.withColumnDomains(ImmutableMap.of(symbol, domain)), TRUE_LITERAL); }
@Override protected ExtractionResult visitNullLiteral(NullLiteral node, Boolean complement) { return new ExtractionResult(TupleDomain.none(), TRUE_LITERAL); } }
@Override protected ExtractionResult visitExpression(Expression node, Boolean complement) { // If we don't know how to process this node, the default response is to say that the TupleDomain is "all" return new ExtractionResult(TupleDomain.all(), complementIfNecessary(node, complement)); }
@Override protected ExtractionResult visitBooleanLiteral(BooleanLiteral node, Boolean complement) { boolean value = complement ? !node.getValue() : node.getValue(); return new ExtractionResult(value ? TupleDomain.all() : TupleDomain.none(), TRUE_LITERAL); }
@Override protected ExtractionResult visitIsNotNullPredicate(IsNotNullPredicate node, Boolean complement) { if (!(node.getValue() instanceof SymbolReference)) { return super.visitIsNotNullPredicate(node, complement); } Symbol symbol = Symbol.from(node.getValue()); Type columnType = checkedTypeLookup(symbol); Domain domain = complementIfNecessary(Domain.notNull(columnType), complement); return new ExtractionResult( TupleDomain.withColumnDomains(ImmutableMap.of(symbol, domain)), TRUE_LITERAL); }
@Override protected ExtractionResult visitIsNullPredicate(IsNullPredicate node, Boolean complement) { if (!(node.getValue() instanceof SymbolReference)) { return super.visitIsNullPredicate(node, complement); } Symbol symbol = Symbol.from(node.getValue()); Type columnType = checkedTypeLookup(symbol); Domain domain = complementIfNecessary(Domain.onlyNull(columnType), complement); return new ExtractionResult( TupleDomain.withColumnDomains(ImmutableMap.of(symbol, domain)), TRUE_LITERAL); }
@Override protected ExtractionResult visitNullLiteral(NullLiteral node, Boolean complement) { return new ExtractionResult(TupleDomain.none(), TRUE_LITERAL); } }
@Override protected ExtractionResult visitBooleanLiteral(BooleanLiteral node, Boolean complement) { boolean value = complement ? !node.getValue() : node.getValue(); return new ExtractionResult(value ? TupleDomain.all() : TupleDomain.none(), TRUE_LITERAL); }
@Override protected ExtractionResult visitExpression(Expression node, Boolean complement) { // If we don't know how to process this node, the default response is to say that the TupleDomain is "all" return new ExtractionResult(TupleDomain.all(), complementIfNecessary(node, complement)); }