github-actions[bot] commented on code in PR #70370:
URL: https://github.com/apache/doris/pull/70370#discussion_r4663160818


##########
fe/fe-connector/fe-connector-iceberg/src/main/java/org/apache/doris/connector/iceberg/IcebergConnectorMetadata.java:
##########
@@ -405,14 +413,19 @@ public ConnectorViewDefinition 
getViewDefinition(ConnectorSession session, Strin
                 // uses Doris as the preference; Iceberg falls back to the 
first SQL if it has no match.
                 String preferredDialect = engineName == null || 
engineName.isEmpty()
                         ? "doris" : engineName.toLowerCase(Locale.ROOT);
-                SQLViewRepresentation sqlViewRepresentation = 
icebergView.sqlFor(preferredDialect);
+                SQLViewRepresentation sqlViewRepresentation = 
selectViewSql(viewVersion, preferredDialect);
                 if (sqlViewRepresentation == null) {
                     throw new DorisConnectorException(String.format(
                             "Cannot get SQL representation for Iceberg view 
'%s.%s'", dbName, viewName));
                 }
                 String dialect = 
sqlViewRepresentation.dialect().toLowerCase(Locale.ROOT);
-                List<ConnectorColumn> columns = 
parseSchema(icebergView.schema());
-                return new 
ConnectorViewDefinition(sqlViewRepresentation.sql(), dialect, columns);
+                Schema schema = 
icebergView.schemas().get(viewVersion.schemaId());
+                if (schema == null) {
+                    throw new DorisConnectorException("Cannot get schema for 
view '" + dbName + "." + viewName + "'");
+                }
+                List<ConnectorColumn> columns = parseSchema(schema);
+                return new 
ConnectorViewDefinition(sqlViewRepresentation.sql(), dialect, columns,
+                        viewVersion.defaultCatalog(), 
Arrays.asList(viewVersion.defaultNamespace().levels()));

Review Comment:
   [P2] Map saved namespaces to the connector's visible database
   
   Returning the physical namespace verbatim breaks previously valid views when 
`external_catalog.name` is configured. For example, set it to `cat`, leave 
nested-namespace recursion disabled, and put `t(x)` and view `v` in physical 
namespace `['cat', 'cat']`, with no saved default catalog and this body:
   
   ```text
   Query(doris_catalog.cat.v)
     View(defaultNamespace=['cat', 'cat'])
       Project(x)
         UnboundRelation(t)
   ```
   
   `listNestedNamespaces` exposes that namespace as Doris database `cat`, and 
`toNamespace("cat")` correctly resolves `['cat', 'cat']`. This new definition 
instead makes `BindRelation` enter database `cat.cat`, so binding `t` fails 
because that database is not listed (and a forced lookup would append another 
`cat`). The previous owning-database default resolved `t` successfully. 
Translate the saved namespace through the connector's configured database 
projection before handing it to generic binding, and cover 
`external_catalog.name` in the view regression.



-- 
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]

Reply via email to