rchowell commented on code in PR #2380:
URL: https://github.com/apache/iceberg-rust/pull/2380#discussion_r3236296714
##########
crates/catalog/sql/src/catalog.rs:
##########
@@ -297,15 +310,60 @@ impl SqlCatalog {
.await
.map_err(from_sqlx_error)?;
+ // Check if the catalog table supports views, indicating that the
schema is V1
+ let is_v1 = sqlx::query(&format!(
+ "SELECT {CATALOG_FIELD_RECORD_TYPE} FROM {CATALOG_TABLE_NAME}
LIMIT 0"
+ ))
+ .execute(&pool)
+ .await
+ .is_ok();
Review Comment:
The sqlx library does not have a way to retrieve schemas in a backend
agnostic way. The sql to be written is also backend specific, while pg has
information_schema, sqlite does not. The JDBC approach is much heavier than
sqlx, but this little probe select is nice because it will fail if the column
does not exist.
It's fair to assume that if the query fails for reasons other than a binding
error, like a connection or permission issue, then any metadata query would
have failed too. To be honest, I think this simple probe query is an elegant
way to check for a column's existence in a backend agnostic way. Any
information_schema checking would be far more complicated and be subject to the
same failure modes anyway.
--
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]