[
https://issues.apache.org/jira/browse/TRAFODION-2127?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15609963#comment-15609963
]
ASF GitHub Bot commented on TRAFODION-2127:
-------------------------------------------
Github user DaveBirdsall commented on a diff in the pull request:
https://github.com/apache/incubator-trafodion/pull/772#discussion_r85229943
--- Diff: core/sql/generator/GenPreCode.cpp ---
@@ -6058,6 +6059,98 @@ RelExpr * MapValueIds::preCodeGen(Generator *
generator,
getGroupAttr()->addCharacteristicInputs(pulledNewInputs);
+ if (cseRef_)
+ {
+ // -------------------------------------------------------------
+ // This MapValueIds represents a common subexpression.
+ //
+ // We need to take some actions here to help with VEG rewrite,
+ // since we eliminated some nodes from the tree, while the
+ // VEGies still contain all equated values, including those that
+ // got eliminated. Furthermore, the one tree that was chosen for
+ // materialization got moved and we need to make sure that the
+ // place where we scan the temp table produces the same ValueIds
+ // that were marked as "Bridge Values" when we processed the
+ // insert into temp statement.
+ // -------------------------------------------------------------
+
+ ValueIdSet cseVEGPreds;
+ const ValueIdList &vegCols(cseRef_->getColumnList());
+ ValueIdSet nonVegCols(cseRef_->getNonVEGColumns());
+ NABoolean isAnalyzingConsumer =
+ (CmpCommon::statement()->getCSEInfo(cseRef_->getName())->
+ getIdOfAnalyzingConsumer() == cseRef_->getId());
+
+ // find all the VEG predicates of the original columns that this
+ // common subexpression represents...
+ for (CollIndex v=0; v<vegCols.entries(); v++)
+ if (vegCols[v].getItemExpr()->getOperatorType() ==
ITM_VEG_REFERENCE)
+ {
+ // look at one particular VEG that is produced by this
+ // query tree
+ VEG *veg =
+ static_cast<VEGReference
*>(vegCols[v].getItemExpr())->getVEG();
+
+ if (isAnalyzingConsumer && veg->getBridgeValues().entries() >
0)
+ {
+ // If we are looking at the analyzing consumer, then
+ // its child tree "C" got transformed into an
+ // "insert overwrite table "temp" select * from "C".
+
+ // This insert into temp statement chose some VEG
+ // member as the "bridge value". Find this bridge
+ // value and choose it to represent the VEG here.
+ const ValueIdSet &vegMembers(veg->getAllValues());
+
+ // collect all VEG members produced and subtract them
+ // from the values to be used for VEG rewrite
+ ValueIdSet subtractions(cseRef_->getNonVEGColumns());
+ // then add back only the bridge value
+ ValueIdSet additions;
+ ValueId baseCol;
+
+ // get the VEG members produced by child C
+ subtractions.intersectSet(vegMembers);
+
+ // augment the base columns with their index columns,
+ // the bridge value is likely an index column
+ for (ValueId v=subtractions.init();
+ subtractions.next(v);
+ subtractions.advance(v))
+ if (v.getItemExpr()->getOperatorType() == ITM_BASECOLUMN)
+ {
+ subtractions +=
+ static_cast<BaseColumn
*>(v.getItemExpr())->getEIC();
+ baseCol = v;
--- End diff --
baseCol doesn't seem to be used anywhere?
> enhance Trafodion implementation of WITH clause
> -----------------------------------------------
>
> Key: TRAFODION-2127
> URL: https://issues.apache.org/jira/browse/TRAFODION-2127
> Project: Apache Trafodion
> Issue Type: Improvement
> Reporter: liu ming
> Assignee: Hans Zeller
>
> TRAFODION-1673 described some details about how to support WITH clause in
> Trafodion.
> As initial implementation, we use a simple pure-parser method.
> That way, Trafodion can support WITH clause functionally, but not good from
> performance point of view,
> also need to enhance the parser to be more strict in syntax.
> This JIRA is a follow up JIRA, to track following effort to support Trafodion
> WITH clause.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)