-
Notifications
You must be signed in to change notification settings - Fork 28k
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-29629][SQL] Support typed integer literal expression #26291
Conversation
Test build #112828 has finished for PR 26291 at commit
|
retest this please |
ex.setStackTrace(e.getStackTrace) | ||
throw ex | ||
} | ||
Literal(i) |
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 replace it by Literal(i, IntegerType)
, so, Literal.apply() doesn't have to pattern match i
to infer IntegerType
.
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.
ok, that is better.
@@ -1799,6 +1799,16 @@ class AstBuilder(conf: SQLConf) extends SqlBaseBaseVisitor[AnyRef] with Logging | |||
case "X" => | |||
val padding = if (value.length % 2 != 0) "0" else "" | |||
Literal(DatatypeConverter.parseHexBinary(padding + value)) | |||
case "INTEGER" => | |||
val i = try { | |||
Integer.parseInt(value) |
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.
nit: Scalish style value.toInt
.
@@ -36,3 +36,5 @@ select date '2001-10-01' - 7; | |||
select date '2001-10-01' - date '2001-09-28'; | |||
select date'2020-01-01' - timestamp'2019-10-06 10:11:12.345678'; | |||
select timestamp'2019-10-06 10:11:12.345678' - date'2020-01-01'; | |||
select date '2001-09-28' + integer '7'; |
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 this is necessary test. datetime.sql
aims to test date-time related functionality. And date +/- integer
has been already covered by https://github.com/apache/spark/pull/26291/files#diff-e7a79cbcd5411e8891cee65c286c2177L33
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.
thanks for your review. updated
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.
LGTM, waiting for jenkins
Test build #112831 has finished for PR 26291 at commit
|
Test build #112834 has finished for PR 26291 at commit
|
Test build #112836 has finished for PR 26291 at commit
|
@@ -1799,6 +1799,16 @@ class AstBuilder(conf: SQLConf) extends SqlBaseBaseVisitor[AnyRef] with Logging | |||
case "X" => | |||
val padding = if (value.length % 2 != 0) "0" else "" | |||
Literal(DatatypeConverter.parseHexBinary(padding + value)) | |||
case "INTEGER" => |
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.
Out of curiosity, how many such typed literals are there left?
Merged to master. |
Shall we revert it? It seems weird to me to write int literals with |
Postgre +1 Presto +1 MySQL -1, ANSI Standard (Seems -1) |
+1 with @cloud-fan |
+1 for reverting, the Jira SPARK-30125 should be reused, then all the reverting PRs are gathered together. |
What changes were proposed in this pull request?
Add support for typed integer literal expression from postgreSQL.
Why are the changes needed?
SPARK-27764 Feature Parity between PostgreSQL and Spark
Does this PR introduce any user-facing change?
support typed integer lit in SQL
How was this patch tested?
add uts