Repository navigation
DuckDB: accept digit separators in numeric literals - #2797
Merged
manticore-projects merged 2 commits intoOct 13, 2026
Merged
Conversation
`1_000_000`, `92_000.0` and `1e1_0` are numbers in DuckDB and PostgreSQL 16, but MySQL reads `2024_01` as an identifier. The new `Feature.allowDigitSeparators`, enabled by the PostgreSQL dialect, drops the separators from the token image, so every consumer of number tokens keeps working. Without it, lexing is unchanged.
guizmaii
marked this pull request as ready for review
October 13, 2026 08:33
27 tasks
Contributor
|
Good one, thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For DuckDB, which accepts
_between digits in numeric literals (docs), as does PostgreSQL 16.MySQL identifiers may start with digits, so
2024_01is a column or table there. Separators are therefore opt-in:withDigitSeparators()/Dialect.POSTGRESQL1_000Column 1_000LongValue 100092_000.0DoubleValue 92000.01e1_0Column 1e1_0DoubleValue 1e10LIMIT 1_000LIMITcolumn1_000LIMIT 1000FROM 2024_012024_01Feature.allowDigitSeparators(defaultfalse) withwithDigitSeparators();Dialect.POSTGRESQLenables it.Dialect.POSTGRESQLonly:2024_01is nowLongValue 202401instead of a column, as PostgreSQL never allows unquoted digit-led identifiers (PostgreSQL < 16 reads1_000as1 AS _000).S_LONGaccepts_between digits. Under the feature, the lexical action drops the separators from the image, so the ~30 grammar actions that read number tokens (Long.valueOf(token.image), ...) need no change.1_000deparses as1000.2024_01, or.5before_5). The default output is identical to master on the whole DuckDB test suite below.checkGrammarAmbiguity: no conflicts../gradlew check: 10,125 tests, 0 failures.test/sql, 70,729 statements): default mode identical to master; with the feature, 10 more parse, none less.