wiedld commented on code in PR #12414:
URL: https://github.com/apache/datafusion/pull/12414#discussion_r1752924134
##########
datafusion/sqllogictest/test_files/order.slt:
##########
@@ -1220,10 +1220,10 @@ physical_plan
01)ProjectionExec: expr=[b@0 as b, c@1 as c, a@2 as a, a0@3 as a0]
02)--SortPreservingMergeExec: [d@4 ASC NULLS LAST,c@1 ASC NULLS LAST,a@2 ASC
NULLS LAST,a0@3 ASC NULLS LAST,b@0 ASC NULLS LAST], fetch=2
03)----UnionExec
-04)------SortExec: TopK(fetch=2), expr=[d@4 ASC NULLS LAST,c@1 ASC NULLS
LAST,a@2 ASC NULLS LAST,b@0 ASC NULLS LAST], preserve_partitioning=[false]
+04)------SortExec: TopK(fetch=2), expr=[d@4 ASC NULLS LAST,c@1 ASC NULLS
LAST,b@0 ASC NULLS LAST], preserve_partitioning=[false]
05)--------ProjectionExec: expr=[b@1 as b, c@2 as c, a@0 as a, NULL as a0, d@3
as d]
06)----------CsvExec: file_groups={1 group:
[[WORKSPACE_ROOT/datafusion/core/tests/data/window_2.csv]]}, projection=[a, b,
c, d], output_ordering=[c@2 ASC NULLS LAST], has_header=true
-07)------SortExec: TopK(fetch=2), expr=[d@4 ASC NULLS LAST,c@1 ASC NULLS
LAST,a0@3 ASC NULLS LAST,b@0 ASC NULLS LAST], preserve_partitioning=[false]
Review Comment:
> you can actually add constants, as there is a flag, "across_partitions,"
that indicates whether the value is constant across all partitions or only in
its corresponding partition
Made the change per suggestion (demonstration only, not final commits), and
I'm not sure this is the proper fix. If I add the constants on the union's
equivalence properties, then there are other ramifications because:
* the
[EquivalenceProperties::output_ordering](https://github.com/apache/datafusion/blob/3ece7a736193a87941a00eb35f3001df282fd075/datafusion/physical-expr/src/equivalence/properties.rs#L142)
remove the constants
* the
[EquivalenceProperties::normalized_oeq_class](https://github.com/apache/datafusion/blob/3ece7a736193a87941a00eb35f3001df282fd075/datafusion/physical-expr/src/equivalence/properties.rs#L154)
remove the constants
In the example above, the sort orders `[a@2 ASC NULLS LAST]` and `[a0@3 ASC
NULLS LAST]` are removed on non-constant projections. The EnforceSorting pass
adds the SortExecs, but the change itself really occurs based upon the
EquivalenceProperties's definition of a (non-constant) sort order.
I started hacking around this in the EnforceSorting, but it feels like the
suggested change (adding to constants) may be actually [changing the
definition](https://github.com/apache/datafusion/pull/12414/commits/0f317a64a748c5f08cb2041a73031c54720f3dae)
of what the constants are?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]