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

Fix the behavior of from_fixed_size_list when offset > 0 #1964

Merged
merged 2 commits into from Jun 29, 2022

Conversation

HaoYang670
Copy link
Contributor

Signed-off-by: remzi 13716567376yh@gmail.com

Which issue does this PR close?

Closes #1958 .

Rationale for this change

Consider the impact of the offset of the list array (also the offset of the child array) when building decimal array.

What changes are included in this PR?

Are there any user-facing changes?

Signed-off-by: remzi <13716567376yh@gmail.com>
@github-actions github-actions bot added the arrow Changes to the arrow crate label Jun 29, 2022
#[test]
fn test_decimal_array_from_fixed_size_list() {
let value_data = ArrayData::builder(DataType::UInt8)
.offset(16)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add offset in the child array

let list_data = ArrayData::builder(list_data_type)
.len(2)
.null_bit_buffer(Some(null_buffer))
.offset(1)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add offset in the list array


assert_eq!(decimal.len(), 2);
assert!(decimal.is_null(0));
assert_eq!(decimal.value_as_string(1), "56".to_string());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is the expected result, because slicing a list array doesn't push down the offset to child

@codecov-commenter
Copy link

codecov-commenter commented Jun 29, 2022

Codecov Report

Merging #1964 (e1ba55d) into master (55d6073) will increase coverage by 0.01%.
The diff coverage is 95.23%.

@@            Coverage Diff             @@
##           master    #1964      +/-   ##
==========================================
+ Coverage   83.47%   83.48%   +0.01%     
==========================================
  Files         221      221              
  Lines       57054    57114      +60     
==========================================
+ Hits        47626    47682      +56     
- Misses       9428     9432       +4     
Impacted Files Coverage Δ
arrow/src/array/array_binary.rs 94.18% <95.23%> (-0.01%) ⬇️
arrow/src/compute/kernels/arithmetic.rs 90.61% <0.00%> (-0.26%) ⬇️
parquet_derive/src/parquet_field.rs 65.75% <0.00%> (-0.23%) ⬇️
parquet/src/file/writer.rs 92.90% <0.00%> (-0.02%) ⬇️
arrow/src/compute/kernels/cast.rs 95.79% <0.00%> (-0.02%) ⬇️
parquet/src/arrow/schema.rs 96.87% <0.00%> (-0.01%) ⬇️
arrow/src/datatypes/datatype.rs 65.42% <0.00%> (ø)
parquet/src/arrow/async_reader.rs 0.00% <0.00%> (ø)
parquet/src/file/metadata.rs 95.15% <0.00%> (+0.02%) ⬆️
parquet/src/encodings/encoding.rs 93.62% <0.00%> (+0.19%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 55d6073...e1ba55d. Read the comment docs.

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.

LGTM

arrow/src/array/array_binary.rs Outdated Show resolved Hide resolved
@@ -831,22 +831,26 @@ impl DecimalArray {
precision: usize,
scale: usize,
) -> Self {
let child_data = &v.data_ref().child_data()[0];
Copy link
Contributor

Choose a reason for hiding this comment

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

Somewhat tangential to this PR, but what happens to the child data's null buffer? Perhaps worth a docstring saying it is ignored?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great Catch!
I am not sure whether we should drop it or do list_nulls & child_nulls.

That's why I want to drop this function and build decimal array from FixedSizeBinary array instead.

Co-authored-by: Raphael Taylor-Davies <1781103+tustvold@users.noreply.github.com>
@tustvold tustvold merged commit 8bb494e into apache:master Jun 29, 2022
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.

DecimalArray::from_fixed_size_list_array fails when offset > 0
3 participants