You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "rdblue (via GitHub)" <gi...@apache.org> on 2024/02/25 18:32:05 UTC

Re: [PR] Spark 3.4, 3.5: Use current namespace for SHOW VIEWS cmd [iceberg]

rdblue commented on code in PR #9787:
URL: https://github.com/apache/iceberg/pull/9787#discussion_r1501873385


##########
spark/v3.4/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestViews.java:
##########
@@ -1335,6 +1335,35 @@ public void showViews() throws NoSuchTableException {
             row("global_temp", "globalviewforlisting", true), tempView);
   }
 
+  @Test
+  public void showViewsWithCurrentNamespace() {
+    String namespaceOne = "show_views_ns1";
+    String namespaceTwo = "show_views_ns2";
+    String viewOne = viewName("viewOne");
+    String viewTwo = viewName("viewTwo");
+    sql("CREATE NAMESPACE IF NOT EXISTS %s", namespaceOne);
+    sql("CREATE NAMESPACE IF NOT EXISTS %s", namespaceTwo);
+
+    // create one view in each namespace
+    sql("CREATE VIEW %s.%s AS SELECT * FROM %s.%s", namespaceOne, viewOne, NAMESPACE, tableName);
+    sql("CREATE VIEW %s.%s AS SELECT * FROM %s.%s", namespaceTwo, viewTwo, NAMESPACE, tableName);
+
+    Object[] v1 = row(namespaceOne, viewOne, false);
+    Object[] v2 = row(namespaceTwo, viewTwo, false);
+
+    sql("USE %s", namespaceOne);
+    // should only contain v1 but not v2
+    assertThat(sql("SHOW VIEWS")).contains(v1).doesNotContain(v2);
+    assertThat(sql("SHOW VIEWS IN %s", catalogName)).contains(v1).doesNotContain(v2);

Review Comment:
   The behavior for `SHOW TABLES IN catalog_name` is to list the root namespace. If the root namespace is not a supported namespace, it fails (I tested a local HadoopCatalog). I think that is reasonable behavior: the `IN` clause specifies the namespace to list. The multi-part identifier passed to the `IN` clause is resolved and the current catalog is used if no catalog is specified, but the current namespace is not used.



-- 
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-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org