danny0405 commented on a change in pull request #1811: [CALCITE-3789] Support 
validation of UNNEST multiple array columns like Presto
URL: https://github.com/apache/calcite/pull/1811#discussion_r390741417
 
 

 ##########
 File path: 
core/src/main/java/org/apache/calcite/sql/validate/DelegatingScope.java
 ##########
 @@ -298,7 +298,11 @@ public SqlQualified fullyQualify(SqlIdentifier 
identifier) {
       for (; i > 0; i--) {
         final SqlIdentifier prefix = identifier.getComponent(0, i);
         resolved.clear();
-        resolve(prefix.names, nameMatcher, false, resolved);
+        resolve(
+            prefix.names,
+            nameMatcher,
+            validator.getConformance().allowAliasUnnestArrayColumns(),
+            resolved);
 
 Review comment:
   The current fix seems not right, the nested field can be seen if we set up 
the record type to `StructKind.PEEK_FIELDS`, for the test cases you gave:
   ```java
   sql("select e.ENAME\n"
           + "from dept_nested as d CROSS JOIN\n"
           + " UNNEST(d.employees) as t(e)")
         .withConformance(SqlConformanceEnum.PRESTO).columnType("VARCHAR(10) 
NOT NULL");
   ```
   There `t(e)` table has record type with `e` as field, the `e` can be seen 
and if you change the nested employee type with  code snippet:
   ```java
   final RelDataType empRecordType = typeFactory.builder()
         .add("EMPNO", intType)
         .add("ENAME", varchar10Type)
         .add("DETAIL", typeFactory.builder()
             .add("SKILLS", array(skillRecordType)).build())
         .kind(StructKind.PEEK_FIELDS) // here is the line you can tweak
         .build();
   ```
   
   So, in total, this line change is not necessary, the field access should not 
be controlled by the `SqlConformance`.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to