GitHub user inouehrs opened a pull request:

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

    [SPARK-16100] [SQL] avoid crash in TreeNode.withNewChildren

    ## What changes were proposed in this pull request?
    This patch fixes a reported bug, which causes IndexOutOfBoundsException 
during the code generation.
    This issue is cased for a `MapObjects` instance which has the same object 
for `loopVar` and `lambdaFunction`. 
    ``` scala
    case class MapObjects private(
        loopVar: LambdaVariable,
        lambdaFunction: Expression,
        inputData: Expression) extends Expression with NonSQLExpression {
    
      override def children: Seq[Expression] = lambdaFunction :: inputData :: 
Nil
    ```
    
    In such case, `loopVar` is handled as a child in `TreeNode.withNewChildren` 
since the object is included in children as `lambdaFunction`. 
    I add checks for the number of unprocessed children to avoid this issue.
    Is there any idea on cleaner way to avoid such a pathological case?
    
    I also add `assert` to confirm that the mapping `Children` and 
`productElement` is correct.
    
    ## How was this patch tested?
    
    Using existing unit tests 


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

    $ git pull https://github.com/inouehrs/spark SPARK-16100

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

    https://github.com/apache/spark/pull/13811.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 #13811
    
----
commit f22e71dc1df045d171b40cf6ccfcc8578258252b
Author: Hiroshi Inoue <inoue...@jp.ibm.com>
Date:   2016-06-21T15:12:46Z

    avoid crash in TreeNode.withNewChildren

----


---
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