Repository: trafodion Updated Branches: refs/heads/master b7384e877 -> 1bc3d1add
[Trafodion 3202] Case when used in the sorting sequence of paging functions. execution error Project: http://git-wip-us.apache.org/repos/asf/trafodion/repo Commit: http://git-wip-us.apache.org/repos/asf/trafodion/commit/de3b7dca Tree: http://git-wip-us.apache.org/repos/asf/trafodion/tree/de3b7dca Diff: http://git-wip-us.apache.org/repos/asf/trafodion/diff/de3b7dca Branch: refs/heads/master Commit: de3b7dca3ded1212987b13b8e2a63cc91688e6d8 Parents: e6e8956 Author: Andy Yang <[email protected]> Authored: Tue Sep 11 16:18:57 2018 +0800 Committer: Andy Yang <[email protected]> Committed: Tue Sep 11 16:18:57 2018 +0800 ---------------------------------------------------------------------- core/sql/optimizer/RelSequence.cpp | 35 +++++++++++++++++++++++++++++++++ core/sql/optimizer/RelSequence.h | 3 +-- 2 files changed, 36 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafodion/blob/de3b7dca/core/sql/optimizer/RelSequence.cpp ---------------------------------------------------------------------- diff --git a/core/sql/optimizer/RelSequence.cpp b/core/sql/optimizer/RelSequence.cpp index f0ce941..b611b94 100644 --- a/core/sql/optimizer/RelSequence.cpp +++ b/core/sql/optimizer/RelSequence.cpp @@ -605,6 +605,41 @@ void RelSequence::rewriteNode(NormWA & normWARef) } // RelSequence::rewriteNode() +RelExpr * RelSequence::normalizeNode(NormWA & normWARef) +{ + RelExpr *result = RelExpr::normalizeNode(normWARef); + + // See RelRoot::normalizeNode(), which has a code segment for a case + // 10-010321-1842 (details of the case are now lost to history). + // Since the RelSequence has an order by expression similar to that + // of the RelRoot, we have to apply an equivalent fix here, so that + // an OVER(ORDER BY x) will work, even if the expression x refers + // to something like a parameter or to current_timestamp. + // For this case we need to + // enforce that Sort operator can sort on this expression by keeping + // parameter ?p in RelRoot child's group requiredInput. + // NOTE. This solution will force the Sort operator to be done + // directly below the RelSequence node. + if (requiredOrder_.entries() > 0) + { + ValueIdSet orderBySet(requiredOrder_), + coveredOrderBySet, + inputsNeededForOrderBy; + + GroupAttributes * childGAPtr = child(0).getPtr()->getGroupAttr(); + + childGAPtr->coverTest(orderBySet, + getGroupAttr()->getCharacteristicInputs(), + coveredOrderBySet, + inputsNeededForOrderBy); + + childGAPtr->addCharacteristicInputs(inputsNeededForOrderBy); + } + + return result; +} + + // RelSequence::pullUpPreds() -------------------------------------------- // is redefined to disallow the pullup of most predicates from the // operator's child. RelSequence can not pull up any predicates from http://git-wip-us.apache.org/repos/asf/trafodion/blob/de3b7dca/core/sql/optimizer/RelSequence.h ---------------------------------------------------------------------- diff --git a/core/sql/optimizer/RelSequence.h b/core/sql/optimizer/RelSequence.h index 189fdbe..7733932 100644 --- a/core/sql/optimizer/RelSequence.h +++ b/core/sql/optimizer/RelSequence.h @@ -122,8 +122,7 @@ public: // predicate pushdown and computing a "minimal" set of // characteristic input and characteristic output values. // - // The default implementation is adequate for RelSequence - // virtual RelExpr * normalizeNode(NormWA & normWARef); + virtual RelExpr * normalizeNode(NormWA & normWARef); // Method to push down predicates from a RelSequence node into the // children
