HIVE-29570: Fix MERGE rewrite parse failure by correctly quoting qual…#6439
Open
kokila-19 wants to merge 1 commit intoapache:masterfrom
Open
HIVE-29570: Fix MERGE rewrite parse failure by correctly quoting qual…#6439kokila-19 wants to merge 1 commit intoapache:masterfrom
kokila-19 wants to merge 1 commit intoapache:masterfrom
Conversation
e98607c to
8ed71ae
Compare
kasakrisz
reviewed
Apr 20, 2026
Comment on lines
+364
to
+370
| ASTNode parent = (ASTNode) identifier.getParent(); | ||
| if (parent != null | ||
| && (parent.getType() == HiveParser.TOK_FUNCTION | ||
| || parent.getType() == HiveParser.TOK_FUNCTIONDI | ||
| || parent.getType() == HiveParser.TOK_FUNCTIONSTAR) | ||
| && parent.getChildCount() > 0 | ||
| && parent.getChild(0) == identifier) { |
Contributor
There was a problem hiding this comment.
I think this is a good solution.
The alternative would be to
- remove the
IdentifierProcessor - add separate processors for
TOK_TABNAME,TOK_TABLE_OR_COL,TOK_FUNCTIONetc.
The risk of this alternative is that we might miss an AST node.
So let's keep yours.
Contributor
Author
There was a problem hiding this comment.
That’s great. I’ve refactored the code into a helper method to improve readability.
Comment on lines
+29
to
+32
| create table src_table(a int, `date` int) clustered by (a) into 2 buckets stored as orc | ||
| TBLPROPERTIES ('transactional'='true'); | ||
| create table tgt_table(a int, `date` int) clustered by (a) into 2 buckets stored as orc | ||
| TBLPROPERTIES ('transactional'='true'); |
Contributor
There was a problem hiding this comment.
Could you please change one of the table names to a quoted function name.
Contributor
Author
There was a problem hiding this comment.
Updated the table name
8ed71ae to
6ad3ec3
Compare
kasakrisz
approved these changes
Apr 20, 2026
Contributor
kasakrisz
left a comment
There was a problem hiding this comment.
+1
please remove the unused imports from HiveUtils
…ified column names when they are function names(like date)
6ad3ec3 to
004913b
Compare
|
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.



…ified column names when they are function names(like date)
What changes were proposed in this pull request?
During merge rewrite, quote the qualified identifiers when those identifiers are same as function name.
Why are the changes needed?
Hive rewrites a MERGE into a different SQL statement (typically INSERT, SELECT) and then parses the rewritten SQL again.
That rewritten SQL is produced from the AST.
After HIVE-29187, the unparse logic does not quote any identifier that matches a built‑in function name.
So when the rewritten query contains a qualified reference like: s.date the unparse step must regenerate it as: 's' .'date'
Instead, it was 's'.date
Because it was not quoted, it fails to parse when the rewritten query is compiled.
Does this PR introduce any user-facing change?
No
How was this patch tested?
mvn test -pl itests/qtest -Dtest=TestMiniLlapLocalCliDriver -Dqfile=sqlmerge.q -Dtest.output.overwrite=true -Pitests