You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Apache Spark (Jira)" <ji...@apache.org> on 2021/08/15 23:13:00 UTC

[jira] [Assigned] (SPARK-36453) Improve consistency processing floating point special literals

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

Apache Spark reassigned SPARK-36453:
------------------------------------

    Assignee: Apache Spark

> Improve consistency processing floating point special literals
> --------------------------------------------------------------
>
>                 Key: SPARK-36453
>                 URL: https://issues.apache.org/jira/browse/SPARK-36453
>             Project: Spark
>          Issue Type: Improvement
>          Components: SQL
>    Affects Versions: 3.3.0
>            Reporter: Pablo Langa Blanco
>            Assignee: Apache Spark
>            Priority: Minor
>
> Special literal in floating point are not consistent between cast and json expressions
>  
> {code:java}
> scala> spark.sql("SELECT CAST('+Inf' as Double)").show
> +--------------------+                                                        
> |CAST(+Inf AS DOUBLE)|
> +--------------------+
> |            Infinity|
> +--------------------+
> {code}
>  
> {code:java}
> scala> val schema =  StructType(StructField("a", DoubleType) :: Nil)
> scala> Seq("""{"a" : "+Inf"}""").toDF("col1").select(from_json(col("col1"),schema)).show
> +---------------+
> |from_json(col1)|
> +---------------+
> |         {null}|
> +---------------+
> scala> Seq("""{"a" : "+Inf"}""").toDF("col").withColumn("col", from_json(col("col"), StructType.fromDDL("a DOUBLE"))).write.json("/tmp/jsontests12345")
> scala> spark.read.schema(StructType(Seq(StructField("col",schema)))).json("/tmp/jsontests12345").show
> +------+
> |   col|
> +------+
> |{null}|
> +------+
> {code}
>  
>  



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