Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-2657

In RexShuttle, use "RexCall.clone()" rather than "new RexCall()" to copy calls

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.17.0
    • 1.18.0
    • core
    • None

    Description

      RexShuttle uses constructor of RexCall to generate a new RexCall, as followings:

        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;
          }
        }
      

      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:

        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;
          }
        }
      

      Attachments

        Issue Links

          Activity

            People

              julianhyde Julian Hyde
              Chunwei Lei Chunwei Lei
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: