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 cast signed numeric to decimal #1044

Merged
merged 5 commits into from
Dec 20, 2021

Conversation

liukun4515
Copy link
Contributor

Which issue does this PR close?

part of #1043

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 Dec 14, 2021
@liukun4515 liukun4515 changed the title support cast signed numeric to decimal [WIP]support cast signed numeric to decimal Dec 14, 2021
@liukun4515 liukun4515 marked this pull request as draft December 14, 2021 08:46
@liukun4515 liukun4515 changed the title [WIP]support cast signed numeric to decimal support cast signed numeric to decimal Dec 16, 2021
@liukun4515 liukun4515 marked this pull request as ready for review December 16, 2021 08:30
@liukun4515
Copy link
Contributor Author

@alamb PTAL

@codecov-commenter
Copy link

codecov-commenter commented Dec 16, 2021

Codecov Report

Merging #1044 (f27dde4) into master (fc343e7) will increase coverage by 0.03%.
The diff coverage is 97.53%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1044      +/-   ##
==========================================
+ Coverage   82.30%   82.34%   +0.03%     
==========================================
  Files         168      168              
  Lines       49046    49135      +89     
==========================================
+ Hits        40368    40459      +91     
+ Misses       8678     8676       -2     
Impacted Files Coverage Δ
arrow/src/compute/kernels/cast.rs 94.98% <97.53%> (+0.17%) ⬆️
arrow/src/compute/kernels/take.rs 95.14% <0.00%> (-0.08%) ⬇️
arrow/src/array/transform/mod.rs 85.10% <0.00%> (+0.13%) ⬆️
parquet/src/encodings/encoding.rs 93.71% <0.00%> (+0.19%) ⬆️
parquet_derive/src/parquet_field.rs 66.21% <0.00%> (+0.22%) ⬆️
arrow/src/datatypes/datatype.rs 66.38% <0.00%> (+0.42%) ⬆️

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 fc343e7...f27dde4. Read the comment docs.

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.

Thank you @liukun4515 -- I looked at the code and it looks correct to me.

I think we need a little more test coverage but otherwise 👍

}

// test i32 to decimal type
let array = Int32Array::from(vec![1, 2, 3, 4, 5]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than just copy / pasting the integer tests when the differ only in the array type, what do you think about making a look like

let input = vec![
  Arc::new(Int8Array::from(vec![1, 2, 3, 4, 5])),
  Arc::new(Int16Array::from(vec![1, 2, 3, 4, 5])),
...
]

And then testing that in a loop? It would also allow coverage of Int16Array more easily

Copy link
Contributor Author

Choose a reason for hiding this comment

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

grate suggestion.
I will try it.

assert!(!can_cast_types(&DataType::UInt64, &decimal_type));

// test i8 to decimal type
let array = Int8Array::from(vec![1, 2, 3, 4, 5]);
Copy link
Contributor

Choose a reason for hiding this comment

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

I also think we should test Nulls here too

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 the Null element for test, please check.

@liukun4515
Copy link
Contributor Author

@alamb PTAL again, If it looks good for you, please merge this pull request.

@liukun4515
Copy link
Contributor Author

@alamb I'm confused about the CI, this pull request is blocked by the CI.
PTAL

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.

Thanks @liukun4515

@alamb
Copy link
Contributor

alamb commented Dec 20, 2021

CI looks good for this one now

@alamb alamb merged commit 4b3d928 into apache:master Dec 20, 2021
@liukun4515 liukun4515 deleted the support_cast_decimal branch December 21, 2021 00:39
alamb pushed a commit that referenced this pull request Dec 21, 2021
* support cast signed numeric to decimal

* add test for i8,i16,i32,i64,f32,f64 casted to decimal

* change format of float64

* add none test; merge integer test together
alamb added a commit that referenced this pull request Dec 22, 2021
* support cast signed numeric to decimal

* add test for i8,i16,i32,i64,f32,f64 casted to decimal

* change format of float64

* add none test; merge integer test together

Co-authored-by: Kun Liu <[email protected]>
mcheshkov pushed a commit to cube-js/arrow-rs that referenced this pull request Aug 26, 2024
* support cast signed numeric to decimal

* add test for i8,i16,i32,i64,f32,f64 casted to decimal

* change format of float64

* add none test; merge integer test together

Can drop this after rebase on commit 4b3d928, first released in 7.0.0
mcheshkov pushed a commit to cube-js/arrow-rs that referenced this pull request Aug 26, 2024
* support cast signed numeric to decimal

* add test for i8,i16,i32,i64,f32,f64 casted to decimal

* change format of float64

* add none test; merge integer test together

Can drop this after rebase on commit 4b3d928, first released in 7.0.0
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