You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Reynold Xin (JIRA)" <ji...@apache.org> on 2016/04/08 09:30:25 UTC
[jira] [Resolved] (SPARK-14189) JSON data source infers a field
type as StringType when some are inferred as DecimalType not capable of
IntegralType.
[ https://issues.apache.org/jira/browse/SPARK-14189?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Reynold Xin resolved SPARK-14189.
---------------------------------
Resolution: Fixed
Assignee: Dongjoon Hyun
Fix Version/s: 2.0.0
> JSON data source infers a field type as StringType when some are inferred as DecimalType not capable of IntegralType.
> ---------------------------------------------------------------------------------------------------------------------
>
> Key: SPARK-14189
> URL: https://issues.apache.org/jira/browse/SPARK-14189
> Project: Spark
> Issue Type: Bug
> Components: SQL
> Affects Versions: 2.0.0
> Reporter: Hyukjin Kwon
> Assignee: Dongjoon Hyun
> Fix For: 2.0.0
>
>
> When inferred types in the same field during finding competible {{DataType}} are {{IntegralType}} and {{DecimalType}} but {{DecimalType}} is not capable of the given {{IntegralType}}, JSON data source simply parses this as {{StringType}}.
> This can be observed when {{floatAsBigDecimal}} is enabled.
> {code}
> def mixedIntegerAndDoubleRecords: RDD[String] =
> sqlContext.sparkContext.parallelize(
> """{"a": 3, "b": 1.1}""" ::
> """{"a": 3.1, "b": 1}""" :: Nil)
> val jsonDF = sqlContext.read
> .option("floatAsBigDecimal", "true")
> .json(mixedIntegerAndDoubleRecords)
> .printSchema()
> {code}
> produces below:
> {code}
> root
> |-- a: string (nullable = true)
> |-- b: string (nullable = true)
> {code}
> When {{floatAsBigDecimal}} is disabled.
> {code}
> def mixedIntegerAndDoubleRecords: RDD[String] =
> sqlContext.sparkContext.parallelize(
> """{"a": 3, "b": 1.1}""" ::
> """{"a": 3.1, "b": 1}""" :: Nil)
> val jsonDF = sqlContext.read
> .option("floatAsBigDecimal", "false")
> .json(mixedIntegerAndDoubleRecords)
> .printSchema()
> {code}
> produces below correctly:
> {code}
> root
> |-- a: double (nullable = true)
> |-- b: double (nullable = true)
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org