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

Add DictionaryArray Constructors (#3879) #4068

Merged
merged 1 commit into from
Apr 18, 2023

Conversation

tustvold
Copy link
Contributor

@tustvold tustvold commented Apr 12, 2023

Which issue does this PR close?

Part of #3879

Rationale for this change

What changes are included in this PR?

Are there any user-facing changes?

Yes, this makes a breaking change to DictionaryArray::try_new to make it consistent with the other arrays which take owned arguments

@tustvold tustvold added the api-change Changes to the arrow API label Apr 12, 2023
@github-actions github-actions bot added arrow Changes to the arrow crate arrow-flight Changes to the arrow-flight crate labels Apr 12, 2023
@tustvold tustvold force-pushed the dictionary-try-new branch from 9212997 to 9c0cbdf Compare April 12, 2023 16:47
@tustvold tustvold force-pushed the dictionary-try-new branch from 9c0cbdf to 992a196 Compare April 12, 2023 19:31
@tustvold tustvold marked this pull request as ready for review April 12, 2023 20:26
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

It looks good to me -- I worry it will be disrupive on downstream crates -- I wonder if we could mark the function deprecated for a release cycle (and maybe call the new DictionaryArray::try_new something bad like DictionaryArray::try_new2)? Maybe it is over thinking it I am just thinking of having to change a bunch of APIs downstream

@@ -1057,23 +1096,23 @@ mod tests {

#[test]
#[should_panic(
expected = "Value at position 1 out of bounds: 3 (should be in [0, 1])"
expected = "Invalid dictionary key 3 at index 1, expected 0 <= key < 2"
Copy link
Contributor

Choose a reason for hiding this comment

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

that is certainly a nicer error message

// Safety: `validate` ensures key type is correct, and
// `validate_values` ensures all offsets are within range
let array = unsafe { builder.build_unchecked() };
if let Some((idx, v)) = keys.values().iter().enumerate().find(|(idx, v)| {
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this code now redundant with the validity checks in ArrayData?

@tustvold
Copy link
Contributor Author

IMO marking it deprecated and removing it is only meaningful if there is a tangible behaviour change that is liable to cause people to defer making the change. As it stands, changing the arguments to be owned is likely as much a change as adding allow(deprecated)].

My vote is just to get it over and done with, but I will leave this open to see if anybody else weighs in

@alamb
Copy link
Contributor

alamb commented Apr 16, 2023

My vote is just to get it over and done with, but I will leave this open to see if anybody else weighs in

Sounds good to me

@tustvold tustvold merged commit 295ca86 into apache:master Apr 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-change Changes to the arrow API arrow Changes to the arrow crate arrow-flight Changes to the arrow-flight crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants