You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2022/06/15 15:17:05 UTC

[GitHub] [calcite] rubenada commented on a diff in pull request #2791: [CALCITE-5134] Queries with subquery inside select list does not work if subquery uses table from left join

rubenada commented on code in PR #2791:
URL: https://github.com/apache/calcite/pull/2791#discussion_r898113844


##########
core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java:
##########
@@ -4883,7 +4883,14 @@ void setRoot(List<RelNode> inputs) {
           int i = 0;
           int offset = 0;
           for (SqlValidatorNamespace c : ancestorScope1.getChildren()) {
-            builder.addAll(c.getRowType().getFieldList());
+            final boolean isNullable = ancestorScope1.children.get(i).isNullable();

Review Comment:
   Thanks for the PR @libenchao .
   I'm not the most expert on the impacted classes, but I guess some people might frown upon making `ScopeChild` public just for this fix. What about...
   - Leaving `ScopeChild` unchanged
   - Add a new method in `ListScope`:
   ```
     public boolean isChildNullable(int i) {
       return children.get(i).nullable;
     }
   ```
   - Changing the `if` condition on the `SqlToRelConverter` fix code to use this method:
   ```
   for (SqlValidatorNamespace c : ancestorScope1.getChildren()) {
     if (ancestorScope1.isChildNullable(i)) {
       for (final RelDataTypeField f : c.getRowType().getFieldList()) {
         builder.add(f.getName(), typeFactory.createTypeWithNullability(f.getType(), true));
       }
     } else {
       builder.addAll(c.getRowType().getFieldList());
     }
     ...
   ```              
   In my opinion, it would be a slightly cleaner solution than the current proposal, WDYT?



-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org