[
https://issues.apache.org/jira/browse/CALCITE-1769?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16003811#comment-16003811
]
slim bouguerra commented on CALCITE-1769:
-----------------------------------------
[~jcamachorodriguez]
Looked at the way the tree gets parsed by hive and find out the expression is
not getting folded.
In nutshell hive relies
{code}
org.apache.calcite.rel.rules.ReduceExpressionsRule#reduceExpressions(org.apache.calcite.rel.RelNode,
java.util.List<org.apache.calcite.rex.RexNode>,
org.apache.calcite.plan.RelOptPredicateList, boolean) {code}
to fold expressions. But this is not folding the cast expression
{code} <(CAST($5):DOUBLE, CAST(5):DOUBLE){code}
Looking at the code path you can see that this cast is not folded do to this
check
{code} private void addResult(RexNode exp) {
// Cast of literal can't be reduced, so skip those (otherwise we'd
// go into an infinite loop as we add them back).
if (exp.getKind() == SqlKind.CAST) {
RexCall cast = (RexCall) exp;
RexNode operand = cast.getOperands().get(0);
if (operand instanceof RexLiteral) {
return;
}
}
{code}
>From class {code}
>org.apache.calcite.rel.rules.ReduceExpressionsRule.ReducibleExprLocator#addResult
> {code}
The reason is not folding it, is some how still not clear to me.
As you can see the comments states that we are not suppose to fold an
expression that has a cast over literal which seems counter intuitive, so not
sure what i am missing.
Can you guys ([~julianhyde] and [~jcamachorodriguez]) explain to me how we can
fold such cast ?
> Push Filters down to druid when there a cast to numeric
> -------------------------------------------------------
>
> Key: CALCITE-1769
> URL: https://issues.apache.org/jira/browse/CALCITE-1769
> Project: Calcite
> Issue Type: Bug
> Components: druid
> Reporter: slim bouguerra
> Assignee: Julian Hyde
> Fix For: 1.13.0
>
>
> Currently if we have cast to numeric over literal filter will not get pushed.
> For instance query like {code}SELECT page from druid_table_1 WHERE page < 5
> group by page {code} from hive will introduce a cast over `5`.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)