Skip to content

Conversation

Yiyang-C
Copy link
Contributor

Which issue does this PR close?

What changes are included in this PR?

  • implemented the register_table method in the Glue catalog.

  • added an integration test to cover table registration via metadata location.

Are these changes tested?

Yes

  • cargo build
  • cargo test (including new test case for register_table)

I'm new to Rust and to Iceberg, any feedback or suggestions for improvement are very welcome! 😊

Copy link
Contributor

@CTTY CTTY left a comment

Choose a reason for hiding this comment

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

Thanks for the work Yiyang ! Left some comments

async fn register_table(
&self,
_table_ident: &TableIdent,
_metadata_location: String,
table: &TableIdent,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
table: &TableIdent,
table_ident: &TableIdent,

"Table {}.{} created but failed to load: {e}",
db_name, table_name
),
)
Copy link
Contributor

Choose a reason for hiding this comment

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

We should use .with_source(e) to expose the cause

} else {
Err(from_aws_sdk_error(err))
}
}
Copy link
Contributor

@CTTY CTTY Jul 31, 2025

Choose a reason for hiding this comment

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

Hmm it seems that iceberg-rs doesn't handle aws error very explicitly, the existing way of exposing error is just attaching AWS SDK error as a source and return ErrorKind::Unexpected: https://github.com/apache/iceberg-rust/blob/2bc03c28268f15472353b828602bb5efd3bf9513/crates/catalog/glue/src/error.rs#L24-L23

ideally we want to handle every error listed here for CreateTable: https://docs.rs/aws-sdk-glue/latest/aws_sdk_glue/operation/create_table/enum.CreateTableError.html

the error handling in this PR looks good to me, and we should update the existing error handling in create_table. this should be completed with a follow-up


match result {
Ok(_) => {
self.load_table(table).await.map_err(|e| {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just use Table::builder()....build() so we don't need to load the table here?

ref:

@@ -624,15 +624,75 @@ impl Catalog for GlueCatalog {
}
}

/// Asynchronously registers an existing table into the Glue Catalog.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why adding Asynchronously? Do you mean the async function? If so, we typically don't add this word.

@Yiyang-C Yiyang-C force-pushed the register-table-test branch 3 times, most recently from d606bc8 to 993c707 Compare August 26, 2025 22:19
- removed unnecessary wording in function documentation comments
- renamed `table_ident` parameter
- replaced `load_table()` with `Table::builder()`
- attached source error using `.with_source(e)`
- restructured error handling to follow `update_table()` pattern
@Yiyang-C Yiyang-C force-pushed the register-table-test branch from 993c707 to 6470f34 Compare August 26, 2025 22:27
@Yiyang-C Yiyang-C requested a review from CTTY August 26, 2025 22:49
Copy link
Contributor

@CTTY CTTY left a comment

Choose a reason for hiding this comment

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

LGTM!

),
CreateTableError::AlreadyExistsException(_) => Error::new(
ErrorKind::TableAlreadyExists,
format!("Table {}.{} already exists", db_name, table_name),
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: you can use table_ident directly, it already contains both

_ => Error::new(
ErrorKind::Unexpected,
format!(
"Failed to register table {}.{} due to AWS SDK error",
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

- updated error message
@Yiyang-C Yiyang-C force-pushed the register-table-test branch from 421b3fa to 1bc8fc4 Compare August 26, 2025 23:27
@Yiyang-C Yiyang-C requested a review from liurenjie1024 August 26, 2025 23:40
Copy link
Contributor

@liurenjie1024 liurenjie1024 left a comment

Choose a reason for hiding this comment

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

Thanks @Yiyang-C for this pr, and @CTTY for review!

@liurenjie1024 liurenjie1024 merged commit 94bed60 into apache:main Aug 27, 2025
17 checks passed
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.

Implement register_table for glue catalog
3 participants