Eyal Segal created CALCITE-2057:
-----------------------------------

             Summary: StackOverflowError when running a JDBC query
                 Key: CALCITE-2057
                 URL: https://issues.apache.org/jira/browse/CALCITE-2057
             Project: Calcite
          Issue Type: Bug
          Components: build
    Affects Versions: 1.14.0
            Reporter: Eyal Segal
            Assignee: Julian Hyde
            Priority: Minor


I've ran the following code:

{code:java}
try (ResultSet rs = statement.executeQuery(
                "SELECT p.name, r.views " +
                    "FROM reports.a as r " +
                    "INNER JOIN main.b as p ON p.id = CAST(r.p_id AS INT) AND 
p.id = 196 " +
                    "WHERE p.id = 196 " +
                    "AND r.p_id = 196 " +
                    "AND r.data_timestamp = TIMESTAMP '2017-11-14 00:00:00'  " 
)) {
{code}

And I'm getting the following StackOverflowError:
{code:java}
Exception in thread "main" java.lang.StackOverflowError
        at 
com.google.common.collect.ImmutableList.indexOf(ImmutableList.java:339)
        at GeneratedMetadataHandler_RowCount.getRowCount_$(Unknown Source)
        at GeneratedMetadataHandler_RowCount.getRowCount(Unknown Source)
        at 
org.apache.calcite.rel.metadata.RelMetadataQuery.getRowCount(RelMetadataQuery.java:235)
        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:235)
        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:235)
        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:235)
        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)
...
{code}

It's solved by removing "AND p.id = 196" from the INNER JOIN, but it's still 
worth fixing.




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to