SQL bug on OVER()

SELECT * FROM (SELECT “NAME”, ROW_NUMBER() OVER( ORDER BY “NAME” DESC ) AS RowId FROM o.POC.TT WHERE 1=1 )AS B WHERE RowId BETWEEN 1 AND 10

we got the following exception.

SQL Error: PLAN ERROR: index (1) must be less than size (1)

SQL Query SELECT * FROM (SELECT “NAME”, ROW_NUMBER() OVER( ORDER BY “NAME” DESC ) AS RowId FROM o.POC.TT WHERE 1=1 )AS B WHERE RowId BETWEEN 1 AND 10

[Error Id: d47ee746-36f2-42ca-81b8-b9a6e75676cb on 192.168.31.234:31010]

(java.lang.IndexOutOfBoundsException) index (1) must be less than size (1)
com.google.common.base.Preconditions.checkElementIndex():1177
com.google.common.base.Preconditions.checkElementIndex():1159
com.google.common.collect.SingletonImmutableList.get():41
org.apache.calcite.util.Pair$6.get():347
com.dremio.exec.store.jdbc.rules.UnpushableTypeVisitor$UnpushableRelVisitor.visit():184
org.apache.calcite.rel.SingleRel.childrenAccept():72
org.apache.calcite.rel.RelVisitor.visit():44
com.dremio.exec.store.jdbc.rules.UnpushableTypeVisitor$UnpushableRelVisitor.visit():187
org.apache.calcite.rel.SingleRel.childrenAccept():72
org.apache.calcite.rel.RelVisitor.visit():44
com.dremio.exec.store.jdbc.rules.UnpushableTypeVisitor$UnpushableRelVisitor.visit():187
org.apache.calcite.rel.SingleRel.childrenAccept():72
org.apache.calcite.rel.RelVisitor.visit():44
com.dremio.exec.store.jdbc.rules.UnpushableTypeVisitor$UnpushableRelVisitor.visit():187
org.apache.calcite.rel.RelVisitor.go():61
com.dremio.exec.store.jdbc.rules.UnpushableTypeVisitor.visitInputRef():73
com.dremio.exec.store.jdbc.rules.UnpushableTypeVisitor.visitInputRef():25
org.apache.calcite.rex.RexInputRef.accept():112

bfb84468-9dca-4375-b28e-db420340bbc9.zip (5.0 KB)

Hello fengliu77,

This seems related to JDBC rules. Can you please create reflection on source tables and try the query again?

Thanks,
Rakesh

Hi, we’ve filed an internal ticket to fix this planning issue.