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

List of MutableRel may fail to be identified by SubstitutionVisitor during matching

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.21.0
    • Component/s: None

      Description

      Current implementation of MutableRels::toMutables is as below:

        private static List<MutableRel> toMutables(List<RelNode> nodes) {
          return Lists.transform(nodes, MutableRels::toMutable);
        }
      

      Thus every time we get from the result list, a new MutableRel will be created:

        private static class TransformingRandomAccessList<F, T> extends AbstractList<T>
            implements RandomAccess, Serializable {
          final List<F> fromList;
          final Function<? super F, ? extends T> function;
      
          TransformingRandomAccessList(List<F> fromList, Function<? super F, ? extends T> function) {
            this.fromList = checkNotNull(fromList);
            this.function = checkNotNull(function);
          }
      
          @Override
          public T get(int index) {
            return function.apply(fromList.get(index));
          }
      ......
      

      As a result, https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/plan/SubstitutionVisitor.java#L514 SubstitutionVisitor will fail to check whether a node has been met/matched before

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              jinxing6042@126.com Jin Xing

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 1h 10m
                1h 10m

                  Issue deployment