Skip to content

Handle the sql type named LONG as an alias for BIGINT#18789

Closed
zhan7236 wants to merge 2 commits into
apache:masterfrom
zhan7236:fix-long-as-bigint-alias
Closed

Handle the sql type named LONG as an alias for BIGINT#18789
zhan7236 wants to merge 2 commits into
apache:masterfrom
zhan7236:fix-long-as-bigint-alias

Conversation

@zhan7236
Copy link
Copy Markdown
Contributor

Description

This PR adds support for using LONG as an alias for BIGINT in SQL CAST expressions. Users who are familiar with Druid's native engine often use LONG as a type name, but the SQL parser previously did not recognize it, resulting in an error.

After this change, the following SQL will work correctly:

SELECT CAST(column_name AS LONG) FROM table

This is equivalent to:

SELECT CAST(column_name AS BIGINT) FROM table

Motivation

People using the native engine may write CAST(some AS LONG) because they are accustomed to working with those types. However, the SQL parser didn't know that type and returned an error. This change handles LONG as an alias to BIGINT for better user experience.

Fixes #17425

Changes

  • config.fmpp: Added LONG to the keywords list.
  • Parser.jj: Modified SqlTypeName1 rule to accept LONG as an alias for BIGINT (similar to how INT is an alias for INTEGER).
  • CalciteQueryTest.java: Added test case testCastAsLongAliasBigint() to verify the new functionality.

Testing

  • Added unit test testCastAsLongAliasBigint() that verifies CAST(dim1 AS LONG) = 2 produces the same query plan as CAST(dim1 AS BIGINT) = 2.

Checklist

  • I have read the contribution guidelines
  • My code follows the existing coding style
  • I have added tests that prove my fix is effective
  • This PR is based on the latest master branch

This change allows users to write CAST(x AS LONG) in SQL queries,
which is treated as equivalent to CAST(x AS BIGINT). This is useful
for users migrating from the native engine who are accustomed to
working with LONG types.

Changes:
- Add LONG keyword to the parser configuration
- Modify SqlTypeName1 rule to accept LONG as an alias for BIGINT
- Add test case to verify CAST AS LONG works correctly

Fixes apache#17425
@zhan7236 zhan7236 force-pushed the fix-long-as-bigint-alias branch from a26fd53 to 93486d2 Compare December 3, 2025 02:12
@github-actions
Copy link
Copy Markdown

This pull request has been marked as stale due to 60 days of inactivity.
It will be closed in 4 weeks if no further activity occurs. If you think
that's incorrect or this pull request should instead be reviewed, please simply
write any comment. Even if closed, you can still revive the PR at any time or
discuss it on the dev@druid.apache.org list.
Thank you for your contributions.

@github-actions github-actions Bot added the stale label Feb 15, 2026
@github-actions
Copy link
Copy Markdown

This pull request/issue has been closed due to lack of activity. If you think that
is incorrect, or the pull request requires review, you can revive the PR at any time.

@github-actions github-actions Bot closed this Mar 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Handle the sql type named LONG

1 participant