Chore: support all basic types#144
Conversation
There was a problem hiding this comment.
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.
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.
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.
We should really have an implementation is consistent with Java's for this task.
| // 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.
We should really have an implementation is consistent with Java's for this task.
| // 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.
We should really have an implementation is consistent with Java's for this task.
| Datum::from(15.21f64), | ||
| // TODO Date | ||
| // TODO Time | ||
| Datum::Date(crate::row::datum::Date::new(5)), |
There was a problem hiding this comment.
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.
I suggest using 09:30:00.0 to keep test case parity with java side.
| @@ -52,14 +52,11 @@ pub trait BinaryWriter { | |||
|
|
|||
| fn write_binary(&mut self, bytes: &[u8], length: usize); | |||
|
|
|||
There was a problem hiding this comment.
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.
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.
| 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()); |
| // Currently write timestamp as a long (epoch millis or other unit depending on upstream) | ||
| self.write_long(value); |
| // Currently write timestamp as a long (epoch millis or other unit depending on upstream) | ||
| self.write_long(value); |
| self.get_int(pos) | ||
| } | ||
|
|
||
| fn get_timestamp_ntz(&self, pos: usize) -> i64 { |
There was a problem hiding this comment.
we can return Timestamp directly
| self.get_long(pos) | ||
| } | ||
|
|
||
| fn get_timestamp_ltz(&self, pos: usize) -> i64 { |
There was a problem hiding this comment.
| fn get_timestamp_ltz(&self, pos: usize) -> i64 { | |
| fn get_timestamp_ltz(&self, pos: usize) -> TimestampLtz { |
| @@ -65,11 +65,14 @@ pub trait InternalRow { | |||
| // /// 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.
could you please also support this method?
|
@Varad-VK Hi, Do you still have time to working on this pr? If not, we're going to take over on it. |
|
Hi @luoyuxia, please take it ahead . |
|
I'll help here |
|
Will continue in #175 |
Fixes #130
Summary:
Testing: