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

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.21.0
    • 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

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jinxing6042@126.com Jin Xing
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              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