gabeiglio commented on code in PR #13847: URL: https://github.com/apache/iceberg/pull/13847#discussion_r2285914223
########## core/src/test/java/org/apache/iceberg/view/ViewCatalogTests.java: ########## @@ -86,6 +87,56 @@ public void loadViewWithNonExistingNamespace() { .hasMessageStartingWith("View does not exist: %s", ident); } + @Test + public void loadViewThatAlreadyExistsAsTable() { + assumeThat(tableCatalog()).as("Only valid for catalogs that support tables").isNotNull(); + + TableIdentifier tableIdentifier = TableIdentifier.of("ns", "table"); + + if (requiresNamespaceCreate()) { + catalog().createNamespace(tableIdentifier.namespace()); + } + + assertThat(tableCatalog().tableExists(tableIdentifier)).as("Table should not exist").isFalse(); + + tableCatalog().buildTable(tableIdentifier, SCHEMA).create(); + + assertThat(tableCatalog().tableExists(tableIdentifier)).as("Table should exist").isTrue(); + + assertThatThrownBy(() -> catalog().loadView(tableIdentifier)) + .isInstanceOf(NoSuchViewException.class) + .hasMessageStartingWith("View does not exist"); + + assertThat(catalog().viewExists(tableIdentifier)).as("View should not exist").isFalse(); + } + + @Test + public void loadTableThatAlreadyExistsAsView() { + assumeThat(tableCatalog()).as("Only valid for catalogs that support tables").isNotNull(); + + TableIdentifier viewIdentifier = TableIdentifier.of("ns", "table"); + + if (requiresNamespaceCreate()) { + catalog().createNamespace(viewIdentifier.namespace()); + } + + assertThat(catalog().viewExists(viewIdentifier)).as("View should not exists").isFalse(); + catalog() + .buildView(viewIdentifier) + .withSchema(SCHEMA) + .withDefaultNamespace(viewIdentifier.namespace()) + .withQuery("spark", "select * from ns.tbl") + .create(); + + assertThat(catalog().viewExists(viewIdentifier)).as("View should exist").isTrue(); + + assertThatThrownBy(() -> tableCatalog().loadTable(viewIdentifier)) + .isInstanceOf(NoSuchTableException.class) + .hasMessageStartingWith("Table does not exist"); + + assertThat(tableCatalog().tableExists(viewIdentifier)).as("Table should not exist").isFalse(); Review Comment: Ah yea let me fix 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