dssysolyatin commented on code in PR #4553:
URL: https://github.com/apache/calcite/pull/4553#discussion_r2431662069


##########
core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java:
##########
@@ -2204,6 +2208,25 @@ protected void inferUnknownTypes(
     }
   }
 
+  private boolean isRowSqlNodeList(final RelDataType inferredType, final 
SqlNodeList nodeList) {
+    return inferredType.isStruct() && !nodeList.isEmpty()
+        && SqlKind.ROW == nodeList.get(0).getKind();

Review Comment:
   The main point of my comment is that checking only the first element isn’t 
enough (for example, the first element could be a function that returns a 
`ROW`, and the second could be a `ROW` constructor). The query I mentioned is 
definitely a separate issue, thanks for creating jira ticket!
   
   Now, you have two `for` loops that can be merged into one function 
`inferRowSqlNodeList`
   ```java
    private void inferRowSqlNodeList(final RelDataType inferredType,
     final SqlValidatorScope scope, final SqlNodeList nodeList) {
     if (!inferredType.isStruct()) {
       return false;
     }
   
     for (SqlNode child: nodeList) {
       if (child instanceof SqlBasicCall && SqlKind.ROW == sqlNode.getKind()) {
         List <SqlNode> operands = ((SqlBasicCall) child).getOperandList();
         for (int index = 0; index < operands.size(); index++) {
           RelDataType type = inferredType.getFieldList().get(index).getType();
           inferUnknownTypes(type, scope, operands.get(index));
         }
       }
     }
   }
     ```
   



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