substrait-io / substrait-java

Apache License 2.0
72 stars 70 forks source link

[WIP] fix(isthmus): fix rel converter for sort when slot is wrapped #235

Open bvolpato opened 4 months ago

bvolpato commented 4 months ago

Attempt to fix https://github.com/substrait-io/substrait-java/issues/192

It works for cases in which RexSlot is wrapped (as we visit + recurse over all the expressions), but it doesn't work yet for literals. Unclear what we should do, I'll do some more digging.

vbarua commented 4 months ago

The RelCollation class, which is used to capture the ordering in Calcite Sort relations, only appears to support column inputs (and not arbitrary expressions).

This is actually fairly similar to the issue of complex expressions in Aggregate group keys. Calcite only allows field references to be used as grouping keys, but Substrait is more permissive. The approach that was taken for that was to add a Project before the Aggregate to execute the expressions and provide field references for use in the Aggregate. That could potentially work here.

See https://github.com/substrait-io/substrait-java/pull/214