substrait-io / substrait-java

Apache License 2.0
75 stars 72 forks source link

[ISTHMUS] ClassCastException when converting ORDER BY clause which isn't a column reference #192

Open patientstreetlight opened 11 months ago

patientstreetlight commented 11 months ago

The substrait for a SQL query like:

SELECT c FROM t ORDER BY c + 1

is currently failing to convert to calcite with a ClassCastException, since it doesn't expect the ORDER BY clause to be arbitrarily complex expressions, only RexSlots.

java.lang.ClassCastException: class org.apache.calcite.rex.RexLiteral cannot be cast to class org.apache.calcite.rex.RexSlot (org.apache.calcite.rex.RexLiteral and org.apache.calcite.rex.RexSlot are in unnamed module of loader 'app')
    at io.substrait.isthmus.SubstraitRelNodeConverter.toRelFieldCollation(SubstraitRelNodeConverter.java:347)
    at io.substrait.isthmus.SubstraitRelNodeConverter.lambda$visit$7(SubstraitRelNodeConverter.java:318)

Full substrait file: class-cast-exception.json