nastra commented on code in PR #12014: URL: https://github.com/apache/iceberg/pull/12014#discussion_r1942405817
########## spark/v3.4/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestViews.java: ########## @@ -2109,6 +2109,34 @@ public void createViewWithCustomMetadataLocation() throws IOException { "")); } + @Test + public void readFromViewVersionTable() throws NoSuchTableException { + insertRows(10); + String viewName = viewName("simpleView"); + String sql = String.format("SELECT id FROM %s", tableName); + + ViewCatalog viewCatalog = viewCatalog(); + + viewCatalog + .buildView(TableIdentifier.of(NAMESPACE, viewName)) + .withQuery("spark", sql) + // use non-existing column name to make sure only the SQL definition for spark is loaded + .withQuery("trino", String.format("SELECT non_existing FROM %s", tableName)) + .withDefaultNamespace(NAMESPACE) + .withDefaultCatalog(catalogName) + .withSchema(schema(sql)) + .create(); + + // Similar to table's metadata table, view's metadata table requires fully qualified name. + List<Object[]> result = sql("SELECT * FROM %s.%s.%s.version", catalogName, NAMESPACE, viewName); + assertThat(result).hasSize(1); + assertThat(result.get(0).length).isEqualTo(7); Review Comment: we should add some additional checks here to assert all the values are what we expect. For this, you can store the result of the view creation above in a `view` variable and then use `view.currentVersion()` to compare values -- 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