Skip to content

LexRequirement as a struct, instead of a type - #12583

Merged
alamb merged 4 commits into
apache:mainfrom
ngli-me:feature/struct-lex-requirement
Sep 23, 2024
Merged

LexRequirement as a struct, instead of a type#12583
alamb merged 4 commits into
apache:mainfrom
ngli-me:feature/struct-lex-requirement

Conversation

@ngli-me

@ngli-mengli-me commented Sep 23, 2024

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Closes#12255.

Rationale for this change

What changes are included in this PR?

Converted LexRequirement type into a struct, with the Vec<PhysicalSortRequirement> as the field labeled inner.
Added two functions for convenience, an iter and push function relating to the struct field.
Added implementations for Deref, FromIterator and IntoIterator.

Are these changes tested?

Adjusted the existing tests

Are there any user-facing changes?

The Vec<PhysicalSortRequirement> needs to be wrapped to initialize the struct insance, and some of the usage needs to be adjusted to get the field from the struct.

@github-actionsgithub-actionsBot added physical-expr Changes to the physical-expr crates core Core DataFusion crate proto Related to proto crate labels Sep 23, 2024
@ngli-me
ngli-me marked this pull request as ready for review September 23, 2024 02:01
@ngli-mengli-me changed the title Feature/struct lex requirementLexRequirement as a struct, instead of a typeSep 23, 2024

@berkaysynnadaberkaysynnada left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you @ngli-me

@@ -264,9 +267,55 @@ pub type LexOrdering = Vec<PhysicalSortExpr>;
/// a reference to a lexicographical ordering.
pub type LexOrderingRef<'a> = &'a [PhysicalSortExpr];

@berkaysynnadaberkaysynnadaSep 23, 2024

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we could follow a similar pattern for LexOrderingRef, too.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created a separate issue for this, #12591!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW having a real struct will make printing these structures much easier -- e.g. I had to do some akward workarounds to implement Display or LexOrdering in #12590

…ement was not being converted after the merge.
@ngli-me

Copy link
Copy Markdown
ContributorAuthor

Made some adjustments, since there was a merge conflict :)

@alambalamb added the api change Changes the API exposed to users of the crate label Sep 23, 2024

@alambalamb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it -- thank you @ngli-me and @berkaysynnada

@alamb
alamb merged commit bd8960e into apache:mainSep 23, 2024
@ngli-me
ngli-me deleted the feature/struct-lex-requirement branch September 23, 2024 21:37
bgjackma pushed a commit to bgjackma/datafusion that referenced this pull request Sep 25, 2024
* Converted LexRequirement into a struct.
* Adjusted the wrapping to return the correct type, since the LexRequirement was not being converted after the merge.
---------
Co-authored-by: nglime <git@ngli.me>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api changeChanges the API exposed to users of the cratecoreCore DataFusion cratephysical-exprChanges to the physical-expr cratesprotoRelated to proto crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

making LexRequirement an actual struct

3 participants

@ngli-me@alamb@berkaysynnada