-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-27117][SQL] current_date/current_timestamp should not refer to columns with ansi parser mode #24039
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-27117][SQL] current_date/current_timestamp should not refer to columns with ansi parser mode #24039
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1212,6 +1212,21 @@ class AstBuilder(conf: SQLConf) extends SqlBaseBaseVisitor[AnyRef] with Logging | |
| } | ||
| } | ||
|
|
||
| override def visitCurrentDatetime(ctx: CurrentDatetimeContext): AnyRef = { | ||
| if (conf.ansiParserEnabled) { | ||
| ctx.name.getType match { | ||
| case SqlBaseParser.CURRENT_DATE => | ||
| CurrentDate() | ||
| case SqlBaseParser.CURRENT_TIMESTAMP => | ||
| CurrentTimestamp() | ||
| } | ||
| } else { | ||
| // If the parser is not in ansi mode, we should return `UnresolvedAttribute`, in case there | ||
| // are columns named `CURRENT_DATE` or `CURRENT_TIMESTAMP`. | ||
| UnresolvedAttribute.quoted(ctx.name.getText) | ||
| } | ||
| } | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to change the current behaviour of
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think so, this behavior change only makes sense in ansi mode.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh, I missed. You're right. |
||
| /** | ||
| * Create a [[Cast]] expression. | ||
| */ | ||
|
|
||
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.
Shouldn't it be?