-
Notifications
You must be signed in to change notification settings - Fork 4.7k
HIVE-28917: NPE in merge statement when checking nullability of joini… #5781
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
merge into target as t using source as s on t.a = s.a | ||
when matched and t.a is null then delete; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From a SQL perspective the query is perfectly valid so there is no reason to throw an error or exception. The query is probably useless cause indeed the when matched and t.a is null
is always false but this is not a SQL error. The expected result is to simply leave the target table unchanged.
|
||
int tokFromIdx = query.getFirstChildWithType(HiveParser.TOK_FROM).getChildIndex(); | ||
ASTNode from = (ASTNode) query.getFirstChildWithType(HiveParser.TOK_FROM); | ||
assert from != null : "Couldn't find a child of type FROM in the AST"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assertions should never be used for user-level errors. Despite the fact that they are disabled in production environments (and thus a user will never encounter) stack-traces and other information associated with the assertion/exception are for developers to help diagnose and fix a problem. Problems with the SQL syntax should be user-level errors with appropriate error codes and localization.
However, as I mentioned previously the MERGE
statement addressed here is valid SQL so it shouldn't lead to failures or exceptions of any kind.
…ng column in matched clause
5efdfe4
to
ef385f5
Compare
|
…ng column in matched clause
What changes were proposed in this pull request?
When TOK_FROM is not present in the AST for MERGE statements, return
DestClausePrefix.MERGE
.Why are the changes needed?
Without this we could get an NPE as explained in HIVE-28917
Does this PR introduce any user-facing change?
No
How was this patch tested?