Skip to content
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

[query] Preserve field order in StructExpression.rename #14807

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

chrisvittal
Copy link
Collaborator

Either set construction from an iterator or set difference is not order preserving. If we iterate through the struct fields in order, then our select inside of rename will preserve order for existing fields.

Brief description and justification of what this PR is doing.

Security Assessment

Delete all except the correct answer:

  • This change has no security impact

Impact Description

Query only. Simply causes a single iteration to happen in a different order.

Either set construction from an iterator or set difference is not order
preserving. If we iterate through the struct fields in order, then our
select inside of rename will preserve order for existing fields.
Copy link
Collaborator

@patrick-schultz patrick-schultz left a comment

Choose a reason for hiding this comment

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

Oof, good catch! Would you mind adding a simple test to enforce that rename preserves order?

Copy link
Collaborator

@cjllanwarne cjllanwarne left a comment

Choose a reason for hiding this comment

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

Looks correct to me, and I agree with @patrick-schultz 's request for a test.

It looks like the rename still shuffles all the renamed fields to the end of the list, even if the original fields are left in their original order. Is that the intended semantics?

@chrisvittal
Copy link
Collaborator Author

We don't necessarily make guarantees as to the order of the fields, but rename is implemented as select which puts 'new' fields at the end of the new struct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants