singhpk234 commented on code in PR #17859:
URL: https://github.com/apache/iceberg/pull/17859#discussion_r3897002956


##########
flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/FlinkCatalog.java:
##########
@@ -683,6 +738,29 @@ static CatalogTable toCatalogTable(Table table) {
     return toCatalogTableWithProps(table, table.properties());
   }
 
+  private CatalogView toCatalogView(View view) {
+    SQLViewRepresentation sqlRepresentation = view.sqlFor(FLINK_DIALECT);
+    Preconditions.checkState(sqlRepresentation != null, "Cannot load SQL for 
view %s", view.name());
+
+    ResolvedSchema resolvedSchema = 
FlinkSchemaUtil.toResolvedSchema(view.schema());
+    org.apache.flink.table.api.Schema schema =
+        
org.apache.flink.table.api.Schema.newBuilder().fromResolvedSchema(resolvedSchema).build();
+
+    Map<String, String> options = Maps.newHashMap(view.properties());
+    String comment = options.remove(ViewProperties.COMMENT);
+
+    ViewVersion currentVersion = view.currentVersion();
+    String defaultCatalog =
+        currentVersion.defaultCatalog() != null ? 
currentVersion.defaultCatalog() : getName();
+    options.put(DEFAULT_CATALOG_OPTION, defaultCatalog);
+    options.put(DEFAULT_NAMESPACE_OPTION, 
currentVersion.defaultNamespace().toString());
+
+    // both original and expanded query hold the stored SQL: Flink expands the 
query itself,
+    // resolving unqualified references against the view's own catalog and 
database
+    return CatalogView.of(
+        schema, comment, sqlRepresentation.sql(), sqlRepresentation.sql(), 
options);

Review Comment:
   can you please elaborate this a bit more, defaultCatalog / defaultNamespace 
should only be used for references inside the view sql ... for the whole view 
itself the current catalog and namespace should already have been resolved ?



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