Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-18363

Calcite engine. Limit with offset can return negative estimated rows count

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 2.15
    • None
    • SQL Calcite: Fixed row count estimate by limit with offset
    • Release Notes Required

    Description

      Limit with offset can return negative estimated rows count, this will throw an assertion error if limit is used as input of another relational operator.

      For example:

      CREATE TABLE t(id INT);
      INSERT INTO t VALUES (1), (2), (3);
      SELECT (SELECT id FROM t ORDER BY id LIMIT 1 OFFSET 10); 

      Throws:

      java.lang.AssertionError: null
          at org.apache.calcite.rel.metadata.RelMdUtil.isNonNegative(RelMdUtil.java:988) ~[calcite-core-1.32.0.jar:1.32.0]
          at org.apache.calcite.rel.metadata.RelMdUtil.validateResult(RelMdUtil.java:977) ~[calcite-core-1.32.0.jar:1.32.0]
          at org.apache.calcite.rel.metadata.RelMetadataQuery.getRowCount(RelMetadataQuery.java:259) ~[calcite-core-1.32.0.jar:1.32.0]
          at org.apache.calcite.rel.metadata.RelMdRowCount.getRowCount(RelMdRowCount.java:73) ~[calcite-core-1.32.0.jar:1.32.0]
          at org.apache.calcite.rel.metadata.janino.GeneratedMetadata_RowCountHandler.getRowCount_$(Unknown Source) ~[?:?]
          at org.apache.calcite.rel.metadata.janino.GeneratedMetadata_RowCountHandler.getRowCount(Unknown Source) ~[?:?]
          at org.apache.calcite.rel.metadata.RelMetadataQuery.getRowCount(RelMetadataQuery.java:258) ~[calcite-core-1.32.0.jar:1.32.0]
          at org.apache.ignite.internal.processors.query.calcite.rel.IgniteAggregate.computeSelfCostHash(IgniteAggregate.java:94) ~[classes/:?]

       

      Attachments

        Issue Links

          Activity

            People

              alex_pl Aleksey Plekhanov
              alex_pl Aleksey Plekhanov
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m