[
https://issues.apache.org/jira/browse/CALCITE-7542?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Mihai Budiu resolved CALCITE-7542.
----------------------------------
Fix Version/s: 1.43.0
Resolution: Fixed
Fixed in
[https://github.com/apache/calcite/commit/3294cd1b27787ed5b506cee89c83719aed266948]
Thank you for the fix [~sbroeder]
> RexCall.isAlwaysTrue()/isAlwaysFalse() incorrectly returns true for
> CAST(boolean AS non-boolean)
> ------------------------------------------------------------------------------------------------
>
> Key: CALCITE-7542
> URL: https://issues.apache.org/jira/browse/CALCITE-7542
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.41.0
> Reporter: Sean Broeder
> Assignee: Sean Broeder
> Priority: Minor
> Labels: pull-request-available
> Fix For: 1.43.0
>
>
> RexCall.isAlwaysTrue() and isAlwaysFalse() delegate to the operand for any
> CAST expression, without checking whether the result type is BOOLEAN. This
> means CAST(TRUE AS INTEGER) — an INTEGER expression — incorrectly reports
> isAlwaysTrue() == true.
> Root cause
> In RexCall.isAlwaysTrue(), the CAST case falls through to return
> operands.get(0).isAlwaysTrue() with no type guard. The fix is to only
> delegate when getType().getSqlTypeName() == SqlTypeName.BOOLEAN.
> Reproduction (unit test)
> RexNode castTrueToInt = rexBuilder.makeAbstractCast(intType, trueLiteral);
> // CAST(TRUE AS INTEGER) is an INTEGER — isAlwaysTrue() must be false
> assertThat(castTrueToInt.isAlwaysTrue(), is(false)); // FAILS: returns true
--
This message was sent by Atlassian Jira
(v8.20.10#820010)