Skip to content

feat: support V0 iceberg_tables schema for SqlCatalog - #3032

Open
dannycjones wants to merge 4 commits into
apache:mainfrom
dannycjones:support-sqlcatalogv0
Open

feat: support V0 iceberg_tables schema for SqlCatalog#3032
dannycjones wants to merge 4 commits into
apache:mainfrom
dannycjones:support-sqlcatalogv0

Conversation

@dannycjones

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Closes #2068.

This change supercedes #2380 originally authored by @rchowell.

What changes are included in this PR?

This PR adds support for using a V0 SqlCatalog from other implementations like iceberg-python or iceberg-java, and it follows the iceberg-java behavior of checking an explicit schema-version property and migrating to V1 only if the user requested this.

The catalog probes to see if we have a V0 or V1 table, then add the iceberg_type column if it does not exist. Reference: apache/iceberg-python#3263

Are these changes tested?

  • Unit tests with migration path

AI Disclosure

No AI has been used on the changes since #2380.

@CTTY CTTY left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for reviving this PR! mostly LGTM

let sql_bind_style = self
.config
.props
.remove(SQL_CATALOG_PROP_BIND_STYLE)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why do we need to consume the property here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I noticed this too but didn't have a preference. It is already established convention in the file. The URI and warehouse location would need to clone if we only borrowed from the config map.

I'm happy with it as is, but I can also move the rest of the load method to borrow (and clone if needed) instead of consume.

// Parse the requested schema version up front so invalid values fail fast rather than
// silently falling back to V0.
let mut valid_schema_version = true;
if let Some(schema_version) = self.config.props.remove(SQL_CATALOG_PROP_SCHEMA_VERSION) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same here, why consume?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Will address comment in this thread: #3032 (comment)

Ok(_) => true,
// The database rejected the query: the `iceberg_type` column (or table) is absent,
// so this is a genuine V0 schema.
Err(sqlx::Error::Database(_)) => false,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is still my biggest concern, there is no way for us to ensure that this is not a permission failure. I was thinking about something like an unexhastive enum to at least check the specific errors for Postgres, MySql, Sqlite. or let's create a follow up to add verification calls directly via different drivers like mentioned here: #2380 (comment)

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.

column "iceberg_type" does not exist

3 participants