somu-imply commented on code in PR #13576:
URL: https://github.com/apache/druid/pull/13576#discussion_r1081616136


##########
sql/src/main/java/org/apache/druid/sql/calcite/expression/Expressions.java:
##########
@@ -214,12 +217,43 @@ public static DruidExpression 
toDruidExpressionWithPostAggOperands(
       return rexCallToDruidExpression(plannerContext, rowSignature, rexNode, 
postAggregatorVisitor);
     } else if (kind == SqlKind.LITERAL) {
       return literalToDruidExpression(plannerContext, rexNode);
+    } else if (kind == SqlKind.FIELD_ACCESS) {
+      return fieldAccessToDruidExpression(rowSignature, rexNode);
     } else {
       // Can't translate.
       return null;
     }
   }
 
+  private static DruidExpression fieldAccessToDruidExpression(
+      final RowSignature rowSignature,
+      final RexNode rexNode
+  )
+  {
+    // Translate field references.
+    final RexFieldAccess ref = (RexFieldAccess) rexNode;
+    // This case arises in the case of a correlation where the rexNode points 
to a table from the left subtree
+    // while the underlying datasource is the scan stub created from 
LogicalValuesRule
+    // In such a case we throw a CannotBuildQueryException so that Calcite 
does not go ahead with this path
+    // This exception is caught while returning false from isValidDruidQuery() 
method

Review Comment:
   Moving this to inside of the if



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