Github user andyyangcn commented on a diff in the pull request: https://github.com/apache/trafodion/pull/1543#discussion_r185411453 --- Diff: core/sql/optimizer/RelExpr.cpp --- @@ -7880,11 +7880,17 @@ NABoolean GroupByAgg::tryToPullUpPredicatesInPreCodeGen( else pulledPredicates += tempPulledPreds; + // just remove pulled up predicates from char. input + ValueIdSet newInputs(getGroupAttr()->getCharacteristicInputs()); + myLocalExpr += selectionPred(); + myLocalExpr -= tempPulledPreds; + myLocalExpr.weedOutUnreferenced(newInputs); --- End diff -- For my test case, in the code you mentioned above, selectionPred() and tempPulledPreds is the same, and myLocalExpr doesn't include the dynamic parameter "?", but the dynamic parameter "?" is included in variable newInputs. So after myLocalExpr.weedOutUnreferenced(newInputs), the dynamic parameter "?" is removed from newINputs. And actually the predicate with dynamic parameter in this case is not pulled up. That cause we have a predicate with an expression "?" in selection predicate, but don't have the expression in character input. To my understand, character inputs are needed by selection predicates. So, for this fix, I recompute the character input and just remove the expressions which are included in pulled up predicates.
---