-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-32207][SQL] Support 'F'-suffixed Float Literals #29022
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
|
cc @cloud-fan @maropu @HyukjinKwon thanks for reviewing this in advance. |
|
I don't know why it's not supported before, and looks fine to me. cc @maropu @viirya @bart-samwel |
|
SGTM! |
|
+1 |
|
Oh, I see. Looks okay to add this. |
wangyum
left a comment
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.
Hive 2.3 and PostgreSQL seem to be aliases:
hive> CREATE TABLE test_float1 as SELECT 1.0F, 2.0D;
hive> DESC test_float1;
OK
f decimal(1,0)
_c1 double
Time taken: 0.763 seconds, Fetched: 2 row(s)postgres=# CREATE TABLE test_float1 as SELECT 1.0F, 2.0D;
postgres=# \d test_float1;
Table "public.test_float1"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
f | numeric | | |
d | numeric | | |
I wonder what postgresql does with |
|
Test build #125202 has finished for PR 29022 at commit
|
postgres=# CREATE TABLE test_float2 as SELECT 1.0F, 2.0D, 1.0e2, 1.0e;
SELECT 1
postgres=# \d test_float2;
Table "public.test_float2"
Column | Type | Collation | Nullable | Default
----------+---------+-----------+----------+---------
f | numeric | | |
d | numeric | | |
?column? | numeric | | |
e | numeric | | |
postgres=# select * from test_float2;
f | d | ?column? | e
-----+-----+----------+-----
1.0 | 2.0 | 100 | 1.0
(1 row) |
|
Test build #125206 has finished for PR 29022 at commit
|
|
I noticed this too when I played with other PR. I thought it was by purpose. If it is not, looks okay to add it. |
|
retest this please |
|
Test build #125236 has finished for PR 29022 at commit
|
|
Could you update the doc, too? https://github.com/apache/spark/blob/master/docs/sql-ref-literals.md#numeric-literal |
|
documentation updated, thanks for reminding me @maropu |
docs/sql-ref-literals.md
Outdated
| Case insensitive, indicates `DOUBLE`, which is an 8-byte double-precision floating point number. | ||
| * **D** |
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.
F
maropu
left a comment
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 except for the @cloud-fan comment.
| Long.MinValue, Long.MaxValue, LongType.simpleString)(_.toLong) | ||
| } | ||
|
|
||
| override def visitFloatLiteral(ctx: FloatLiteralContext): Literal = { |
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 add a function description like the other functions around here, @yaooqinn ?
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.
done, thanks!
dongjoon-hyun
left a comment
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.
+1, LGTM (except @cloud-fan 's comment and mine)
|
Test build #125287 has finished for PR 29022 at commit
|
|
retest this please |
If the digits part is integral, e.g. |
|
Is there a system support |
|
Test build #125298 has finished for PR 29022 at commit
|
|
Test build #125307 has finished for PR 29022 at commit
|
|
retest this please |
|
Seems like most databases don't support the |
|
Test build #125320 has started for PR 29022 at commit |
|
Yea, the @cloud-fan comment above sounds fine to me. |
|
Retest this please. |
|
Test build #125384 has finished for PR 29022 at commit
|
|
retest this please |
1 similar comment
|
retest this please |
|
Test build #125388 has finished for PR 29022 at commit
|
|
retest this please |
|
Test build #125425 has finished for PR 29022 at commit
|
|
retest this please |
|
Test build #125435 has finished for PR 29022 at commit
|
|
retest this please |
|
Test build #125443 has finished for PR 29022 at commit
|
|
retest this please |
|
Test build #125491 has started for PR 29022 at commit |
|
retest this please |
|
Retest this please |
|
Test build #125505 has finished for PR 29022 at commit
|
|
Thank you, @yaooqinn and all. Merged to master. |
|
Thanks for merging @dongjoon-hyun and all for the help |






What changes were proposed in this pull request?
In this PR, I suppose we support 'f'-suffixed float literal, e.g.
select 1.1fWhy are the changes needed?
a very common feature across platforms, checked with pg, presto, hive, MySQL...
Does this PR introduce any user-facing change?
yes,
select 1.1fresults float value 1.1 instead of throwing AnlaysisExceptiionCan't extract value from 1: need struct type but got int;How was this patch tested?
add unit tests