GitHub user kiszk opened a pull request:

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

    [SPARK-22668][SQL] Exclude global variables from arguments of method split 
by CodegenContext.splitExpressions()

    ## What changes were proposed in this pull request?
    
    This PR fixes to make incorrect result when split method by 
`CodegenContext.splitExpressions() ` has global variables in its arguments. 
When variables in arguments are declared as local variables, to assign a value 
to the variable, which has been originally declared as a global varible, 
updates a local variable.
    
    To fix this problem, this PR excludes global variables from arguments of 
the split method.
    
    Before this PR
    ```
    class Test {
      int globalInt;
    
      void splittedFunction(int globalInt) {
        ...
        globalInt = 2;
      }
    
      void apply() {
        globalInt = 1;
        ...
        splittedFunction(globalInt);
        // globalInt should be 2 here since it is 2 if statemetns are not split
      }
    }
    ```
    
    After this PR.
    ```
    class Test {
      int globalInt;
    
      void splittedFunction() {
        ...
        globalInt = 2;
      }
    
      void apply() {
        globalInt = 1;
        ...
        splittedFunction();
        // globalInt is 2
      }
    }
    ```
    
    ## How was this patch tested?
    
    Added test case into `CodeGenerationSuite`

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

    $ git pull https://github.com/kiszk/spark SPARK-22668

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

    https://github.com/apache/spark/pull/19865.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 #19865
    
----
commit 3b25b5f2fdaec7b1e97732f1b8a0bf4c588a44f2
Author: Kazuaki Ishizaki <[email protected]>
Date:   2017-12-02T06:07:03Z

    initial commit

----


---

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

Reply via email to