Details
-
Bug
-
Status: Resolved
-
Blocker
-
Resolution: Fixed
-
Impala 2.8.0, Impala 2.9.0, Impala 2.10.0
-
ghx-label-5
Description
@Override public String toSqlImpl() { if (label_ != null) return label_; // Merge agg fns should have an explicit label. Preconditions.checkState(!isMergeAggFn()); StringBuilder sb = new StringBuilder(); sb.append(fnName_).append("("); if (params_.isStar()) sb.append("*"); if (params_.isDistinct()) sb.append("DISTINCT "); sb.append(Joiner.on(", ").join(childrenToSql())).append(")"); return sb.toString(); } protected FunctionCallExpr(FunctionCallExpr other) { super(other); fnName_ = other.fnName_; isAnalyticFnCall_ = other.isAnalyticFnCall_; isInternalFnCall_ = other.isInternalFnCall_; mergeAggInputFn_ = other.mergeAggInputFn_ == null ? null : (FunctionCallExpr)other.mergeAggInputFn_.clone(); // Clone the params in a way that keeps the children_ and the params.exprs() // in sync. The children have already been cloned in the super c'tor. if (other.params_.isStar()) { Preconditions.checkState(children_.isEmpty()); params_ = FunctionParams.createStarParam(); } else { params_ = new FunctionParams(other.params_.isDistinct(), children_); <------- other.params_.isIgnoreNulls() is ignored. } label_ = other.label_; }
We don't include the "IGNORE NULLS" clause if present, causing it to break the cases which rely on it, for example an InlineViewRef. A sample repro.
[localhost:21000] > create foo(a int, b int); [localhost:21000] > create view test_view as select * from (select last_value(b IGNORE NULLS) OVER (PARTITION BY a order by b) from test) x; [localhost:21000] > show create view test_view; Query: show create view test_view +------------------------------------------------------------------------------------------------+ | result | +------------------------------------------------------------------------------------------------+ | CREATE VIEW incrstat.test_view AS | | SELECT * FROM (SELECT last_value(b) OVER (PARTITION BY a ORDER BY b ASC) FROM incrstat.test) x | +------------------------------------------------------------------------------------------------+