15 package com.cloudera.impala.analysis;
17 import java.util.List;
23 import com.cloudera.impala.thrift.TExprNode;
24 import com.cloudera.impala.thrift.TExprNodeType;
25 import com.cloudera.impala.thrift.TTupleIsNullPredicate;
26 import com.google.common.base.Preconditions;
27 import com.google.common.collect.Lists;
28 import com.google.common.collect.Sets;
44 Preconditions.checkState(tupleIds != null && !tupleIds.isEmpty());
45 this.tupleIds_ = Sets.newHashSet(tupleIds);
53 tupleIds_ = Sets.newHashSet(other.tupleIds_);
60 super.analyze(analyzer);
66 msg.node_type = TExprNodeType.TUPLE_IS_NULL_PRED;
67 msg.tuple_is_null_pred =
new TTupleIsNullPredicate();
72 Preconditions.checkNotNull(tupleDesc,
"Unknown tuple id: " + tid.toString());
73 Preconditions.checkState(tupleDesc.isMaterialized(),
74 String.format(
"Illegal reference to non-materialized tuple: tid=%s", tid));
75 msg.tuple_is_null_pred.addToTuple_ids(tid.asInt());
81 if (!super.equals(o))
return false;
83 return other.tupleIds_.containsAll(
tupleIds_) &&
88 protected String
toSqlImpl() {
return "TupleIsNull()"; }
105 public static List<Expr>
wrapExprs(List<Expr> inputExprs,
110 Preconditions.checkState(tupleDesc.isMaterialized());
113 List<Expr> result = Lists.newArrayListWithCapacity(inputExprs.size());
114 for (
Expr e: inputExprs) {
115 result.add(
wrapExpr(e, tids, analyzer));
127 List<Expr> params = Lists.newArrayList();
132 ifExpr.analyzeNoThrow(analyzer);
143 Preconditions.checkNotNull(expr);
151 List<SlotRef> slotRefs = Lists.newArrayList();
152 expr.collect(SlotRef.class, slotRefs);
153 for (
SlotRef slotRef: slotRefs) {
156 nullSmap.put(slotRef, NullLiteral.create(slotRef.getType()));
161 Expr isNotNullLiteralPred =
163 Preconditions.checkState(isNotNullLiteralPred.isConstant());
165 isNotNullLiteralPred.analyzeNoThrow(analyzer);
166 return FeSupport.EvalPredicate(isNotNullLiteralPred, analyzer.getQueryCtx());
TupleIsNullPredicate(List< TupleId > tupleIds)
Set< TupleId > getTupleIds()
void toThrift(TExprNode msg)
static boolean requiresNullWrapping(Expr expr, Analyzer analyzer)
static List< Expr > wrapExprs(List< Expr > inputExprs, List< TupleId > tids, Analyzer analyzer)
void analyze(Analyzer analyzer)
final Set< TupleId > tupleIds_
TupleIsNullPredicate(TupleIsNullPredicate other)
static Expr wrapExpr(Expr expr, List< TupleId > tids, Analyzer analyzer)