Github user Guhaiyan commented on a diff in the pull request:
https://github.com/apache/trafodion/pull/1581#discussion_r191620727
--- Diff: core/sql/optimizer/RelExpr.cpp ---
@@ -13341,6 +13345,33 @@ void GenericUpdate::pushdownCoveredExpr(const
ValueIdSet &outputExpr,
newExternalInputs,
predicatesOnParent,
&localExprs);
+
+ if (avoidHalloween() && child(0) && child(0)->getGroupAttr())
+ {
+ ValueIdSet cur_output =
child(0)->getGroupAttr()->getCharacteristicOutputs();
+ if (cur_output.isEmpty())
+ {
+ ValueId exprId;
+ ValueId atLeastOne;
+
+ for (exprId = original_output.init();
+ original_output.next(exprId);
+ original_output.advance(exprId))
+ {
+ atLeastOne = exprId;
+ if
(!(exprId.getItemExpr()->doesExprEvaluateToConstant(FALSE, TRUE)))
+ {
+
child(0)->getGroupAttr()->addCharacteristicOutputs(exprId);
+ break;
+ }
+ }
+ cur_output = child(0)->getGroupAttr()->getCharacteristicOutputs();
+ if (cur_output.isEmpty())
--- End diff --
If cur_output is empty, it means that in RelExpr::pushdownCoveredExpr,
child(0).getPtr()->getGroupAttr()->computeCharacteristicIO set requiredOutputs_
to be empty, that is there is no output for Scan. So I go through the
original_output and pick a ValueId which does NOT EvaluateToConst and add it
to the characteristic output of Scan. Since the original_output is not empty,
so we can always find one ValueId to be added to Scan's output . After "for"
loop, atLeastOne is the last ValueId in the original_output, not its initial
value(0), so I do not think the "if" would cause adding an null ValueId in
Scan's output.
---