GitHub user dongjoon-hyun opened a pull request:

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

    [SPARK-13135][SQL] Don't print expressions recursively in generated code

    ## What changes were proposed in this pull request?
    
    This PR is an up-to-date and a little bit improved version of #11019 of 
@rxin for
    - (1) preventing recursive printing of expressions in generated code.
    
    In addition to #11019, this PR improves the followings in code generation.
    - (2) Improve multiline comment about `Codegened pipeline`.
    - (3) Improve multiline comment indentation.
    - (4) Reduce the number of empty lines (mainly consequtive empty lines).
    - (5) Remove all space characters on empty lines.
    
    **Example**
    ```
    spark.range(1, 1000).select('id+1+2+3+4)
    ```
    
    **Before**
    ```
    Generated code:
    /* 001 */ public Object generate(Object[] references) {
    ...
    /* 005 */ /** Codegened pipeline for:
    /* 006 */ * Project [((((id#0L + 1) + 2) + 3) + 4) AS ((((id + 1) + 2) + 3) 
+ 4)#3L]
    /* 007 */ +- Range 1, 1, 8, 999, [id#0L]
    /* 008 */ */
    ...
    /* 074 */     /*** PRODUCE: Project [((((id#0L + 1) + 2) + 3) + 4) AS 
((((id + 1) + 2) + 3) + 4)#3L] */
    /* 075 */     
    /* 076 */     /*** PRODUCE: Range 1, 1, 8, 999, [id#0L] */
    /* 077 */     
    /* 078 */     // initialize Range
    ...
    /* 091 */       /*** CONSUME: Project [((((id#0L + 1) + 2) + 3) + 4) AS 
((((id + 1) + 2) + 3) + 4)#3L] */
    /* 092 */       
    /* 093 */       /*** CONSUME: WholeStageCodegen */
    /* 094 */       
    /* 095 */       /* ((((input[0, bigint] + 1) + 2) + 3) + 4) */
    /* 096 */       /* (((input[0, bigint] + 1) + 2) + 3) */
    /* 097 */       /* ((input[0, bigint] + 1) + 2) */
    /* 098 */       /* (input[0, bigint] + 1) */
    ...
    /* 109 */       project_value = project_value1 + 4L;
    /* 110 */       project_rowWriter.write(0, project_value);
    ...
    /* 116 */ }
    ```
    
    **After**
    ```
    Generated code:
    /* 001 */ public Object generate(Object[] references) {
    ...
    /* 005 */ /** Codegened pipeline for:
    /* 006 */  * Project [((((id#0L + 1) + 2) + 3) + 4) AS ((((id + 1) + 2) + 
3) + 4)#3L]
    /* 007 */  * +- Range 1, 1, 8, 999, [id#0L]
    /* 008 */  */
    ...
    /* 074 */     /*** PRODUCE: Project [((((id#0L + 1) + 2) + 3) + 4) AS 
((((id + 1) + 2) + 3) + 4)#3L] */
    /* 075 */     /*** PRODUCE: Range 1, 1, 8, 999, [id#0L] */
    /* 076 */     // initialize Range
    ...
    /* 089 */       /*** CONSUME: Project [((((id#0L + 1) + 2) + 3) + 4) AS 
((((id + 1) + 2) + 3) + 4)#3L] */
    /* 090 */       /*** project list: [((((input[0, bigint, false] + 1) + 2) + 
3) + 4)] */
    /* 091 */       /*** CONSUME: WholeStageCodegen */
    ...
    /* 102 */       project_value = project_value1 + 4L;
    /* 103 */       /*** project list: [input[0, bigint, false]] */
    /* 104 */       project_rowWriter.write(0, project_value);
    ...
    /* 110 */ }
    ```
    
    ## How was this patch tested?
    
    Pass the Jenkins tests and see the result of the following command manually.
    ```scala
    scala> spark.range(1, 
1000).select('id+1+2+3+4).queryExecution.debug.codegen()
    ```
    
    Author: Dongjoon Hyun <dongj...@apache.org>
    Author: Reynold Xin <r...@databricks.com>

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

    $ git pull https://github.com/dongjoon-hyun/spark SPARK-13135

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

    https://github.com/apache/spark/pull/13192.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 #13192
    
----
commit ea7de3b92d413352cec2520119a4ab9b3f930cf3
Author: Dongjoon Hyun <dongj...@apache.org>
Date:   2016-05-19T07:47:45Z

    [SPARK-13135][SQL] Don't print expressions recursively in generated code
    
    - Don't print expressions recursively
    - Reduce the number of empty lines
    - Remove all space characters on empty lines
    - Improve multiline comment indentation

----


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