Open bvolpato opened 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.
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.