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


##########
sql/src/main/java/org/apache/druid/sql/calcite/rule/DruidFilterUnnestRule.java:
##########
@@ -94,9 +95,15 @@ public static DruidProjectOnUnnestRule instance()
     public boolean matches(RelOptRuleCall call)
     {
       final Project rightP = call.rel(0);
-      final SqlKind rightProjectKind = rightP.getChildExps().get(0).getKind();
-      // allow rule to trigger only if there's a string CAST or numeric 
literal cast
-      return rightP.getProjects().size() == 1 && (rightProjectKind == 
SqlKind.CAST || rightProjectKind == SqlKind.LITERAL);
+      if (rightP.getChildExps().size() > 0) {
+        final SqlKind rightProjectKind = 
rightP.getChildExps().get(0).getKind();
+        final SqlTypeName rightType = 
rightP.getChildExps().get(0).getType().getSqlTypeName();
+        // allow rule to trigger only if there's a non-decimal CAST or numeric 
literal cast
+        return rightP.getProjects().size() == 1 && ((rightProjectKind == 
SqlKind.CAST
+                                                     && rightType != 
SqlTypeName.DECIMAL)
+                                                    || rightProjectKind == 
SqlKind.LITERAL);

Review Comment:
   Fixed this to allow only if we cast from same datatype to same datatype. We 
have tests covering for string, float etc



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