-
Notifications
You must be signed in to change notification settings - Fork 28.7k
[SPARK-24803][SQL] add support for numeric #21766
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
Can one of the admins verify this patch? |
@gatorsmile Is it worth adding a numeric type as an alias of decimal? Both types seems to be in the SQL standard and some dbms (e.g., postgresql and sql server) can parse both. |
Although MS SQL Server looks like use them interchangeably, https://docs.microsoft.com/en-us/sql/t-sql/data-types/decimal-and-numeric-transact-sql?view=sql-server-2017, they are not exactly the same in ANSI SQL.
|
aha, I didn't know that and postgresql also uses them interchangeably, too. |
Just checked out the PR, scala> spark.sql("SELECT CAST(1 as NUMERIC)")
res0: org.apache.spark.sql.DataFrame = [CAST(1 AS DECIMAL(10,0)): decimal(10,0)]
scala> spark.sql("SELECT NUMERIC(1)")
org.apache.spark.sql.AnalysisException: Undefined function: 'NUMERIC'. This function is neither a registered temporary function nor a permanent function registered in the database 'default'.; line 1 pos 7 I imagine some tests could be added here:
Do you think it's worth having a separate DataType or just have it as an alias? |
Why did you need this change? Given it's very difficult to revert the change (or introduce a proper numeric type if ever needed in the future), I would not merge this pull request unless there are sufficient justification. |
@dmateusp Actually i think "Numeric" has no essential difference with "Decimal". May be just have it as an alias is better,i will add some tests if you agree. |
@rxin In order to support sql syntax better and align SQL standards. I think it is worth to add a numeric type as an alias of decimal. |
@wangtao605 Do you mind documenting our behavior in our Spark SQL doc? |
Yes, it's ok. |
What changes were proposed in this pull request?
numerical is as same with decimal. Spark has already supported decimal,so i think we should add support for numeric to align SQL standards.
(Please fill in changes proposed in this fix)
How was this patch tested?
already exist tests
Please review http://spark.apache.org/contributing.html before opening a pull request.