You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Dongjoon Hyun (Jira)" <ji...@apache.org> on 2020/03/29 02:07:00 UTC

[jira] [Updated] (SPARK-29842) PostgreSQL dialect: cast to double

     [ https://issues.apache.org/jira/browse/SPARK-29842?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dongjoon Hyun updated SPARK-29842:
----------------------------------
    Affects Version/s:     (was: 3.0.0)
                       3.1.0

> PostgreSQL dialect: cast to double
> ----------------------------------
>
>                 Key: SPARK-29842
>                 URL: https://issues.apache.org/jira/browse/SPARK-29842
>             Project: Spark
>          Issue Type: Sub-task
>          Components: SQL
>    Affects Versions: 3.1.0
>            Reporter: jobit mathew
>            Priority: Major
>
> Make SparkSQL's cast to double behavior be consistent with PostgreSQL when
> spark.sql.dialect is configured as PostgreSQL.
> some examples
> {code:java}
> spark-sql> select CAST ('10.2' AS DOUBLE PRECISION);
> Error in query:
> extraneous input 'PRECISION' expecting ')'(line 1, pos 30)
> == SQL ==
> select CAST ('10.2' AS DOUBLE PRECISION)
> ------------------------------^^^
> spark-sql> select CAST ('10.2' AS DOUBLE PRECISION);
> Error in query:
> extraneous input 'PRECISION' expecting ')'(line 1, pos 30)
> == SQL ==
> select CAST ('10.2' AS DOUBLE PRECISION)
> ------------------------------^^^
> spark-sql> select CAST ('10.2' AS DOUBLE);
> 10.2
> Time taken: 0.08 seconds, Fetched 1 row(s)
> spark-sql> select CAST ('10.222222222222' AS DOUBLE);
> 10.222222222222
> Time taken: 0.08 seconds, Fetched 1 row(s)
> spark-sql> select CAST ('ff' AS DOUBLE);
> NULL
> Time taken: 0.08 seconds, Fetched 1 row(s)
> spark-sql> select CAST ('11111111111111111' AS DOUBLE);
> 1.1111111111111112E16
> Time taken: 0.067 seconds, Fetched 1 row(s)
> spark-sql> 
> {code}
> Postgresql
> select CAST ('10.22222222222' AS DOUBLE PRECISION);
>  select CAST ('11111111111111111' AS DOUBLE PRECISION);
>  select CAST ('ff' AS DOUBLE PRECISION);
>  
>  
> ||  ||float8||
> |1|10,22222222222|
>  
> ||  ||float8||
> |1|1,11111111111111E+16|
> Error(s), warning(s):
> 22P02: invalid input syntax for type double precision: "ff"
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org