[ 
https://issues.apache.org/jira/browse/CALCITE-3211?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ruben Quesada Lopez resolved CALCITE-3211.
------------------------------------------
    Resolution: Fixed

Fixed in 
https://github.com/apache/calcite/commit/d98856bf1a5f5c151d004b769e14bdd368a67234
Thanks for the PR [~jinxing6...@126.com]!

> List of MutableRel may fail to be identified by SubstitutionVisitor during 
> matching
> -----------------------------------------------------------------------------------
>
>                 Key: CALCITE-3211
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3211
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: jin xing
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.21.0
>
>          Time Spent: 1h
>  Remaining Estimate: 0h
>
> Current implementation of {{MutableRels::toMutables}} is as below:
> {code:java}
>   private static List<MutableRel> toMutables(List<RelNode> nodes) {
>     return Lists.transform(nodes, MutableRels::toMutable);
>   }
> {code}
> Thus every time we {{get}} from the result list, a new {{MutableRel}} will be 
> created:
> {code:java}
>   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));
>     }
> ......
> {code}
> 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



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)

Reply via email to