You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Aman Omer (Jira)" <ji...@apache.org> on 2019/11/11 12:26:00 UTC

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

    [ https://issues.apache.org/jira/browse/SPARK-29842?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16971477#comment-16971477 ] 

Aman Omer commented on SPARK-29842:
-----------------------------------

I will work on this

> 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.0.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