-
Notifications
You must be signed in to change notification settings - Fork 21
Chore: support all basic types #144
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
base: main
Are you sure you want to change the base?
Chore: support all basic types #144
Conversation
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.
Pull request overview
This PR adds support for Date, Timestamp, and TimestampLtz basic data types across the row handling system. The implementation enables these types to be used in field getters, binary writers, and key encoders.
Changes:
- Added InternalRow methods for Date, Timestamp (NTZ), and Timestamp (LTZ) types
- Extended field getters, binary writers, and encoders to handle the new types
- Updated test coverage to verify encoding behavior for Date and Timestamp types
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| crates/fluss/src/row/mod.rs | Added get_date, get_timestamp_ntz, and get_timestamp_ltz methods to InternalRow trait and GenericRow implementation |
| crates/fluss/src/row/field_getter.rs | Added Date, Timestamp, and TimestampLtz variants to InnerFieldGetter enum with corresponding get_field implementations |
| crates/fluss/src/row/encode/compacted_key_encoder.rs | Updated test_all_data_types test to include Date and Timestamp encoding verification |
| crates/fluss/src/row/datum.rs | Added new() and get_inner() methods for Timestamp and TimestampLtz types; updated test to be explicit about Cow type |
| crates/fluss/src/row/compacted/compacted_row_writer.rs | Added write_decimal, write_timestamp_ntz, and write_timestamp_ltz methods |
| crates/fluss/src/row/compacted/compacted_key_writer.rs | Delegated new write methods from BinaryWriter trait to CompactedRowWriter |
| crates/fluss/src/row/column.rs | Implemented get_date, get_timestamp_ntz, and get_timestamp_ltz for ColumnarRow |
| crates/fluss/src/row/binary/binary_writer.rs | Updated BinaryWriter trait and InnerValueWriter to support Decimal, Date, TimestampNtz, and TimestampLtz types |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
leekeiabstraction
left a comment
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.
Left comments, PTAL!
|
|
||
| // TODO Decimal type | ||
| // fn write_decimal(&mut self, pos: i32, value: f64); | ||
| fn write_decimal(&mut self, value: &rust_decimal::Decimal, precision: u32); |
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.
nit: decimal as name should suffice, none other args within this trait starts with rust_
| // For now, serialize decimal to its string representation and write as bytes | ||
| // TODO: implement compact decimal encoding based on precision similar to Java implementation | ||
| let s = value.to_string(); | ||
| self.write_bytes(s.as_bytes()); |
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.
We should really have an implementation is consistent with Java's for this task.
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.
+1
| // Currently write timestamp as a long (epoch millis or other unit depending on upstream) | ||
| self.write_long(value); |
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.
We should really have an implementation is consistent with Java's for this task.
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.
+1
| // Currently write timestamp as a long (epoch millis or other unit depending on upstream) | ||
| self.write_long(value); |
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.
We should really have an implementation is consistent with Java's for this task.
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.
+1
| Datum::from(15.21f64), | ||
| // TODO Date | ||
| // TODO Time | ||
| Datum::Date(crate::row::datum::Date::new(5)), |
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.
What does 5 mean?
I suggest using the date 2023-10-25 to keep test case parity with java side.
| // TODO Date | ||
| // TODO Time | ||
| Datum::Date(crate::row::datum::Date::new(5)), | ||
| Datum::Timestamp(crate::row::datum::Timestamp::new(13)), |
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 suggest using 09:30:00.0 to keep test case parity with java side.
luoyuxia
left a comment
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.
@Varad-VK Thanks for the pr. I left minor comment. PTAL
| fn write_double(&mut self, value: f64); | ||
|
|
||
| fn write_binary(&mut self, bytes: &[u8], length: usize); | ||
|
|
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.
sorry for miss that, can we also support write_time in this pr?
| Date, | ||
| TimestampNtz(u32), // precision | ||
| TimestampLtz(u32), // precision | ||
| // TODO TimeWithoutTimeZone, Array, Row |
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.
Can we also support Time in this pr?
| Float, | ||
| Double, | ||
| // TODO Decimal, Date, TimeWithoutTimeZone, TimestampWithoutTimeZone, TimestampWithLocalTimeZone, Array, Row | ||
| Decimal(u32), // precision |
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.
| Decimal(u32), // precision | |
| Decimal(u32, u32), // precision, scale |
| // For now, serialize decimal to its string representation and write as bytes | ||
| // TODO: implement compact decimal encoding based on precision similar to Java implementation | ||
| let s = value.to_string(); | ||
| self.write_bytes(s.as_bytes()); |
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.
+1
| // Currently write timestamp as a long (epoch millis or other unit depending on upstream) | ||
| self.write_long(value); |
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.
+1
| // Currently write timestamp as a long (epoch millis or other unit depending on upstream) | ||
| self.write_long(value); |
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.
+1
| self.get_int(pos) | ||
| } | ||
|
|
||
| fn get_timestamp_ntz(&self, pos: usize) -> i64 { |
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.
we can return Timestamp directly
| self.get_long(pos) | ||
| } | ||
|
|
||
| fn get_timestamp_ltz(&self, pos: usize) -> i64 { |
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.
| fn get_timestamp_ltz(&self, pos: usize) -> i64 { | |
| fn get_timestamp_ltz(&self, pos: usize) -> TimestampLtz { |
| fn get_string(&self, pos: usize) -> &str; | ||
|
|
||
| // /// Returns the decimal value at the given position | ||
| // fn get_decimal(&self, pos: usize, precision: usize, scale: usize) -> Decimal; |
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.
could you please also support this method?
Fixes #130
Summary:
Testing: