jbonofre commented on code in PR #9487:
URL: https://github.com/apache/iceberg/pull/9487#discussion_r1484131220


##########
core/src/main/java/org/apache/iceberg/jdbc/JdbcCatalog.java:
##########
@@ -185,14 +195,41 @@ private void initializeCatalogTables() throws 
InterruptedException, SQLException
           LOG.debug(
               "Creating table {} to store iceberg catalog namespace 
properties",
               JdbcUtil.NAMESPACE_PROPERTIES_TABLE_NAME);
-          return 
conn.prepareStatement(JdbcUtil.CREATE_NAMESPACE_PROPERTIES_TABLE).execute();
+          return 
conn.prepareStatement(JdbcUtil.CREATE_NAMESPACE_PROPERTIES_TABLE_SQL).execute();
         });
   }
 
+  private void updateCatalogTables(Connection connection) throws SQLException {
+    DatabaseMetaData dbMeta = connection.getMetaData();
+    ResultSet typeColumn =
+        dbMeta.getColumns(null, null, JdbcUtil.CATALOG_TABLE_VIEW_NAME, 
JdbcUtil.TYPE);
+    if (typeColumn.next()) {
+      LOG.debug("{} is already up-to-date", 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(
+            "{} is using the old SQL schema, you should update the SQL schema 
to support view.",
+            JdbcUtil.CATALOG_TABLE_VIEW_NAME);
+        viewSupport = false;
+      }
+    }
+  }
+
   @Override
   protected TableOperations newTableOps(TableIdentifier tableIdentifier) {
     return new JdbcTableOperations(
-        connections, io, catalogName, tableIdentifier, catalogProperties);
+        connections, io, catalogName, tableIdentifier, catalogProperties, 
viewSupport);
+  }
+
+  @Override
+  protected ViewOperations newViewOps(TableIdentifier viewIdentifier) {
+    if (!viewSupport) {
+      throw new RuntimeException(VIEW_WARNING_LOG_MESSAGE);

Review Comment:
   Yes, I forgot (that was my primary intention). I will update, thanks.



-- 
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

Reply via email to