soma-mondal commented on a change in pull request #1437: [CALCITE-3318] 
Preserving CAST of STRING operands in comparison operator
URL: https://github.com/apache/calcite/pull/1437#discussion_r335344796
 
 

 ##########
 File path: 
core/src/main/java/org/apache/calcite/sql/dialect/BigQuerySqlDialect.java
 ##########
 @@ -89,6 +94,22 @@ public BigQuerySqlDialect(SqlDialect.Context context) {
     return emulateNullDirectionWithIsNull(node, nullsFirst, desc);
   }
 
+  @Override public boolean castRequiredForStringOperand(RexCall node) {
+    if (super.castRequiredForStringOperand(node)) {
+      return true;
+    }
+    RexNode operand = node.getOperands().get(0);
+    RelDataType castType = node.type;
+    if (operand instanceof RexLiteral) {
+      if (SqlTypeFamily.NUMERIC.contains(castType)) {
+        return true;
+      }
+      return false;
+    } else {
+      return true;
+    }
 
 Review comment:
   Looks good. Will do the change. Thank you for pointing it out. 

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