You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "jin xing (JIRA)" <ji...@apache.org> on 2019/07/26 05:29:00 UTC
[jira] [Comment Edited] (CALCITE-3211) MutableRel returned from
MutableRels::toMutables may lose reference to parent
[ https://issues.apache.org/jira/browse/CALCITE-3211?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16893336#comment-16893336 ]
jin xing edited comment on CALCITE-3211 at 7/26/19 5:28 AM:
------------------------------------------------------------
[~julianhyde]
Thanks a lot for reply ~
I updated the description of the issue. I'm working on a rule for materialization matching of {{Union}} https://issues.apache.org/jira/browse/CALCITE-3214
When I run below test, {{SubstitutionVisitor}} suffers into an infinite loop
{code:java}
@Test public void testDEV() {
String sql0 = "select * from \"emps\" where \"empid\" < 300";
String sql1 = "select * from \"emps\" where \"empid\" > 200";
checkMaterialize(sql0 + " union all " + sql1, sql1 + " union all " + sql0);
}
{code}
My previous understanding is wrong. I think the problem is from here:
{code:java}
Lists.transform(nodes, MutableRels::toMutable);
{code}
When we {{get}} from the result list, a new {{MutableRel}} is created.
was (Author: jinxing6042@126.com):
[~julianhyde]
Thanks a lot for reply ~
I updated the description of the issue. I'm working on a rule for materialization matching of {{Union}} https://issues.apache.org/jira/browse/CALCITE-3214
When I run below test, {{SubstitutionVisitor}} suffers into a infinite loop
{code:java}
@Test public void testDEV() {
String sql0 = "select * from \"emps\" where \"empid\" < 300";
String sql1 = "select * from \"emps\" where \"empid\" > 200";
checkMaterialize(sql0 + " union all " + sql1, sql1 + " union all " + sql0);
}
{code}
My previous understanding is wrong. I think the problem is from here:
{code:java}
Lists.transform(nodes, MutableRels::toMutable);
{code}
When we {{get}} from the result list, a new {{MutableRel}} is created.
> MutableRel returned from MutableRels::toMutables may lose reference to parent
> -----------------------------------------------------------------------------
>
> 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
> Time Spent: 10m
> 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)