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

Support casting from binary to dictionary of binary #3482

Merged
merged 1 commit into from
Jan 16, 2023

Conversation

viirya
Copy link
Member

@viirya viirya commented Jan 6, 2023

Which issue does this PR close?

Part of #1179.

Rationale for this change

What changes are included in this PR?

Are there any user-facing changes?

@github-actions github-actions bot added the arrow Changes to the arrow crate label Jan 6, 2023
Comment on lines +3355 to +3359
fn pack_binary_to_dictionary<K>(
array: &ArrayRef,
cast_options: &CastOptions,
) -> Result<ArrayRef, ArrowError>
where
Copy link
Member Author

Choose a reason for hiding this comment

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

Perhaps we can have a generic one for both string and binary, I may try it in a follow up work.

@viirya viirya force-pushed the cast_binary_to_dict_binary branch from 82e3b8d to 8f21b9a Compare January 6, 2023 22:28
@@ -268,7 +268,7 @@ where
let keys = self.keys_builder.finish();

let data_type =
DataType::Dictionary(Box::new(K::DATA_TYPE), Box::new(DataType::Utf8));
DataType::Dictionary(Box::new(K::DATA_TYPE), Box::new(T::DATA_TYPE));
Copy link
Member Author

Choose a reason for hiding this comment

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

Found a bug.

Copy link
Contributor

Choose a reason for hiding this comment

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

Eep

@viirya viirya force-pushed the cast_binary_to_dict_binary branch from f71a2d1 to 6a4ca6e Compare January 6, 2023 23:39
@@ -3285,6 +3285,8 @@ fn cast_to_dictionary<K: ArrowDictionaryKeyType>(
),
Utf8 => pack_string_to_dictionary::<K>(array, cast_options),
LargeUtf8 => pack_string_to_dictionary::<K>(array, cast_options),
Binary => pack_binary_to_dictionary::<K>(array, cast_options),
LargeBinary => pack_binary_to_dictionary::<K>(array, cast_options),
Copy link
Contributor

Choose a reason for hiding this comment

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

The method assumes BinaryArray, so I'm not sure how this works?

Copy link
Member Author

Choose a reason for hiding this comment

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

Like pack_string_to_dictionary, they both perform casting first to get StringArray/BinaryArray which is taken to build dictionary array. I think we can simplify this by removing first casting. I will do it in a follow up pr.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah this is also problematic as it bat truncate offsets, would be good to fix

Dictionary(Box::new(DataType::UInt32), Box::new(DataType::Utf8)),
Dictionary(Box::new(DataType::UInt32), Box::new(DataType::Binary)),
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the rationale for this choice of dictionary keys

Copy link
Member Author

Choose a reason for hiding this comment

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

I just picked it following other existing types. Maybe as a improvement, I can refactor this in a separate pr to iterate all possible dictionary key types.

@viirya viirya requested a review from tustvold January 13, 2023 17:14
Copy link
Contributor

@tustvold tustvold left a comment

Choose a reason for hiding this comment

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

Sorry for the delay

@tustvold tustvold merged commit 07fd434 into apache:master Jan 16, 2023
@ursabot
Copy link

ursabot commented Jan 16, 2023

Benchmark runs are scheduled for baseline = 95cf030 and contender = 07fd434. 07fd434 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on ec2-t3-xlarge-us-east-2] ec2-t3-xlarge-us-east-2
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on test-mac-arm] test-mac-arm
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on ursa-i9-9960x] ursa-i9-9960x
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on ursa-thinkcentre-m75q] ursa-thinkcentre-m75q
Buildkite builds:
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

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

Successfully merging this pull request may close these issues.

3 participants