somu-imply commented on code in PR #13976:
URL: https://github.com/apache/druid/pull/13976#discussion_r1152300563
##########
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:
Queries such as `select sum(c) col from druid.numfoo,
unnest(mv_to_array(dim3)) as u(c)` will need to cast string to decimal that
will appear as a logical project on top of the unnest rel. We do not want this
rule to be triggered if this is such a case.
--
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]