-
Notifications
You must be signed in to change notification settings - Fork 33
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
refactor: Refactor DateTypes to make it more easy to use #29
Conversation
Signed-off-by: Xuanwo <[email protected]>
Signed-off-by: Xuanwo <[email protected]>
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.
LGTM
@@ -329,44 +225,40 @@ impl BinaryType { | |||
|
|||
pub const DEFAULT_LENGTH: usize = 1; | |||
|
|||
pub fn new(is_nullable: bool, length: usize) -> Self { | |||
Self::try_new(is_nullable, length).unwrap() | |||
pub fn new(length: usize) -> Result<Self, &'static str> { |
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.
You might consider unifying the error types, such as using InvalidXXXType, and applying the same approach in other areas as well.
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.
You might consider unifying the error types, such as using InvalidXXXType, and applying the same approach in other areas as well.
Yes, we've directly migrated the code here without refactoring errors to clarify the scope of this PR. We can finish this part later.
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.
Would you like to perform this refactor? The error type has been defined at
paimon-rust/crates/paimon/src/error.rs
Lines 25 to 40 in a5cfac7
pub enum Error { | |
#[snafu(display("Paimon data invalid for {}: {:?}", message, source))] | |
DataInvalid { | |
message: String, | |
#[snafu(backtrace)] | |
source: snafu::Whatever, | |
}, | |
#[snafu( | |
visibility(pub(crate)), | |
display("Paimon hitting unexpected error {}: {:?}", message, source) | |
)] | |
IoUnexpected { | |
message: String, | |
source: opendal::Error, | |
}, | |
} |
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.
Tracked at #32
/// Returns true if the data type is nullable. | ||
/// | ||
/// Impl Reference: <https://github.com/apache/paimon/blob/release-0.8.2/paimon-common/src/main/java/org/apache/paimon/types/DataType.java#L59> | ||
fn is_nullable(&self) -> bool { |
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.
Is this method should be kept for the DataType
?
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.
Yes, we can implement in following PRs.
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.
OK
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.
Tracked at #31
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
This PR refactor data types to make it more easy to use in rust.
Some
Display
doesn't implemented correctly, I removed them in this PR. We can add them back in following PRs.