Github user sureshsubbiah commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/291#discussion_r51330090
  
    --- Diff: core/sql/optimizer/BindRelExpr.cpp ---
    @@ -10272,8 +10273,14 @@ RelExpr* Insert::xformUpsertToMerge(BindWA *bindWA)
       ((Join*)re)->doNotTransformToTSJ();
       ((Join*)re)->setTSJForMerge(TRUE);       
       ((Join*)re)->setTSJForMergeWithInsert(TRUE);
    +  ((Join*)re)->setTSJForMergeUpsert(TRUE);
       ((Join*)re)->setTSJForWrite(TRUE);
    -  if (bindWA->hasDynamicRowsetsInQuery())
    +
    +  // if Inputs of current insert are empty (i.e. we have no params/rowsets)
    +  // then there will be no pull up of inputs during transform and the join 
will
    +  // not see the inputs of the mergeUpdate due to intermediate nodes. So
    +  // add inputs directly to join and use elimination to remove extra inputs
    +  if (NOT getGroupAttr()->getCharacteristicInputs().isEmpty())
    --- End diff --
    
    In RelExpr::recomputeOuterReferences and most other implementations of 
recomputeOuterReferences char inputs are pulled up from the child to the 
parent, but this pullup code is executed only if the parent has inputs to start 
with. If parent has no inputs to start with, then most recomputeOuterRefences 
implementations do little. I was seeing that if inputs were added to "mu" and 
the UPSERT had no params (i.e. when all inputs mentioned in this method are 
internal ones, those that are required because the "mu" is now on the right 
side of a tuple_flow, not those that will come in from the cli through the 
input_desc) they were not getting pulled up, and inlining nodes were not 
getting the values they needed.
    I tried for a long to time to avoid adding any inputs explicitly to both 
"mu" and "re" and letting inputs be managed by existing code in 
Transform/Normalize. I could not get that to work as they started failing an 
assert in optimizer. Now I have adopted the idea of doing the minimum 
necessary. Add only to "mu" as far as possible, however in the no input_desc 
char. inputs I did have to add it to "re".


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to