Skip to content

fix: automatically migrate V0 SqlCatalog catalog tables#2380

Open
rchowell wants to merge 1 commit intoapache:mainfrom
rchowell:iceberg-type
Open

fix: automatically migrate V0 SqlCatalog catalog tables#2380
rchowell wants to merge 1 commit intoapache:mainfrom
rchowell:iceberg-type

Conversation

@rchowell
Copy link
Copy Markdown
Contributor

Which issue does this PR close?

What changes are included in this PR?

Probe to see if we have a V0 or V1 table, then add the iceberg_type column if it does not exist. More details in apache/iceberg-python#3263

Are these changes tested?

  • Unit tests with migration path

.map_err(from_sqlx_error)?;

// Check if the catalog table has the iceberg_type column, if not, it's a V0 schema.
let needs_migration = sqlx::query(&format!(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think it's a good idea to do migration silently. We should do followings:

  1. Add a config to do auto migration if need, and this should be disabled by default.
  2. If auto migration is disabled, and we detected that it's v0, we should return error.
  3. Add a pub api in SqlCatalog to allow user to do migration.

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 agree, however this is the same behavior as iceberg-java which by default does auto-migration. https://github.com/apache/iceberg/blob/main/core/src/main/java/org/apache/iceberg/jdbc/JdbcCatalog.java#L157

I am happy to change this if you still believe iceberg-rust should have a different behavior. Any thoughts on the config name since it does not exist in other libs?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I still don't think this is the right behavior to silently upgrade db schema. Also it's not upgrading silently, it will check a property: https://github.com/apache/iceberg/blob/b809dcd770d3c10cc6d81b70dc198422749cfa0e/core/src/main/java/org/apache/iceberg/jdbc/JdbcCatalog.java#L246

As with the property name, how about make it similar java version: sql.schema-version ?

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

2 participants