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


##########
core/src/test/java/org/apache/iceberg/jdbc/TestJdbcCatalog.java:
##########
@@ -158,6 +162,66 @@ public void testInitialize() {
     jdbcCatalog.initialize("test_jdbc_catalog", properties);
   }
 
+  @Test
+  public void testSchemaUpdate() throws Exception {
+    // as this test uses different connection, we can't use memory database 
(as it's per
+    // connection), but a
+    // file database instead
+    java.nio.file.Path dbFile = Files.createTempFile("icebergSchemaUpdate", 
"db");
+    String jdbcUrl = "jdbc:sqlite:" + dbFile.toAbsolutePath();
+
+    initOldSchema(jdbcUrl);
+
+    Map<String, String> properties = Maps.newHashMap();
+    properties.put(CatalogProperties.WAREHOUSE_LOCATION, 
this.tableDir.toAbsolutePath().toString());
+    properties.put(CatalogProperties.URI, jdbcUrl);
+    properties.put(JdbcUtil.ADD_VIEW_SUPPORT_PROPERTY, "true");
+    JdbcCatalog jdbcCatalog = new JdbcCatalog();
+    jdbcCatalog.setConf(conf);
+    jdbcCatalog.initialize("TEST", properties);
+
+    List<TableIdentifier> tables = 
jdbcCatalog.listTables(Namespace.of("namespace1"));
+    Set<String> tablesSet = 
Sets.newHashSet(tables.stream().map(TableIdentifier::name).iterator());
+    assertThat(tablesSet).hasSize(1).contains("table1");
+
+    List<TableIdentifier> views = 
jdbcCatalog.listViews(Namespace.of("namespace1"));
+    assertThat(views).hasSize(0);
+  }
+
+  @Test
+  public void testOldSchemaSupport() throws Exception {

Review Comment:
   I would probably update this test to 
   ```
   @Test
     public void legacySchemaWorksWithoutViewSupport() throws Exception {
       // as this test uses different connection, we can't use memory database 
(as it's per
       // connection), but a
       // file database instead
       java.nio.file.Path dbFile = Files.createTempFile("icebergOldSchema", 
"db");
       String jdbcUrl = "jdbc:sqlite:" + dbFile.toAbsolutePath();
   
       initLegacySchema(jdbcUrl);
   
       Map<String, String> properties = Maps.newHashMap();
       properties.put(CatalogProperties.WAREHOUSE_LOCATION, 
this.tableDir.toAbsolutePath().toString());
       properties.put(CatalogProperties.URI, jdbcUrl);
       JdbcCatalog jdbcCatalog = new JdbcCatalog();
       jdbcCatalog.setConf(conf);
       jdbcCatalog.initialize("TEST", properties);
   
       TableIdentifier tableOne = TableIdentifier.of("namespace1", "table1");
       TableIdentifier tableTwo = TableIdentifier.of("namespace2", "table2");
       assertThat(jdbcCatalog.listTables(Namespace.of("namespace1")))
           .hasSize(1)
           .containsExactly(tableOne);
   
       assertThat(jdbcCatalog.listTables(Namespace.of("namespace2")))
           .hasSize(1)
           .containsExactly(tableTwo);
   
       TableIdentifier newTable = TableIdentifier.of("namespace1", "table2");
       jdbcCatalog.buildTable(newTable, SCHEMA).create();
   
       assertThat(jdbcCatalog.listTables(Namespace.of("namespace1")))
           .hasSize(2)
           .containsExactly(tableOne, newTable);
   
       assertThatThrownBy(() -> 
jdbcCatalog.listViews(Namespace.of("namespace1")))
           .isInstanceOf(UnsupportedOperationException.class)
           .hasMessage(JdbcCatalog.VIEW_WARNING_LOG_MESSAGE);
   
       assertThatThrownBy(
               () -> jdbcCatalog.buildView(TableIdentifier.of("namespace1", 
"view")).create())
           .isInstanceOf(UnsupportedOperationException.class)
           .hasMessage(JdbcCatalog.VIEW_WARNING_LOG_MESSAGE);
     }
   ```



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