You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Vladimir Sitnikov (Jira)" <ji...@apache.org> on 2019/11/28 10:14:00 UTC

[jira] [Commented] (CALCITE-3544) RexSimplify does not simpilfy RexNode completely

    [ https://issues.apache.org/jira/browse/CALCITE-3544?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16984296#comment-16984296 ] 

Vladimir Sitnikov commented on CALCITE-3544:
--------------------------------------------

Please prefer RexProgramBuilderBase APIs to make test code readable: [https://github.com/apache/calcite/blob/fab877bb447a9949fac37b0661acf61ab9f7c6fb/core/src/test/java/org/apache/calcite/test/RexProgramTest.java#L1477-L1481] [88-L290|https://github.com/apache/calcite/blob/fab877bb447a9949fac37b0661acf61ab9f7c6fb/core/src/test/java/org/apache/calcite/test/RexProgramBuilderBase.java#L288-L290]

The current sample is hard to reason about.

> RexSimplify does not simpilfy RexNode completely
> ------------------------------------------------
>
>                 Key: CALCITE-3544
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3544
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 1.21.0
>            Reporter: Chunwei Lei
>            Assignee: Chunwei Lei
>            Priority: Major
>
> When there are multiple predicates in RexSimplify, only the first predicates will be used to simplify the RexNode. The following test can reproduce.
> {code:java}
> // code placeholder
> @Test public void testSimplifyRangeWithMultiPredicates() {
>   RelDataType type = typeFactory.createSqlType(SqlTypeName.INTEGER);
>   final RexLiteral c1 = rexBuilder.makeExactLiteral(BigDecimal.ONE);
>   final RexLiteral c5 = rexBuilder.makeExactLiteral(BigDecimal.valueOf(5L));
>   final RexLiteral c9 = rexBuilder.makeExactLiteral(BigDecimal.valueOf(9L));
>   final RexNode ref = rexBuilder.makeInputRef(type, 1);
>   final RexNode pred1 = rexBuilder.makeCall(SqlStdOperatorTable.GREATER_THAN, ref, c1);
>   final RexNode pred2 = rexBuilder.makeCall(SqlStdOperatorTable.LESS_THAN, ref, c5);
>   List<RexNode> predicates = new ArrayList<>();
>   predicates.add(pred1);
>   predicates.add(pred2);
>   RelOptPredicateList relOptPredicateList = RelOptPredicateList.of(rexBuilder, predicates);
>   RexNode node = rexBuilder.makeCall(SqlStdOperatorTable.GREATER_THAN, ref, c9);
>   final RexSimplify simplify =
>       new RexSimplify(rexBuilder, relOptPredicateList, RexUtil.EXECUTOR)
>           .withParanoid(true);
>   node = simplify.simplify(node);
>   assertThat(node, is(falseLiteral));
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)