feat(parser): model ColDataType precision and scale as structured properties - #2539
Merged
manticore-projects merged 1 commit intoSep 4, 2026
Conversation
…perties
ColDataType exposed type parameters in three different shapes depending on
the grammar path: keyword types fold them into the dataType string
("VARCHAR (255)"), identifier types keep them in argumentsStringList
(mediumint(9) -> ["9"]), and zoned types embed them in the lexer token
image ("TIMESTAMP(3) WITH TIME ZONE"). A consumer that needs the precision
has to re-parse the string, with a different pattern per shape.
Populate structured precision and scale on all three paths. The rendered
dataType string, toString(), equals() and hashCode() are unchanged; the
hand-built object trees in DeclareStatementTest gain the new state.
Contributor
|
Thank you much! |
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.
Summary
precisionandscalestate toColDataType, populated on every grammar pathgetDataType(),toString(),equals()andhashCode()unchanged, so deparsing and existing consumers are unaffectedColDataTypecurrently exposes type parameters in three different shapes depending on which grammar path produced it:getDataType()getArgumentsStringList()VARCHAR(255)"VARCHAR (255)"nullMEDIUMINT(9)"MEDIUMINT"["9"]TIMESTAMP(3) WITH TIME ZONE"TIMESTAMP(3) WITH TIME ZONE"nullKeyword types fold the parameters into the type string (inserting a space), identifier types keep them in the arguments list, and zoned types embed them in the lexer token image. A consumer that needs the precision has to regex the string, with a different pattern per shape. The new accessors return the parameters uniformly:
The string-based behavior stays untouched for compatibility. The hand-built expected object trees in
DeclareStatementTestwere extended with the new state, sinceassertEqualsObjectTreecompares all fields reflectively.Testing
./gradlew checkpasses (checkstyle, PMD, spotless, spotbugs, JaCoCo)0 errors and 11 warnings, identical tomaster— no new choice conflictsColDataTypeTestpingetPrecision()/getScale()for the three shapes above, plus the no-parameter,DECIMAL(10, 2),VARCHAR(MAX)andENUM(...)casesAI assistance
AI tooling assisted with the implementation and test coverage. The changes were manually reviewed and verified against MySQL and PostgreSQL syntax.