You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2026/05/22 00:27:00 UTC
[jira] [Updated] (CALCITE-7542) RexCall.isAlwaysTrue()/isAlwaysFalse() incorrectly returns true for CAST(boolean AS non-boolean)
[ https://issues.apache.org/jira/browse/CALCITE-7542?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
ASF GitHub Bot updated CALCITE-7542:
------------------------------------
Labels: pull-request-available (was: )
> 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
>
> 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)