-
Notifications
You must be signed in to change notification settings - Fork 28.5k
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-3371][SQL] Renaming a function expression with group by gives error #2511
Conversation
… error Signed-off-by: ravipesala <[email protected]>
Can one of the admins verify this patch? |
ok to test |
QA tests have started for PR 2511 at commit
|
QA tests have finished for PR 2511 at commit
|
Test PASSed. |
@@ -166,7 +186,7 @@ class SqlParser extends StandardTokenParsers with PackratParsers { | |||
val withFilter = f.map(f => Filter(f, base)).getOrElse(base) | |||
val withProjection = | |||
g.map {g => | |||
Aggregate(assignAliases(g), assignAliases(p), withFilter) | |||
Aggregate(assignAliasesForGroups(g,p), assignAliases(p), withFilter) |
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.
A simpler solution is to just not assignAliases to the grouping expressions (I'm not sure why we are. That is probably my mistake). That change also seems to also make your test case pass.
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.
Yes @marmbrus , better we remove assignAliases to grouping expressions.Updated code as per that. Please review.
QA tests have started for PR 2511 at commit
|
QA tests have finished for PR 2511 at commit
|
Test PASSed. |
Thanks! Merged to master. |
The following code gives error.
Because SQl parser creates the aliases to the functions in grouping expressions with generated alias names. So if user gives the alias names to the functions inside projection then it does not match the generated alias name of grouping expression.
This kind of queries are working in Hive.
So the fix I have given that if user provides alias to the function in projection then don't generate alias in grouping expression,use the same alias.