-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EnforceSorting
resorts the inout of UnionExec unnecessarily
#4943
Comments
cc @mustafasrepo and @mingmwang who I think have expertise in this area |
I think the reason is that UnionExec doesn't implement fn maintains_input_order(&self) -> bool {
let first_input_ordering = self.inputs[0].output_ordering();
// If the Union is not partition aware and all the input ordering spec strictly equal with the first_input_ordering
// `UnionExec` maintains input order
//
// It might be too strict here in the case that the input ordering are compatible but not exactly the same.
// For example one input ordering has the ordering spec SortExpr('a','b','c') and the other has the ordering
// spec SortExpr('a'), It is safe to derive the out ordering with the spec SortExpr('a').
!self.partition_aware
&& first_input_ordering.is_some()
&& self
.inputs
.iter()
.map(|plan| plan.output_ordering())
.all(|ordering| {
ordering.is_some()
&& sort_expr_list_eq_strict_order(
ordering.unwrap(),
first_input_ordering.unwrap(),
)
})
} |
Thank you @mustafasrepo -- I will attempt to write a reproducer for this and try our your proposed fix |
proposed PR: #4946 |
Nice !! |
Yes I am quite pleased with how sophisticated the sorting based optimizations are becoming |
Describe the bug
Given the following input plan (I see this by enabling trace logging via
RUST_LOG=trace
:Here is the input to enforce sorting:
And here is the output from
EnforceSorting
, where it has moved the SortExec up to the top of the union:To Reproduce
I have a reproducer from IOx -- see https://github.com/influxdata/influxdb_iox/pull/6528#discussion_r1070632410
Expected behavior
I expect the
SortExec
to be left where it is (at the input to theAdditional context
I found this in the context of upgrading DataFusion in IOx: https://github.com/influxdata/influxdb_iox/pull/6528
The text was updated successfully, but these errors were encountered: