[ 
https://issues.apache.org/jira/browse/CALCITE-2657?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16677891#comment-16677891
 ] 

Julian Hyde commented on CALCITE-2657:
--------------------------------------

Note the comment in RexCall:
{code}
 * <p>It's not often necessary to sub-class this class. The smarts should be in
 * the operator, rather than the call. Any extra information about the call can
 * often be encoded as extra arguments. (These don't need to be hidden, because
 * no one is going to be generating source code from this tree.)</p>
{code}

So, we don't want to encourage sub-classing. Of the sub-classes that do exist, 
two of them - RexOver and RexSubQuery - have specific handler methods in 
RexShuttle. Adding handler methods is not something we would allow for code 
outside of Calcite.

> use RexCall#clone instead of constructor to make a new RexCall in RexShuttle 
> for more scalability
> -------------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-2657
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2657
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.17.0
>            Reporter: Chunwei Lei
>            Assignee: Julian Hyde
>            Priority: Major
>             Fix For: 1.18.0
>
>
> RexShuttle uses constructor of RexCall to generate a new RexCall, as 
> followings:
> {code:java}
>   public RexNode visitCall(final RexCall call) {
>     boolean[] update = {false};
>     List<RexNode> clonedOperands = visitList(call.operands, update);
>     if (update[0]) {
>       // REVIEW jvs 8-Mar-2005:  This doesn't take into account
>       // the fact that a rewrite may have changed the result type.
>       // To do that, we would need to take a RexBuilder and
>       // watch out for special operators like CAST and NEW where
>       // the type is embedded in the original call.
>       return new RexCall(
>           call.getType(),
>           call.getOperator(),
>           clonedOperands);
>     } else {
>       return call;
>     }
>   }
> {code}
> It is more scalability when using RexCall#clone() for those using sub-class 
> of RexCall since function clone can be override by sub-class, as followings:
> {code:java}
>   public RexNode visitCall(final RexCall call) {
>     boolean[] update = {false};
>     List<RexNode> clonedOperands = visitList(call.operands, update);
>     if (update[0]) {
>       // REVIEW jvs 8-Mar-2005:  This doesn't take into account
>       // the fact that a rewrite may have changed the result type.
>       // To do that, we would need to take a RexBuilder and
>       // watch out for special operators like CAST and NEW where
>       // the type is embedded in the original call.
>       return call.clone(call.getType(), clonedOperands);
>     } else {
>       return call;
>     }
>   }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to