nastra commented on code in PR #17128:
URL: https://github.com/apache/iceberg/pull/17128#discussion_r3542808151
##########
spark/v4.1/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestViews.java:
##########
@@ -774,6 +774,34 @@ public void renameView() throws NoSuchTableException {
.containsExactlyInAnyOrderElementsOf(expected);
}
+ @TestTemplate
+ public void renameQualifiedViewToUnqualifiedTargetKeepsSourceNamespace() {
+ Namespace sourceNamespace = Namespace.of(viewName("rename_source_ns"));
+ Namespace currentNamespace = Namespace.of(viewName("rename_current_ns"));
+ String viewName = viewName("originalView");
+ String renamedView = viewName("renamedView");
+ String sql = String.format("SELECT id FROM %s.%s.%s", catalogName,
NAMESPACE, tableName);
+
+ sql("CREATE NAMESPACE IF NOT EXISTS %s.%s", catalogName, sourceNamespace);
+ sql("CREATE NAMESPACE IF NOT EXISTS %s.%s", catalogName, currentNamespace);
+
+ ViewCatalog viewCatalog = viewCatalog();
+ viewCatalog
+ .buildView(TableIdentifier.of(sourceNamespace, viewName))
+ .withQuery("spark", sql)
+ .withDefaultNamespace(sourceNamespace)
+ .withDefaultCatalog(catalogName)
+ .withSchema(schema(sql))
+ .create();
+
+ sql("USE %s.%s", catalogName, currentNamespace);
+ sql("ALTER VIEW %s.%s RENAME TO %s", sourceNamespace, viewName,
renamedView);
Review Comment:
it seems a bit counter-intuitive to resolve this against the target
namespace instead of resolving against the current namespace? I don't think we
have other places where we would have a similar resolution strategy? Typically
providing only the plain identifier should always resolve to whatever
catalog/namespace is currently configured
--
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]