dannycjones commented on code in PR #3032:
URL: https://github.com/apache/iceberg-rust/pull/3032#discussion_r3831851784
##########
crates/catalog/sql/src/catalog.rs:
##########
@@ -343,6 +441,52 @@ impl SqlCatalog {
.await
.map_err(from_sqlx_error)?;
+ let detected_schema_version = SchemaVersion::detect(&pool).await?;
+ let desired_schema_version = config.schema_version;
+
+ // Detect schema by describing columns. If desired schema is
configured then automigrate, otherwise gracefully support older schemas.
+ let schema_version = match (detected_schema_version,
desired_schema_version) {
+ (SchemaVersion::V1, Some(SchemaVersion::V1) | None) => {
+ tracing::debug!(
+ "detected {CATALOG_TABLE_NAME} schema {} which already
supports views",
+ detected_schema_version,
+ );
+ SchemaVersion::V1
+ }
+ (SchemaVersion::V0, Some(desired_schema_version @
SchemaVersion::V1)) => {
+ tracing::warn!(
+ "table {CATALOG_TABLE_NAME} has inferred schema {} but
desired schema {}, performing migration",
+ detected_schema_version,
+ desired_schema_version,
+ );
+ if let Some(migration_sql) = SchemaVersion::V1.migration_sql()
{
+ sqlx::query(&migration_sql)
+ .execute(&pool)
+ .await
+ .map_err(from_sqlx_error)?;
+ }
Review Comment:
I'm going to leave that as a follow up rather than bloat the PR any further.
The Java implementation does not address this risk either.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]