-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-29587][SQL] Support SQL Standard type real as float(4) numeric as decimal #26537
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
Changes from 1 commit
b9a25e8
ca25319
e3857e8
c6aaccc
14265f0
f7bd4b9
a1f21fc
d5d1f8e
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 |
|---|---|---|
|
|
@@ -59,3 +59,8 @@ TBLPROPERTIES ('a' = '1'); | |
|
|
||
| SHOW CREATE TABLE tbl; | ||
| DROP TABLE tbl; | ||
|
|
||
| -- new real/numeric type | ||
|
Contributor
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. What we need to prove is the alias works. I think this test is good enough (no need to test it in cast), but we should update the comment. It's not new types, but just alias.
Member
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. OK |
||
| CREATE TABLE tbl (a REAL, b NUMERIC, c NUMERIC(10), d NUMERIC(10,1)) USING parquet; | ||
| SHOW CREATE TABLE tbl; | ||
| DROP TABLE tbl; | ||
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 take a look at SQL standard, float and real are different
We can say that now Spark supports real type, and its precision is the same as java float. But it needs to be proposed explicitly, e.g. send an email to dev list.
Uh oh!
There was an error while loading. Please reload this page.
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.
It seems numeric and decimal are not exactly the same...
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 want to gather more information about these before sending an email to discuss.
https://www.postgresql.org/docs/9.3/datatype-numeric.html
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.
https://download.mimer.com/pub/developer/docs/html_100/Mimer_SQL_Engine_DocSet/Syntax_Rules4.html#wp1228955
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.
https://prestosql.io/docs/current/language/types.html#floating-point
No documentation found about numeric type
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.
https://docs.microsoft.com/en-us/openspecs/standards_support/MS-STDSUPLP/17a32be7-10b3-4025-bea4-133a66b4c689
Decimal
Float
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.
In this case it's not very useful to look at other databases. There are many stuff that is "implementation-defined".
Personally I'm fine to treat real as float in Spark, just need an official proposal.
For numeric/decimal, I don't have a strong preference.
Uh oh!
There was an error while loading. Please reload this page.
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.
The below notes from SQL standard might have some information to help us whether or not to involve real or numeric
Uh oh!
There was an error while loading. Please reload this page.
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 know why 26th - NUMERIC and 27th - DECIMAL have different definitions, but IIUC with restraint of the 25th, they are even, both with
implementation-definedprecision and scale, the user-specified ones can not be greater than these.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.
So seems the key difference between DEICMAL and NUMERIC are:
Decimal can have at least specified precision (which means can have more) whereas numeric should have exactly specified precision.
Spark's decimal satisfy both so I think NUMERIC as a synonym of DECIMAL makes sense.