Skip to content

Databricks, Hive: parse 1L as a long literal - #2771

Open
moshap-firebolt wants to merge 2 commits into
apache:mainfrom
moshap-firebolt:databricks-long-literal
Open

moshap-firebolt wants to merge 2 commits into
apache:mainfrom
moshap-firebolt:databricks-long-literal

Conversation

@moshap-firebolt

@moshap-firebolt moshap-firebolt commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Databricks and Hive both write a BIGINT literal with an L suffix (Databricks, Hive), but both dialects read it as an identifier:

SELECT 1L
-- Databricks, Hive: Identifier(Ident { value: "1L", .. })

Their numeric-prefix rule, which allows table names like 59901_user_login, runs before the tokenizer looks for the suffix. Hive's long_numerics test passed only because the identifier 1L prints back unchanged.

This adds Dialect::supports_long_suffix_before_numeric_prefix, enabled for both: an L that ends the number makes it a long, and 1La is still an identifier. MySQL, which has a numeric prefix but no long literal, keeps reading 1L as an identifier. As elsewhere in the tokenizer, only an uppercase L is a suffix. Databricks DIV, CREATE TABLE ... USING and LONG are left to #2425.

Tests in sqlparser_common.rs cover dialects with and without the method; they fail without the change.

This PR was prepared with AI assistance (Claude).

Dialects: Databricks, Hive

@codecov-commenter

codecov-commenter commented Oct 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.62%. Comparing base (c6cec56) to head (d9a8008).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2771      +/-   ##
==========================================
+ Coverage   82.60%   82.62%   +0.01%     
==========================================
  Files          42       42              
  Lines       35607    35627      +20     
  Branches    35607    35627      +20     
==========================================
+ Hits        29414    29436      +22     
  Misses       2659     2659              
+ Partials     3534     3532       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

moshap-firebolt and others added 2 commits October 30, 2026 13:03
Both dialects read `1L` as an identifier, since the numeric-prefix rule
(tables named `59901_user_login`) ran before the long suffix. A new
dialect method, supports_long_suffix_before_numeric_prefix, lets an `L`
that ends the number win; `1La` is still an identifier. MySQL, which has
no long literal, keeps reading `1L` as an identifier.

Co-authored-by: Claude Opus 5.5 <[email protected]>
@moshap-firebolt
moshap-firebolt force-pushed the databricks-long-literal branch from ccf327d to d9a8008 Compare October 30, 2026 20:29
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.

3 participants