Skip to content

[CALCITE-2438] RexCall#isAlwaysTrue return incorrect result#778

Closed
jiayuanv127 wants to merge 10 commits intoapache:masterfrom
jiayuanv127:master
Closed

[CALCITE-2438] RexCall#isAlwaysTrue return incorrect result#778
jiayuanv127 wants to merge 10 commits intoapache:masterfrom
jiayuanv127:master

Conversation

@jiayuanv127
Copy link

No description provided.

Copy link
Contributor

@vlsi vlsi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See in-line comments, and please add more tests if you want to get this PR committed.

  1. You have only positive tests. Please add negative tests as well (e.g. to ensure IS_FALSE can produce isAlwaysTrue at all)

  2. You have changed the logic for IS_NOT_TRUE, and you have added zero cases for that.
    Please either revert unintended changes or cover the changes with tests.

final RelDataType booleanNullableType =
typeFactory.createTypeWithNullability(
typeFactory.createSqlType(SqlTypeName.BOOLEAN), true);
RexNode node = rexBuilder.makeInputRef(booleanNullableType, 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am sure it makes no sense to clutter test code with boiler-plate creation of RelDataType and inputrefs

typeFactory.createSqlType(SqlTypeName.BOOLEAN), true);
RexNode node = rexBuilder.makeInputRef(booleanNullableType, 0);

RexNode exp1 = rexBuilder.makeCall(SqlStdOperatorTable.IS_FALSE, isNotNull(isNull(node)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IS_FALSE should be refactored to a method like isNull for consistency and test brevity

RexNode node = rexBuilder.makeInputRef(booleanNullableType, 0);

RexNode exp1 = rexBuilder.makeCall(SqlStdOperatorTable.IS_FALSE, isNotNull(isNull(node)));
assertEquals(exp1.isAlwaysTrue(), false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use message parameter for assertEquals or other means to make exception message clear.

Current one would be like "expected false, got true at line 2180.
It would be extremely hard to maintain if ever this test goes off the rails.

The same applies to all assertEquals in this test

return rexBuilder.makeCall(SqlStdOperatorTable.IS_TRUE, node);
}

private RexNode isNotTrue(RexNode node) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please co-locate is*True/False methods? It looks like isNotFalse is declared elsewhere

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I have added the isNotFalse method after isNotTrue.

RexNode inputRef = rexBuilder.makeInputRef(type, 0);

RexNode isFalseExp = isFalse(isNotNull(isNull(inputRef)));
assertEquals("isAlwaysTrue should return false,but get true",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make the test fail (e.g. by replacing isAlwaysTrue with a simple return false), then see how the test reports the problem.
Would you be able to tell the nature of the issue from the error message/stacktrace then?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for you suggestion,I have make a change to make the error message more clear.

julianhyde pushed a commit to julianhyde/calcite that referenced this pull request Aug 7, 2018
…pzw)

Make tests also call RexSimplify (Julian Hyde)

Close apache#778
@jiayuanv127 jiayuanv127 closed this Aug 9, 2018
kgyrtkirk pushed a commit to kgyrtkirk/calcite that referenced this pull request Oct 4, 2018
…pzw)

Make tests also call RexSimplify (Julian Hyde)

Close apache#778
julianhyde pushed a commit to julianhyde/calcite that referenced this pull request Oct 6, 2018
F21 pushed a commit to F21/calcite that referenced this pull request Jan 3, 2019
wangxlong pushed a commit to wangxlong/calcite that referenced this pull request Feb 13, 2020
jamesstarr pushed a commit to jamesstarr/calcite that referenced this pull request Aug 28, 2025
… (Zoltan Haindrich)

closes apache#778
closes apache#875

Change-Id: I98c63b904f2c0164b37e6b0b2a147f8353102a69
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants