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/05/11 16:56:00 UTC
[jira] [Commented] (SPARK-35374) Add string-to-number conversion
support to JacksonParser
[ https://issues.apache.org/jira/browse/SPARK-35374?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17342732#comment-17342732 ]
Apache Spark commented on SPARK-35374:
--------------------------------------
User 'sarutak' has created a pull request for this issue:
https://github.com/apache/spark/pull/32506
> Add string-to-number conversion support to JacksonParser
> --------------------------------------------------------
>
> Key: SPARK-35374
> URL: https://issues.apache.org/jira/browse/SPARK-35374
> Project: Spark
> Issue Type: Improvement
> Components: SQL
> Affects Versions: 2.4.7, 3.1.1, 3.2.0
> Reporter: Kousuke Saruta
> Assignee: Kousuke Saruta
> Priority: Minor
>
> In the current implementation, spark.read.json doesn't convert numbers represented as string even though types are specified by schema.
> Here is anexample.
> {code}
> $ cat test.json
> { "value": "foo" }
> { "value": "100" }
> { "value": "257" }
> { "value": "32768" }
> { "value": "2147483648" }
> { "value": "2.71f" }
> { "value": "1.0E100" }
> $ bin/spark-shell
> import org.apache.spark.sql.types._
> val df = spark.read.
> schema(StructType(StructField("value", DoubleType)::Nil)).json("test.json")
> df.show
> +-----+
> |value|
> +-----+
> | null|
> | null|
> | null|
> | null|
> | null|
> | null|
> | 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