-
Notifications
You must be signed in to change notification settings - Fork 287
Rest: Implement register table #1521
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?
Conversation
0bfda56
to
5c342f3
Compare
StatusCode::UNAUTHORIZED => { | ||
return Err(Error::new( | ||
ErrorKind::Unexpected, | ||
"Authenticated user does not have the necessary permissions.", | ||
)); | ||
} | ||
StatusCode::FORBIDDEN => { | ||
return Err(Error::new( | ||
ErrorKind::Unexpected, | ||
"Authenticated user does not have the necessary permissions.", | ||
)); | ||
} |
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.
Also not sure if we need to check for these cases
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.
Following iceberg-java's error handling logic, I think it's necessary to handle all of these error codes
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 it's useful to process things like 404 and 409, others are general errors and we could use deserialize_unexpected_catalog_error
to handle it
5c342f3
to
574069f
Compare
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.
Hi @gabeiglio , thanks for your contribution! I've left some suggestions
} | ||
StatusCode::CONFLICT => { | ||
return Err(Error::new( | ||
ErrorKind::TableAlreadyExists, |
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.
This should use ErrorKind::CatalogCommitConflicts
and should be explicitly set to retryable using with_retryable(true)
StatusCode::UNAUTHORIZED => { | ||
return Err(Error::new( | ||
ErrorKind::Unexpected, | ||
"Authenticated user does not have the necessary permissions.", | ||
)); | ||
} | ||
StatusCode::FORBIDDEN => { | ||
return Err(Error::new( | ||
ErrorKind::Unexpected, | ||
"Authenticated user does not have the necessary permissions.", | ||
)); | ||
} |
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.
Following iceberg-java's error handling logic, I think it's necessary to handle all of these error codes
let metadata_location = response.metadata_location.as_ref().ok_or(Error::new( | ||
ErrorKind::DataInvalid, | ||
"Metadata location missing in `register_table` response!", | ||
))?; |
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: this can be slightly simplified using some syntax sugar
let Some(metadata_location) = response.metadata_location else { return Err(Error::new(...)) }
let file_io = self.load_file_io(metadata_location, None).await?;
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.
Thanks @gabeiglio for this pr, generally LGTM! Left some comments to fix.
#[serde(rename_all = "kebab-case")] | ||
pub(super) struct RegisterTableRequest { | ||
pub(super) name: String, | ||
pub(super) metadata_location: String, |
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.
Missing a field owerwrite
, see https://github.com/apache/iceberg/blob/cab0decbb0e32bf314039e30807eb033c50665d5/open-api/rest-catalog-open-api.yaml#L3536
StatusCode::UNAUTHORIZED => { | ||
return Err(Error::new( | ||
ErrorKind::Unexpected, | ||
"Authenticated user does not have the necessary permissions.", | ||
)); | ||
} | ||
StatusCode::FORBIDDEN => { | ||
return Err(Error::new( | ||
ErrorKind::Unexpected, | ||
"Authenticated user does not have the necessary permissions.", | ||
)); | ||
} |
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 it's useful to process things like 404 and 409, others are general errors and we could use deserialize_unexpected_catalog_error
to handle it
@@ -745,10 +749,86 @@ impl Catalog for RestCatalog { | |||
_table_ident: &TableIdent, |
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.
And _
prefix of parameter name means unused, we should remove them.
Which issue does this PR close?
What changes are included in this PR?
Are these changes tested?
Im new to Rust so any feedback is welcomed! :)