nastra commented on code in PR #11751: URL: https://github.com/apache/iceberg/pull/11751#discussion_r1881747660
########## spark/v3.5/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestViews.java: ########## @@ -1414,7 +1414,42 @@ public void describeExtendedView() { String.format( "['format-version' = '1', 'location' = '%s', 'provider' = 'iceberg']", location), - "")); + ""), + row("View Text", sql, "")); + } + + @TestTemplate + public void describeExtendedViewWithoutCurrentNamespace() { Review Comment: I took a look at the issue and I think the issue is less with `DESCRIBE` itself, but rather the namespace being used during view creation: These 2 tests should be all we need ``` @TestTemplate public void createViewInDefaultNamespace() { String viewName = viewName("createViewInDefaultNamespace"); String sql = String.format("SELECT id, data FROM %s WHERE id <= 3", tableName); sql("CREATE VIEW %s (id, data) AS %s", viewName, sql); View view = viewCatalog().loadView(TableIdentifier.of(NAMESPACE, viewName)); assertThat(view.currentVersion().defaultCatalog()).isNull(); assertThat(view.currentVersion().defaultNamespace()).isEqualTo(NAMESPACE); } @TestTemplate public void createViewWithoutCurrentNamespace() { String viewName = viewName("createViewWithoutCurrentNamespace"); Namespace namespace = Namespace.of("test_namespace"); String sql = String.format("SELECT id, data FROM %s WHERE id <= 3", tableName); sql("CREATE NAMESPACE IF NOT EXISTS %s", namespace); sql("CREATE VIEW %s.%s (id, data) AS %s", namespace, viewName, sql); View view = viewCatalog().loadView(TableIdentifier.of(namespace, viewName)); assertThat(view.currentVersion().defaultCatalog()).isNull(); assertThat(view.currentVersion().defaultNamespace()).isEqualTo(namespace); } ``` I still need to double-check some things, but most likely the fix we need is this: ``` --- a/spark/v3.5/spark-extensions/src/main/scala/org/apache/spark/sql/execution/datasources/v2/CreateV2ViewExec.scala +++ b/spark/v3.5/spark-extensions/src/main/scala/org/apache/spark/sql/execution/datasources/v2/CreateV2ViewExec.scala @@ -48,7 +48,7 @@ case class CreateV2ViewExec( override protected def run(): Seq[InternalRow] = { val currentCatalogName = session.sessionState.catalogManager.currentCatalog.name val currentCatalog = if (!catalog.name().equals(currentCatalogName)) currentCatalogName else null - val currentNamespace = session.sessionState.catalogManager.currentNamespace + val currentNamespace = ident.namespace() ``` -- 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