spark-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Huaxin Gao (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (SPARK-15491) JSON serialization fails for JDBC DataFrames
Date Tue, 24 May 2016 18:01:13 GMT

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

Huaxin Gao commented on SPARK-15491:
------------------------------------

It seems to me that the problem is because JDBCRelation has two sets of constructor parameters
(first set: url, table, parts, properties.  2nd set: sparkSession). If I change it to use
only one set of parameter (url, table, parts, properties, sparkSession), then p.productIterator.toSeq
will give 5 parameters instead of 4. 

I referenced the usage of JDBCRelation, I didn't see any usage of partial function, though.
 I guess it's intended for future usage. 

I will work on the fix. I will try to find a way to get the fieldvalues for all the constructor
parameters  (instead of using p.productIterator.toSeq which only gives the first level of
constructor parameters)


> JSON serialization fails for JDBC DataFrames
> --------------------------------------------
>
>                 Key: SPARK-15491
>                 URL: https://issues.apache.org/jira/browse/SPARK-15491
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 2.0.0
>         Environment: MacOS 10.11.5, Spark 2.0.0-preview
>            Reporter: Marc Prud'hommeaux
>
> The TreeNode.toJSON feature implemented in SPARK-12321 fails with an assertion error
on DataFrames that use JDBC in spark 2.0.0-preview:
> {code}
> scala> sqlContext.read.json("examples/src/main/resources/people.json").select("name",
"age").agg(avg("age"), count("name")).filter(avg("age") > 10).queryExecution.logical.toJSON
> res113: String = [{"class":"org.apache.spark.sql.catalyst.plans.logical.Filter","num-children":1,"condition":[{"class":"org.apache.spark.sql.catalyst.expressions.GreaterThan","num-children":2,"left":0,"right":1},{"class":"org.apache.spark.sql.catalyst.expressions.aggregate.AggregateExpression","num-children":1,...
> scala> sqlContext.read.format("jdbc").options(db + ("dbtable" -> "categories")).load().queryExecution.logical.simpleString
> res120: String = Relation[category#2148,categoryname#2149] JDBCRelation(categories)
> scala> sqlContext.read.format("jdbc").options(db + ("dbtable" -> "categories")).load().queryExecution.logical.toJSON
> java.lang.AssertionError: assertion failed
>   at scala.Predef$.assert(Predef.scala:156)
>   at org.apache.spark.sql.catalyst.trees.TreeNode.org$apache$spark$sql$catalyst$trees$TreeNode$$parseToJson(TreeNode.scala:598)
>   at org.apache.spark.sql.catalyst.trees.TreeNode$$anonfun$jsonFields$2.apply(TreeNode.scala:562)
>   at org.apache.spark.sql.catalyst.trees.TreeNode$$anonfun$jsonFields$2.apply(TreeNode.scala:553)
>   at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
>   at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
>   at scala.collection.immutable.List.foreach(List.scala:381)
>   at scala.collection.TraversableLike$class.map(TraversableLike.scala:234)
>   at scala.collection.immutable.List.map(List.scala:285)
>   at org.apache.spark.sql.catalyst.trees.TreeNode.jsonFields(TreeNode.scala:553)
>   at org.apache.spark.sql.catalyst.trees.TreeNode.org$apache$spark$sql$catalyst$trees$TreeNode$$collectJsonValue$1(TreeNode.scala:538)
>   at org.apache.spark.sql.catalyst.trees.TreeNode.jsonValue(TreeNode.scala:543)
>   at org.apache.spark.sql.catalyst.trees.TreeNode.toJSON(TreeNode.scala:529)
>   ... 48 elided
> {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


Mime
View raw message