[ 
https://issues.apache.org/jira/browse/CALCITE-987?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15038219#comment-15038219
 ] 

Mike Hinchey edited comment on CALCITE-987 at 12/3/15 6:40 PM:
---------------------------------------------------------------

I moved my comment to CALCITE-1005.


was (Author: mikehinchey):
After commit 24b0747, I get an error from a test in my own project, but the 
test is all copied from calcite.

The query is this:

with
t1(x) as (select * from  (values 1,2, case when 1 = 1 then null else 3 end)),
t2(x) as (select * from  (values 1,case when 1 = 1 then null else 3 end))
select *
from t1
where t1.x not in (select t2.x from t2);

Which I took from core/src/test/resources/sql/subquery.oq, which I’m running 
with the CsvSchemaFactory and TRANSLATABLE.

Abbreviated stacktrace (most of it is reflection noise):

        ...
        at 
org.apache.calcite.rel.metadata.RelMetadataQuery.getRowCount(RelMetadataQuery.java:86)
        at org.apache.calcite.plan.hep.HepPlanner.dumpGraph(HepPlanner.java:958)
        at 
org.apache.calcite.plan.hep.HepPlanner.applyTransformationResults(HepPlanner.java:723)
        at org.apache.calcite.plan.hep.HepPlanner.applyRule(HepPlanner.java:518)
        at 
org.apache.calcite.plan.hep.HepPlanner.applyRules(HepPlanner.java:392)
        at 
org.apache.calcite.plan.hep.HepPlanner.executeInstruction(HepPlanner.java:255)
        at 
org.apache.calcite.plan.hep.HepInstruction$RuleInstance.execute(HepInstruction.java:125)
        at 
org.apache.calcite.plan.hep.HepPlanner.executeProgram(HepPlanner.java:207)
        at 
org.apache.calcite.plan.hep.HepPlanner.findBestExp(HepPlanner.java:194)
        ... more
        at 
org.apache.calcite.rel.metadata.RelMetadataQuery.getRowCount(RelMetadataQuery.java:86)
        at 
org.apache.calcite.rel.core.Filter.estimateFilteredRows(Filter.java:156)
        at 
org.apache.calcite.rel.core.Filter.estimateFilteredRows(Filter.java:150)
        at org.apache.calcite.rel.core.Calc.getRows(Calc.java:135)
        at 
org.apache.calcite.rel.metadata.RelMdRowCount.getRowCount(RelMdRowCount.java:144)
        ... 50 more
        at 
org.apache.calcite.rel.metadata.RelMetadataQuery.getMaxRowCount(RelMetadataQuery.java:101)
        at 
org.apache.calcite.rel.metadata.RelMdUtil.getJoinRowCount(RelMdUtil.java:705)
        at org.apache.calcite.rel.core.Join.getRows(Join.java:175)
        at 
org.apache.calcite.rel.metadata.RelMdRowCount.getRowCount(RelMdRowCount.java:144)
        ... 90 more
        at 
org.apache.calcite.rel.metadata.RelMetadataQuery.getMaxRowCount(RelMetadataQuery.java:101)
        at 
org.apache.calcite.rel.metadata.RelMdMaxRowCount.getMaxRowCount(RelMdMaxRowCount.java:108)
        ... 105 more
Caused by: java.lang.NullPointerException
        at 
org.apache.calcite.rel.metadata.RelMdMaxRowCount.getMaxRowCount(RelMdMaxRowCount.java:102)
        ... 125 more


> Push limit 0 will result in an infinite loop
> --------------------------------------------
>
>                 Key: CALCITE-987
>                 URL: https://issues.apache.org/jira/browse/CALCITE-987
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.5.0
>            Reporter: Pengcheng Xiong
>            Assignee: Pengcheng Xiong
>             Fix For: 1.6.0
>
>         Attachments: CALCITE-987.01.patch, CALCITE-987.02.patch, 
> CALCITE-987.03.patch, CALCITE-987.04.patch
>
>
> We use "checkInputForCollationAndLimit" in RelMdUtil.java to check the input 
> #rows. However, it calls RelMetadataQuery.getRowCount which will validate the 
> #rows. The validation will change #row=0 to #row=1. This will result in an 
> infinite loop to push limit. The affected rules include 
> SortUnionTransposeRule and any Sort***TransposeRules that call  
> checkInputForCollationAndLimit.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to