@Override protected R visitIsNotNullPredicate(IsNotNullPredicate node, C context) { return process(node.getValue(), context); }
@Override protected String visitIsNotNullPredicate(IsNotNullPredicate node, Void context) { return "(" + process(node.getValue(), context) + " IS NOT NULL)"; }
@Override protected Boolean visitIsNotNullPredicate(IsNotNullPredicate node, Void context) { return process(node.getValue(), context); }
@Override protected Type visitIsNotNullPredicate(IsNotNullPredicate node, StackableAstVisitorContext<Context> context) { process(node.getValue(), context); return setExpressionType(node, BOOLEAN); }
@Override protected Boolean visitIsNotNullPredicate(IsNotNullPredicate actual, Node expectedExpression) { if (!(expectedExpression instanceof IsNotNullPredicate)) { return false; } IsNotNullPredicate expected = (IsNotNullPredicate) expectedExpression; return process(actual.getValue(), expected.getValue()); }
@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 RowExpression visitIsNotNullPredicate(IsNotNullPredicate node, Void context) { RowExpression expression = process(node.getValue(), context); return call( Signatures.notSignature(), BOOLEAN, call(Signatures.isNullSignature(expression.getType()), BOOLEAN, ImmutableList.of(expression))); }
@Override public Expression rewriteIsNotNullPredicate(IsNotNullPredicate node, Void context, ExpressionTreeRewriter<Void> treeRewriter) { Expression value = treeRewriter.rewrite(node.getValue(), context); return new NotExpression(new IsNullPredicate(value)); }
@Override protected PlanNodeStatsEstimate visitIsNotNullPredicate(IsNotNullPredicate 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() * (1 - symbolStats.getNullsFraction())); result.addSymbolStatistics(symbol, symbolStats.mapNullsFraction(x -> 0.0)); return result.build(); } return PlanNodeStatsEstimate.unknown(); }
@Override protected String visitIsNotNullPredicate(IsNotNullPredicate node, Boolean unmangleNames) { if (!(node.getValue() instanceof Identifier)) { throw new IllegalArgumentException("inlined expressions are not supported"); } String variableName = "#" + variable[0]++; nameBuilder.put(variableName, ((Identifier) node.getValue()).getValue()); return format("attribute_exists(%s)", variableName); }
@Override protected String visitIsNotNullPredicate(IsNotNullPredicate node, Void context) { return "(" + process(node.getValue(), context) + " IS NOT NULL)"; }
@Override protected String visitIsNotNullPredicate(IsNotNullPredicate node, Boolean context) { return process(node.getValue(), context) + " != null"; }
@Override protected String visitIsNotNullPredicate(IsNotNullPredicate node, Boolean negate) { if (negate) { return visitIsNullPredicate(new IsNullPredicate(node.getValue()), !negate); } String column = process(node.getValue(), negate); return "SELECT date, dimension, _user_set FROM " + column + " WHERE dimension is not null"; }
@Override protected R visitIsNotNullPredicate(IsNotNullPredicate node, C context) { return process(node.getValue(), context); }
@Override protected String visitIsNotNullPredicate(IsNotNullPredicate node, Void context) { return "(" + process(node.getValue(), context) + " IS NOT NULL)"; }
@Override protected String visitLogicalBinaryExpression(LogicalBinaryExpression node, Boolean negate) { LogicalBinaryExpression.Type type = node.getType(); if (type == AND) { // TODO find a better way // Optimization for the case when one hand or binary expression is IS NOT NULL predicate if (node.getRight() instanceof IsNotNullPredicate && !(node.getLeft() instanceof IsNotNullPredicate) || node.getLeft() instanceof IsNotNullPredicate && !(node.getRight() instanceof IsNotNullPredicate)) { Expression isNotNull = node.getRight() instanceof IsNotNullPredicate ? node.getRight() : node.getLeft(); Expression setExpression = isNotNull == node.getRight() ? node.getLeft() : node.getRight(); String excludeQuery = process(new IsNullPredicate(((IsNotNullPredicate) isNotNull).getValue()), negate); return "SELECT l.date, l.dimension, l._user_set FROM (" + process(setExpression, negate) + ") l LEFT JOIN (" + excludeQuery + ") r ON (r.date = l.date AND l.dimension = r.dimension) WHERE r.date IS NULL"; } String right = process(node.getRight(), negate); String left = process(node.getLeft(), negate); // TODO: use INTERSECT when it's implemented in Presto. return "SELECT l.date, l.dimension, l._user_set FROM (" + left + ") l JOIN (" + right + ") r ON (r.date = l.date)"; } else if (type == OR) { return "SELECT date, dimension, _user_set FROM (" + process(node.getLeft(), negate) + " UNION ALL " + process(node.getRight(), negate) + ")"; } else { throw new IllegalStateException(); } }
@Override protected Boolean visitIsNotNullPredicate(IsNotNullPredicate node, Void context) { return process(node.getValue(), context); }
@Override protected RowExpression visitIsNotNullPredicate(IsNotNullPredicate node, Void context) { RowExpression expression = process(node.getValue(), context); return call( Signatures.notSignature(), BOOLEAN, call(Signatures.isNullSignature(expression.getType()), BOOLEAN, ImmutableList.of(expression))); }