CTTY commented on code in PR #3032:
URL: https://github.com/apache/iceberg-rust/pull/3032#discussion_r3827350165
##########
crates/catalog/sql/src/catalog.rs:
##########
@@ -199,14 +206,33 @@ impl CatalogBuilder for SqlCatalogBuilder {
let name = name.into();
let mut valid_sql_bind_style = true;
- if let Some(sql_bind_style) =
self.config.props.remove(SQL_CATALOG_PROP_BIND_STYLE) {
+
+ // Accept the preferred `sql.bind-style` key, falling back to the
legacy `sql_bind_style`.
+ let sql_bind_style = self
+ .config
+ .props
+ .remove(SQL_CATALOG_PROP_BIND_STYLE)
Review Comment:
Why do we need to consume the property here?
##########
crates/catalog/sql/src/catalog.rs:
##########
@@ -343,6 +417,46 @@ impl SqlCatalog {
.await
.map_err(from_sqlx_error)?;
+ // Probe for the `iceberg_type` column to detect whether the catalog
table is already a schema version v1 (which supports views).
+ let is_v1 = match sqlx::query(&format!(
+ "SELECT {CATALOG_FIELD_RECORD_TYPE} FROM {CATALOG_TABLE_NAME}
LIMIT 0"
+ ))
+ .execute(&pool)
+ .await
+ {
+ 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,
Review Comment:
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:
https://github.com/apache/iceberg-rust/pull/2380#discussion_r3252774410
##########
crates/catalog/sql/src/catalog.rs:
##########
@@ -199,14 +206,33 @@ impl CatalogBuilder for SqlCatalogBuilder {
let name = name.into();
let mut valid_sql_bind_style = true;
- if let Some(sql_bind_style) =
self.config.props.remove(SQL_CATALOG_PROP_BIND_STYLE) {
+
+ // Accept the preferred `sql.bind-style` key, falling back to the
legacy `sql_bind_style`.
+ let sql_bind_style = self
+ .config
+ .props
+ .remove(SQL_CATALOG_PROP_BIND_STYLE)
+ .or_else(||
self.config.props.remove(SQL_CATALOG_PROP_BIND_STYLE_LEGACY));
+
+ // Validate the SQL bind style
+ if let Some(sql_bind_style) = sql_bind_style {
if let Ok(sql_bind_style) =
SqlBindStyle::from_str(&sql_bind_style) {
self.config.sql_bind_style = sql_bind_style;
} else {
valid_sql_bind_style = false;
}
}
+ // 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) {
Review Comment:
Same here, why consume?
--
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]