You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Yu Xu (Jira)" <ji...@apache.org> on 2026/01/27 02:12:00 UTC
[jira] [Commented] (CALCITE-7398) Incorrect int cast in VariantNonNull#cast for BIGINT
[ https://issues.apache.org/jira/browse/CALCITE-7398?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18054494#comment-18054494 ]
Yu Xu commented on CALCITE-7398:
--------------------------------
Although Jira records version 1.38, I have tested it on main and version 1.41, and the issue does exist.
> Incorrect int cast in VariantNonNull#cast for BIGINT
> ----------------------------------------------------
>
> Key: CALCITE-7398
> URL: https://issues.apache.org/jira/browse/CALCITE-7398
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.38.0
> Reporter: heng qian
> Priority: Major
> Labels: pull-request-available
>
> In `VariantNonNull.java`, the `cast()` method has a bug in the `BIGINT` case at line 289:
> {code:java}
> case BIGINT: {
> long l = (int) value; // Bug: should be (long) value
> ...
> } {code}
> The value field for BIGINT type is stored as Long (verified by the constructor's assertion assert value instanceof Long). However, the code incorrectly casts it to int before assigning to the long variable.
> This causes a variant value with BIGINT runtime type to be null, since the cast function throws exception in this place.
> {code:java}
> java.lang.ClassCastException: class java.lang.Long cannot be cast to class java.lang.Integer (java.lang.Long and java.lang.Integer are in module java.base of loader 'bootstrap'){code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)