snuyanzin commented on code in PR #27096:
URL: https://github.com/apache/flink/pull/27096#discussion_r2418703217


##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/operations/converters/SqlNodeConvertUtils.java:
##########
@@ -85,11 +85,7 @@ static CatalogView toCatalogView(
                 context.getSqlValidator().getNamespace(validateQuery);
         validateDuplicatedColumnNames(query, viewFields, validatedNamespace);
 
-        // The LATERAL operator was eliminated during sql validation, thus the 
unparsed SQL
-        // does not contain LATERAL which is problematic,
-        // the issue was resolved in CALCITE-4077
-        // (always treat the table function as implicitly LATERAL).
-        String expandedQuery = context.expandSqlIdentifiers(originalQuery);
+        String expandedQuery = context.toQuotedSqlString(query);

Review Comment:
   about 
   > So LATERAL was the only problem.
   
   Based on comments in corresponding related jira 
https://issues.apache.org/jira/browse/FLINK-18750#comment-17168834
   short answer: yes, `LATERAL` was the only root cause for this change
   
   also more detailed:
   the first commit with such comment and logic I believe  came here 
https://github.com/apache/flink/commit/69fa07ec5c11c59499fc79a03323228e373ca0a9#diff-3aeeb4c53fea845484a61b0a5672e5b8abebdabb3d82efc7f7a1a852448f8b9bR720-R728
 in this PR https://github.com/apache/flink/pull/13050
   
   before that the code looked like 
   ```java
   ...
   String originalQuery = getQuotedSqlString(query);
   String expandedQuery = getQuotedSqlString(validateQuery);
   PlannerQueryOperation operation = toQueryOperation(flinkPlanner, 
validateQuery);
   TableSchema schema = operation.getTableSchema();
   ...
   ```
   so expanded was calculated from validated.
   
   Also there was added a test for views with `LATERAL` which is present so far 
in the repo
   
https://github.com/apache/flink/blob/48aed8418d6ab27b6dc12b101d3f438ff9005d9c/flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/plan/common/ViewsExpandingTest.scala#L117-L133



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

Reply via email to