GitHub user liancheng opened a pull request:

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

    [SPARK-12131][SQL][WIP] Fixes ExpressionEncoder for arrays of nested classes

    `ExpressionEncoder` uses `MapObjects` to extract Scala objects from 
`InternalRow`s. During the process, `MapObjects.completeFunction` plays the 
role of a lambda function within the SQL space.  However, there lies an 
contradiction:
    
    1.  `completeFunction` is not a constructor argument of `MapObjects`. This 
stops `ExpressionEncoder.resolve` to transform inner `NewInstance` expressions 
within `completeFunction` to fill in outer pointers for nested classes.
    1.  On the other hand, once we make `completeFunction` a constructor 
arguments, it will be eagerly resolved by the analyzer. But this "lambda" 
function should only be resolved while being "applied" within the generated 
code.
    
    This PR tries fix this issue by specializing `MapObjects` in 
`ExpressionEncoder.resolve`, and adding an extra argument list to the 
constructor to pass in an optional copy of the transformed `completeFunction`.
    
    This PR is still in a WIP. Although it does fix the nested class issue, it 
breaks other situations like `Seq` of `Seq` and `Map` of `Map`. Still working 
on it.


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

    $ git pull https://github.com/liancheng/spark 
spark-12131.encoder-for-array-of-inner-class

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

    https://github.com/apache/spark/pull/10133.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 #10133
    
----
commit da4e024da8c6da3a3464e8acaaef00ea52e1900d
Author: Cheng Lian <[email protected]>
Date:   2015-12-03T16:47:02Z

    WIP

----


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to