@Override protected R visitIsNullPredicate(IsNullPredicate node, C context) { return process(node.getValue(), context); }
private static IsNullPredicate isNull(Expression expression) { return new IsNullPredicate(expression); }
@Override protected Object visitIsNullPredicate(IsNullPredicate node, Object context) { Object value = process(node.getValue(), context); if (value instanceof Expression) { return new IsNullPredicate(toExpression(value, type(node.getValue()))); } return value == null; }
@Override protected String visitIsNullPredicate(IsNullPredicate node, Boolean negate) { if (negate) { return visitIsNullPredicate(new IsNullPredicate(node.getValue()), !negate); } return "SELECT date, dimension, _user_set FROM " + process(node.getValue(), negate) + " WHERE dimension is null"; }
@Override protected String visitIsNullPredicate(IsNullPredicate node, Void context) { return "(" + process(node.getValue(), context) + " IS NULL)"; }
private static IsNullPredicate isNull(Expression expression) { return new IsNullPredicate(expression); }
@Override protected Object visitIsNullPredicate(IsNullPredicate node, Object context) { Object value = process(node.getValue(), context); if (value instanceof Expression) { return new IsNullPredicate(toExpression(value, expressionTypes.get(node.getValue()))); } return value == null; }
@Override protected Boolean visitIsNullPredicate(IsNullPredicate node, Void context) { return process(node.getValue(), context); }
@Override public Expression rewriteIsNotNullPredicate(IsNotNullPredicate node, Void context, ExpressionTreeRewriter<Void> treeRewriter) { Expression value = treeRewriter.rewrite(node.getValue(), context); return new NotExpression(new IsNullPredicate(value)); }
private static Expression isNotNull(Expression expression) { return new NotExpression(new IsNullPredicate(expression)); }
@Override protected Type visitIsNullPredicate(IsNullPredicate node, StackableAstVisitorContext<Context> context) { process(node.getValue(), context); return setExpressionType(node, BOOLEAN); }
public static Function<Expression, Expression> expressionOrNullSymbols(final Predicate<Symbol>... nullSymbolScopes) { return expression -> { ImmutableList.Builder<Expression> resultDisjunct = ImmutableList.builder(); resultDisjunct.add(expression); for (Predicate<Symbol> nullSymbolScope : nullSymbolScopes) { List<Symbol> symbols = SymbolsExtractor.extractUnique(expression).stream() .filter(nullSymbolScope) .collect(toImmutableList()); if (Iterables.isEmpty(symbols)) { continue; } ImmutableList.Builder<Expression> nullConjuncts = ImmutableList.builder(); for (Symbol symbol : symbols) { nullConjuncts.add(new IsNullPredicate(symbol.toSymbolReference())); } resultDisjunct.add(and(nullConjuncts.build())); } return or(resultDisjunct.build()); }; }
@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); }
private static IsNullPredicate isNull(Symbol symbol) { return new IsNullPredicate(symbol.toSymbolReference()); }
@Override protected RowExpression visitIsNullPredicate(IsNullPredicate node, Void context) { RowExpression expression = process(node.getValue(), context); return call(Signatures.isNullSignature(expression.getType()), BOOLEAN, expression); }
private Expression toPredicate(Domain domain, SymbolReference reference) { if (domain.getValues().isNone()) { return domain.isNullAllowed() ? new IsNullPredicate(reference) : FALSE_LITERAL; } if (domain.getValues().isAll()) { return domain.isNullAllowed() ? TRUE_LITERAL : new NotExpression(new IsNullPredicate(reference)); } List<Expression> disjuncts = new ArrayList<>(); disjuncts.addAll(domain.getValues().getValuesProcessor().transform( ranges -> extractDisjuncts(domain.getType(), ranges, reference), discreteValues -> extractDisjuncts(domain.getType(), discreteValues, reference), allOrNone -> { throw new IllegalStateException("Case should not be reachable"); })); // Add nullability disjuncts if (domain.isNullAllowed()) { disjuncts.add(new IsNullPredicate(reference)); } return combineDisjunctsWithDefault(disjuncts, TRUE_LITERAL); }
@Override protected PlanNodeStatsEstimate visitNotExpression(NotExpression node, Void context) { if (node.getValue() instanceof IsNullPredicate) { return process(new IsNotNullPredicate(((IsNullPredicate) node.getValue()).getValue())); } return subtractSubsetStats(input, process(node.getValue())); }
@Override public Node visitNullPredicate(SqlBaseParser.NullPredicateContext context) { Expression child = (Expression) visit(context.value); if (context.NOT() == null) { return new IsNullPredicate(getLocation(context), child); } return new IsNotNullPredicate(getLocation(context), child); }
@Override protected PlanNodeStatsEstimate visitIsNullPredicate(IsNullPredicate node, Void context) { if (node.getValue() instanceof SymbolReference) { Symbol symbol = Symbol.from(node.getValue()); SymbolStatsEstimate symbolStats = input.getSymbolStatistics(symbol); PlanNodeStatsEstimate.Builder result = PlanNodeStatsEstimate.buildFrom(input); result.setOutputRowCount(input.getOutputRowCount() * symbolStats.getNullsFraction()); result.addSymbolStatistics(symbol, SymbolStatsEstimate.builder() .setNullsFraction(1.0) .setLowValue(NaN) .setHighValue(NaN) .setDistinctValuesCount(0.0) .build()); return result.build(); } return PlanNodeStatsEstimate.unknown(); }