[ https://issues.apache.org/jira/browse/CALCITE-1862?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16396908#comment-16396908 ]
zhen wang commented on CALCITE-1862: ------------------------------------ {code} before transform: EnumerableFilter(condition=[IS NULL(null)]) EnumerableProject(subset=[rel#44:Subset#5.ENUMERABLE.[]], EMPNO=[$0]) EnumerableFilter(subset=[rel#142:Subset#7.ENUMERABLE.[]], condition=[AND(IS NULL(null), IS NULL(null))]) EnumerableTableScan(subset=[rel#24:Subset#0.ENUMERABLE.[0]], table=[[scott, EMP]]) after transform: EnumerableProject(EMPNO=[$0]) EnumerableFilter(condition=[IS NULL(null)]) EnumerableFilter(subset=[rel#240:Subset#16.ENUMERABLE.[]], condition=[IS NULL(null)]) EnumerableFilter(subset=[rel#234:Subset#15.ENUMERABLE.[]], condition=[IS NULL(null)]) EnumerableFilter(subset=[rel#88:Subset#6.ENUMERABLE.[]], condition=[IS NULL(null)]) EnumerableTableScan(subset=[rel#24:Subset#0.ENUMERABLE.[0]], table=[[scott, EMP]]) {code} This occurred when the `Project` relation is a RelSubset, the match process didn't choose the best of the Project equivalent RelSubset, but instead chose not optimized one. causing the rule to be fired again and again, causing stack overflow. > StackOverflowException in RelMdUtil.estimateFilteredRows > -------------------------------------------------------- > > Key: CALCITE-1862 > URL: https://issues.apache.org/jira/browse/CALCITE-1862 > Project: Calcite > Issue Type: Bug > Reporter: Julian Hyde > Assignee: Julian Hyde > Priority: Major > > The query > {code}select * > from ( > select * > from ( > select cast(null as integer) as d > from "scott".emp) > where d is null and d is null) > where d is null;{code} > gives > {noformat} > java.lang.StackOverflowError > > at > > org.apache.calcite.adapter.clone.ArrayTable.getStatistic(ArrayTable.java:76) > > at > > org.apache.calcite.prepare.RelOptTableImpl.getRowCount(RelOptTableImpl.java:224) > > at > > org.apache.calcite.rel.core.TableScan.estimateRowCount(TableScan.java:75) > > at > > org.apache.calcite.rel.metadata.RelMdRowCount.getRowCount(RelMdRowCount.java:206) > > at GeneratedMetadataHandler_RowCount.getRowCount_$(Unknown Source) > > at GeneratedMetadataHandler_RowCount.getRowCount(Unknown Source) > > at > > org.apache.calcite.rel.metadata.RelMetadataQuery.getRowCount(RelMetadataQuery.java:236) > > at > > org.apache.calcite.rel.metadata.RelMdRowCount.getRowCount(RelMdRowCount.java:71) > > at GeneratedMetadataHandler_RowCount.getRowCount_$(Unknown Source) > > at GeneratedMetadataHandler_RowCount.getRowCount(Unknown Source) > > at > > org.apache.calcite.rel.metadata.RelMetadataQuery.getRowCount(RelMetadataQuery.java:236) > > at > > org.apache.calcite.rel.metadata.RelMdUtil.estimateFilteredRows(RelMdUtil.java:718) > > at > > org.apache.calcite.rel.metadata.RelMdRowCount.getRowCount(RelMdRowCount.java:123) > > at GeneratedMetadataHandler_RowCount.getRowCount_$(Unknown Source) > > at GeneratedMetadataHandler_RowCount.getRowCount(Unknown Source) > > at > > org.apache.calcite.rel.metadata.RelMetadataQuery.getRowCount(RelMetadataQuery.java:236) > > at > > org.apache.calcite.rel.metadata.RelMdRowCount.getRowCount(RelMdRowCount.java:71) > > at GeneratedMetadataHandler_RowCount.getRowCount_$(Unknown Source) > > at GeneratedMetadataHandler_RowCount.getRowCount(Unknown Source) > > at > > org.apache.calcite.rel.metadata.RelMetadataQuery.getRowCount(RelMetadataQuery.java:236) > > at > > org.apache.calcite.rel.metadata.RelMdUtil.estimateFilteredRows(RelMdUtil.java:718){noformat} > For a test case, add the query to misc.iq and run QuidemTest. -- This message was sent by Atlassian JIRA (v7.6.3#76005)