-
Notifications
You must be signed in to change notification settings - Fork 29k
[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
Conversation
| UnresolvedAttribute.quoted(ctx.name.getText) | ||
| } | ||
| } | ||
|
|
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.
We need to change the current behaviour of select current_date/select current_timestamp in the non-ansi mode? If so, we need to update the migration guide:
// the current behaivour in the non-ansi mode
scala> sql("SET spark.sql.parser.ansi.enabled=false")
scala> sql("SELECT CURRENT_TIMESTAMP").show
+--------------------+
| current_timestamp()|
+--------------------+
|2019-02-25 16:26:...|
+--------------------+
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.
I don't think so, this behavior change only makes sense in ansi mode.
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.
oh, I missed. You're right.
| } | ||
| } | ||
|
|
||
| override def visitCurrentDatetime(ctx: CurrentDatetimeContext): AnyRef = { |
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?
override def visitCurrentDatetime(ctx: CurrentDatetimeContext): Expression = withOrigin(ctx) {
...
}|
Test build #103262 has finished for PR 24039 at commit
|
| } | ||
| } | ||
|
|
||
| override def visitCurrentDatetime(ctx: CurrentDatetimeContext): AnyRef = withOrigin(ctx) { |
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.
Not AnyRef but Expression?
|
Test build #103297 has finished for PR 24039 at commit
|
|
retest this please |
|
Test build #103303 has finished for PR 24039 at commit
|
|
Test build #103307 has finished for PR 24039 at commit
|
|
thanks, merging to master! |
What changes were proposed in this pull request?
This PR is a followup of #19559 .
It revisits https://issues.apache.org/jira/browse/SPARK-27117 , which should be an invalid use case according to the SQL standard.
current_date/current_timestampare reserved keywords, if users want to access columns namedcurrent_date/current_timestamp, they should quote the name likeselect `current_date` from tblIf ansi mode is not enabled(which is the default), this PR won't introduce any changes.
How was this patch tested?
a new test case