GitHub user huaxingao opened a pull request:

    https://github.com/apache/spark/pull/13287

    [SPARK-15491][SQL]fix assertion failure for JDBC DataFrame to JSON

    ## What changes were proposed in this pull request?
     in TreeNode.scala parseToJson, it has
    
    case p: Product => try {
          val fieldNames = getConstructorParameterNames(p.getClass)
          val fieldValues = p.productIterator.toSeq
          assert(fieldNames.length == fieldValues.length)
          ("product-class" -> JString(p.getClass.getName)) :: 
fieldNames.zip(fieldValues).map {
            case (name, value) => name -> parseToJson(value)
          }.toList
    
    For a class that has two level of constructor parameters, for example, 
    private[sql] case class JDBCRelation(
        url: String,
        table: String,
        parts: Array[Partition],
        properties: Properties = new Properties())(@transient val sparkSession: 
SparkSession)
    
    val fieldValues = p.productIterator.toSeq will only get the values for the 
first level of constructor parameters, in this case, 4 parameters,  but val 
fieldNames = getConstructorParameterNames(p.getClass) will get all the 5 
parameters, so assert(fieldNames.length == fieldValues.length) will fail. 
    
    I will change code to make fieldValues have all the parameters. 
    
    ## How was this patch tested?
    
    I have a unit test.  Will add it soon. 
    
    


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/huaxingao/spark spark-15491

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/13287.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #13287
    
----
commit 8307b348b62f0653cccd04cd543cf77281bc4b85
Author: Huaxin Gao <huax...@us.ibm.com>
Date:   2016-05-25T00:11:53Z

    [SPARK-15491][SQL]fix assertion failure for JDBC DataFrame to JSON

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to