rdblue commented on code in PR #9765: URL: https://github.com/apache/iceberg/pull/9765#discussion_r1496214318
########## core/src/main/java/org/apache/iceberg/jdbc/JdbcCatalog.java: ########## @@ -199,21 +198,29 @@ private void initializeCatalogTables() throws InterruptedException, SQLException }); } - private void updateCatalogTables(Connection connection) throws SQLException { - DatabaseMetaData dbMeta = connection.getMetaData(); - ResultSet typeColumn = - dbMeta.getColumns(null, null, JdbcUtil.CATALOG_TABLE_VIEW_NAME, JdbcUtil.RECORD_TYPE); - if (typeColumn.next()) { - LOG.debug("{} already supports views", JdbcUtil.CATALOG_TABLE_VIEW_NAME); - } else { - if (PropertyUtil.propertyAsBoolean( - catalogProperties, JdbcUtil.ADD_VIEW_SUPPORT_PROPERTY, false)) { - connection.prepareStatement(JdbcUtil.UPDATE_CATALOG_SQL).execute(); - } else { - LOG.warn(VIEW_WARNING_LOG_MESSAGE); - schemaVersion = JdbcUtil.SchemaVersion.V0; - } - } + private void checkAndMaybeUpdateSchema() throws SQLException, InterruptedException { + LOG.trace( + "Checking the SQL schema version and eventually update if {} is true", + JdbcUtil.ADD_VIEW_SUPPORT_PROPERTY); + connections.run( + conn -> { + DatabaseMetaData dbMeta = conn.getMetaData(); + ResultSet typeColumn = + dbMeta.getColumns(null, null, JdbcUtil.CATALOG_TABLE_VIEW_NAME, JdbcUtil.RECORD_TYPE); + if (typeColumn.next()) { + LOG.debug("{} already supports views", JdbcUtil.CATALOG_TABLE_VIEW_NAME); + return true; + } else { + if (PropertyUtil.propertyAsBoolean( + catalogProperties, JdbcUtil.ADD_VIEW_SUPPORT_PROPERTY, false)) { + return conn.prepareStatement(JdbcUtil.UPDATE_CATALOG_SQL).execute(); + } else { + LOG.warn(VIEW_WARNING_LOG_MESSAGE); + schemaVersion = JdbcUtil.SchemaVersion.V0; Review Comment: Instead of downgrading the schema, I think it should start at `V0` and be upgraded if needed. That's more conservative, in case there are any more unintended uses that don't run the check. -- 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: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org