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


##########
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 {
+    // 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();
+
+    initOldSchema(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);
+
+    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");

Review Comment:
   this seems to be slightly more complicated than necessary. This could be 
done in a single stmt: 
   ```
   assertThat(jdbcCatalog.listTables(Namespace.of("namespace1")))
           .hasSize(1)
           .containsExactly(tableOne);
   ```



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

Reply via email to