-
Notifications
You must be signed in to change notification settings - Fork 839
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 Decimal256Builder
and Decimal256Array
; Decimal arrays now implement BasicDecimalArray
trait
#2000
Conversation
Marked as draft now and I will add some tests and dedup some codes. |
If it is ready, please @ me. @viirya |
Codecov Report
@@ Coverage Diff @@
## master #2000 +/- ##
==========================================
- Coverage 83.58% 83.58% -0.01%
==========================================
Files 222 222
Lines 57529 57603 +74
==========================================
+ Hits 48088 48145 +57
- Misses 9441 9458 +17
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the code looks good to me 👍 Nice work @viirya and thank you!
I have some comments regarding checking for mismatch in precision / scale between the builder and values, but otherwise I think this PR looks good to me.
pub fn append_value(&mut self, value: &Decimal256) -> Result<()> { | ||
let value_as_bytes = value.raw_value(); | ||
|
||
if self.builder.value_length() != value_as_bytes.len() as i32 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we also need to check the precision
and scale
of value
(and either error if they don't match the builder or do conversion if required) 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I think we should. It is a cheap check too so I think okay.
bytes = vec![0; 32]; | ||
bytes[0..16].clone_from_slice(&0_i128.to_le_bytes()); | ||
bytes[15] = 128; | ||
let value = Decimal256::try_new_from_bytes(40, 6, bytes.as_slice()).unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should add a test for appending a value
that has a precision/scale other than 40. 6
, as I mentioned above
Should I be reviewing this or #2006, they seem to implement the same functionality? |
/// See [`Decimal256Array`] for example. | ||
#[derive(Debug)] | ||
pub struct Decimal256Builder { | ||
builder: FixedSizeListBuilder<UInt8Builder>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be more straightforward to build decimal array based on FixedSizeBinaryBuilder
. I will file a followup issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create #2026 to track this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also confused about that we use the the FixedSizeListBuilder
to store decimal data in the decimal builder.
@tustvold is this one good to go (for arrow 18?) |
Decimal256Builder
and Decimal256Array
Decimal256Builder
and Decimal256Array
Decimal256Builder
and Decimal256Array
; Decimal arrays now implement BasicDecimalArray
trait
I see now that @liukun4515 asked to be pinged on this PR for review, which @viirya did but then I merged it prior to @liukun4515 having a chance to review. @liukun4515 I will make the 18.0.0 release candidate but if you find issues with the API or some other reason we should not release 18.0.0 with this change in it, please let me know and we can make changes prior to release. |
Sorry for the later reply, I am busy with other task. |
Which issue does this PR close?
Closes #1999.
Rationale for this change
What changes are included in this PR?
Are there any user-facing changes?