[
https://issues.apache.org/jira/browse/CALCITE-3525?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16979061#comment-16979061
]
Igor Guzenko commented on CALCITE-3525:
---------------------------------------
Hello [~julianhyde],
1. To be concrete the issue is more related to ITEM and I believe other
function calls as well. Simplifier works fine for {code}(b > 4 and b < 3 and a
= 3){code} where *b* is input ref, but in case from description *b* is rex call
to ITEM operator. I think the term should be evaluated to false for
deterministic functions with same arguments.
2. Regarding parentheses I'll definitely align them, otherwise checkstyle will
bite me.
> RexSimplify: eliminate redundant rex calls in OR
> ------------------------------------------------
>
> Key: CALCITE-3525
> URL: https://issues.apache.org/jira/browse/CALCITE-3525
> Project: Calcite
> Issue Type: Improvement
> Reporter: Igor Guzenko
> Assignee: Igor Guzenko
> Priority: Major
>
> Sample case to reproduce in {code}RexProgramTest.simplifyOrTerms{code}:
> {code:java}
> // (a=1 or a=2 or (arr[1]>4 and arr[1]<3 and a=3)) => a=1 or a=2
> final RelDataType intArrayType = typeFactory.createArrayType(intType, -1);
> final RexInputRef ref0 = rexBuilder.makeInputRef(intType, 0);
> final RexInputRef ref3 = rexBuilder.makeInputRef(intArrayType, 3);
> final RexCall itm1 = (RexCall) rexBuilder.makeCall(intType,
> SqlStdOperatorTable.ITEM,
> ImmutableList.of(ref3, literal1));
> simplify = this.simplify.withParanoid(false);
> checkSimplifyFilter(
> or(
> eq(ref0, literal1),
> eq(ref0, literal2),
> and(
> gt(itm1, literal4),
> lt(itm1, literal3),
> eq(ref0, literal3)
> )
> ),
> "OR(=($0, 1), =($0, 2))"
> );
> simplify = simplify.withParanoid(true);
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)