jbonofre commented on code in PR #10111: URL: https://github.com/apache/iceberg/pull/10111#discussion_r1559367373
########## core/src/test/java/org/apache/iceberg/jdbc/TestJdbcUtil.java: ########## @@ -45,4 +51,97 @@ public void testFilterAndRemovePrefix() { assertThat(expected).isEqualTo(actual); } + + @Test + public void testV0toV1SqlStatements() throws Exception { + java.nio.file.Path dbFile = Files.createTempFile("icebergSchemaUpdate", "db"); + String jdbcUrl = "jdbc:sqlite:" + dbFile.toAbsolutePath(); + + SQLiteDataSource dataSource = new SQLiteDataSource(); + dataSource.setUrl(jdbcUrl); + + try (JdbcClientPool connections = new JdbcClientPool(jdbcUrl, Maps.newHashMap())) { + // create "old style" SQL schema + connections.newClient().prepareStatement(JdbcUtil.V0_CREATE_CATALOG_SQL).executeUpdate(); + + // inserting tables + JdbcUtil.doCommitCreateTable( + JdbcUtil.SchemaVersion.V0, + connections, + "TEST", + Namespace.of("namespace1"), + TableIdentifier.of(Namespace.of("namespace1"), "table1"), + "testLocation"); + JdbcUtil.doCommitCreateTable( + JdbcUtil.SchemaVersion.V0, + connections, + "TEST", + Namespace.of("namespace1"), + TableIdentifier.of(Namespace.of("namespace1"), "table2"), + "testLocation"); + + try (PreparedStatement statement = + connections.newClient().prepareStatement(JdbcUtil.V0_LIST_TABLE_SQL)) { + statement.setString(1, "TEST"); + statement.setString(2, "namespace1"); + ResultSet tables = statement.executeQuery(); + tables.next(); + assertThat(tables.getString(JdbcUtil.TABLE_NAME)).isEqualTo("table1"); + tables.next(); + assertThat(tables.getString(JdbcUtil.TABLE_NAME)).isEqualTo("table2"); + } + + // updating the schema from V0 to V1 + connections.newClient().prepareStatement(JdbcUtil.V1_UPDATE_CATALOG_SQL).execute(); + + // trying to add a table on the updated schema Review Comment: Good point, I will add this. -- 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