fix: prevent bare partition columns from inheriting the previous item's value - #2518
Merged
manticore-projects merged 1 commit intoAug 31, 2026
Conversation
…'s value Partitions() shares one production-level valueExpression across list items, so a bare (dynamic) partition column kept the value of the preceding item: PARTITION (dtime = '2024-04-03', region) deparsed as region = '2024-04-03', silently turning a dynamic partition into a static assignment. Reset the variable per item, same idiom as DeclareType, Alias and ColumnsNamesList. Fixes JSQLParser#2500 Signed-off-by: 付典 <fudianchn@gmail.com>
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.
AI disclosure: this change was prepared with AI coding agents, reviewed and revised line by line by me.
What
A bare (dynamic) partition column no longer inherits the value expression of the preceding item in a mixed
INSERT ... PARTITION (...)list; it keepsnullagain, as before #2323.Why
With a static item followed by a bare one, the deparser output silently turned the dynamic column into a constant assignment, changing the statement's semantics for Hive mixed static/dynamic partition writes (#2500).
How
Partitions()declares onevalueExpressionfor the whole production and the optional"=" Expression()unit leaves the previous item's value in place when skipped. The list loop arm now resetsvalueExpression = nullbefore the optional unit, the same idiom already used byDeclareType,AliasandColumnsNamesListfor their list items. No AST, deparser or visitor change:Partitionalready renders a bare column when the value isnull.Root cause
Production-level
valueExpressioninPartitions()is shared across list items and was not reset when an item skipped the optional value (introduced with #2323).Testing
InsertTest#testInsertMixedStaticAndDynamicPartitionscovers the full [BUG] JSQLParser 5.4-SNAPSHOT : Hive : INSERT PARTITION bare column inherits the previous item's value #2500 combination table: static -> bare, bare -> static, static -> bare -> bare, bare -> static -> bare, andINSERT INTOwith a numeric value. All wrong rows fail on master and pass with the change; the two correct rows are pinned as guards. Two mutants verified: removing the reset and misplacing it after the optional unit both turn the test red.gradlew test --tests InsertTest-> 79 passed.performance.sqlcontains noPARTITIONclause, the changed action is not reached by the benchmark.Verification of the original issue
Fixes #2500