-
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
Deprecate PhysicalSortRequirement::from_sort_exprs
and PhysicalSortRequirement::to_sort_exprs
#13222
Conversation
…tRequirement::to_sort_exprs`
50ded20
to
79278f8
Compare
vec![Some(PhysicalSortRequirement::from_sort_exprs( | ||
self.expr.iter(), | ||
))] | ||
vec![Some(LexRequirement::from(self.expr.clone()))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a pretty good example of the potential improvement -- it is now clear this function is returning a LexRequirement
and that it clones the underlying LexOrdering
structure
This was still happening on main but the conversion was hidden
@@ -243,8 +240,7 @@ fn pushdown_requirement_to_children( | |||
smj.schema().fields.len() - smj.right().schema().fields.len(); | |||
let new_right_required = | |||
shift_right_required(parent_required, right_offset)?; | |||
let new_right_required_expr = | |||
PhysicalSortRequirement::to_sort_exprs(new_right_required); | |||
let new_right_required_expr = LexOrdering::from(new_right_required); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this structure makes it much clearer what is going on
@@ -221,7 +221,7 @@ fn replace_with_partial_sort( | |||
// here we're trying to find the common prefix for sorted columns that is required for the | |||
// sort and already satisfied by the given ordering | |||
let child_eq_properties = child.equivalence_properties(); | |||
let sort_req = PhysicalSortRequirement::from_sort_exprs(sort_plan.expr()); | |||
let sort_req = LexRequirement::from(sort_plan.expr().clone()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, there is no more cloning going on than previously, just now the clone is explicit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, the code is clearly improving. Thank you @alamb.
Thank you for the review @berkaysynnada |
Which issue does this PR close?
Part of #12591
Rationale for this change
Before
LexOrdering
andLexRequirement
were actual structs (thanks to @ngli-me and @berkaysynnada on #13146!!!), we couldn't put the conversion betweenLexOrdering
andLexRequirement
on to the actual structures and thus the conversion is done via free functions onPhysicalSortRequirements
This is confusing for several reasons:
From
conversion they aren't there)This structure bothered me for a long time, so it is time to scratch an itch now that @ngli-me started the ball rolling
What changes are included in this PR?
PhysicalSortRequirement::from_sort_exprs
andPhysicalSortRequirement::to_sort_exprs
LexOrdering::from_lex_requirement
andLexOrdering::from_lex_ordering
andFrom
implsAre these changes tested?
By existint CI
Are there any user-facing changes?
SOme methods are deprecated with hints about what to use instead