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

refactor: Refactor DateTypes to make it more easy to use #29

Merged
merged 2 commits into from
Aug 2, 2024

Conversation

Xuanwo
Copy link
Member

@Xuanwo Xuanwo commented Aug 2, 2024

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.

Copy link
Contributor

@XuQianJin-Stars XuQianJin-Stars left a 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> {
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Member Author

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

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,
},
}

Copy link
Member Author

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 {
Copy link
Contributor

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 ?

Copy link
Member Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK

Copy link
Member Author

Choose a reason for hiding this comment

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

Tracked at #31

Copy link
Contributor

@Aitozi Aitozi left a comment

Choose a reason for hiding this comment

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

+1

@Aitozi Aitozi merged commit 65a8e74 into apache:main Aug 2, 2024
7 checks passed
@Xuanwo Xuanwo deleted the refactor-type branch August 2, 2024 14:45
devillove084 pushed a commit to devillove084/paimon-rust that referenced this pull request Aug 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants