-
Notifications
You must be signed in to change notification settings - Fork 28.1k
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
[SPARK-40291][SQL] Improve the message for column not in group by clause error #37742
Conversation
0d92e87
to
b3a0e76
Compare
cc @cloud-fan |
@@ -65,6 +65,12 @@ | |||
], | |||
"sqlState" : "22005" | |||
}, | |||
"COLUMN_NOT_IN_GROUP_BY_CLAUSE" : { | |||
"message" : [ | |||
"expression '<expression>' is neither present in the group by, nor is it an aggregate function. Add to group by or wrap in first() (or first_value) if you don't care which value you get." |
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.
Please, remove '' around and use toSQLExpr(), and first() should be quoted by back ticks.
def columnNotInGroupByClauseError(expression: Expression): Throwable = { | ||
new AnalysisException( | ||
errorClass = "COLUMN_NOT_IN_GROUP_BY_CLAUSE", | ||
messageParameters = Array(expression.sql) |
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.
expression.sql -> toSQLExpr(expression)
@MaxGekk Thanks for reviewing! I updated the PR |
assert( | ||
e.contains("COLUMN_NOT_IN_GROUP_BY_CLAUSE") && | ||
e.contains("\"c1\"")) |
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.
Could you use checkError()
, please. See the check above.
Co-authored-by: Maxim Gekk <max.gekk@gmail.com>
+1, LGTM. Merging to master. |
What changes were proposed in this pull request?
Improve the message for columns not in group by clause error
Why are the changes needed?
Use the new error class framework for columns not in group by clause error
Does this PR introduce any user-facing change?
Yes, adding error class
How was this patch tested?
UT