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

Meaningful error message for map builder with null keys #3450

Merged
merged 2 commits into from
Jan 6, 2023

Conversation

Jefffrey
Copy link
Contributor

@Jefffrey Jefffrey commented Jan 4, 2023

Which issue does this PR close?

Follow-on from discussion in PR: #3205 (comment)

Rationale for this change

Have clearer error message for when attempting to finish a MapBuilder which has null keys. Also do some refactoring.

What changes are included in this PR?

Are there any user-facing changes?

Comment on lines +113 to +118
if !matches!(data.data_type(), DataType::Map(_, _)) {
return Err(ArrowError::InvalidArgumentError(format!(
"MapArray expected ArrayData with DataType::Map got {}",
data.data_type()
)));
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

refactoring out a panic into an Err

@github-actions github-actions bot added the arrow Changes to the arrow crate label Jan 4, 2023
Comment on lines +178 to +182
assert!(
keys_arr.null_count() == 0,
"Keys array must have no null values, found {} null value(s)",
keys_arr.null_count()
);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ideally would return an Err instead of panicking, but would change signature of finish & finish_cloned, unsure if that is desirable? especially since other structs like StructBuilder has a similar signature (finish doesn't return a Result, just the StructArray)

Copy link
Contributor

Choose a reason for hiding this comment

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

In theory the API for adding keys wouldn't allow adding null values for keys -- but I see that is not possible with the current API

I agree keeping the current (non fallable) API is a reasonable choice

@Jefffrey
Copy link
Contributor Author

Jefffrey commented Jan 4, 2023

cc @tustvold

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.

LGTM -- thank you @Jefffrey

Comment on lines +178 to +182
assert!(
keys_arr.null_count() == 0,
"Keys array must have no null values, found {} null value(s)",
keys_arr.null_count()
);
Copy link
Contributor

Choose a reason for hiding this comment

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

In theory the API for adding keys wouldn't allow adding null values for keys -- but I see that is not possible with the current API

I agree keeping the current (non fallable) API is a reasonable choice

self.finish_helper(keys_arr, values_arr, offset_buffer, null_bit_buffer, len)
}

fn finish_helper(
Copy link
Contributor

Choose a reason for hiding this comment

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

this is a nice cleanup

@alamb alamb merged commit 39eeeaf into apache:master Jan 6, 2023
@ursabot
Copy link

ursabot commented Jan 6, 2023

Benchmark runs are scheduled for baseline = 7805a81 and contender = 39eeeaf. 39eeeaf 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

@Jefffrey Jefffrey deleted the mapbuilder_null_key_error_msg branch January 6, 2023 20:58
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