Github user kiszk commented on the pull request:

    https://github.com/apache/spark/pull/11636#issuecomment-195323234
  
    @nongli , here is another example.
    
    Spark code with two columns
    ````
        
sqlContext.conf.setConfString(SQLConf.PARQUET_VECTORIZED_READER_ENABLED.key, 
"true")
        sqlContext.conf.setConfString(SQLConf.WHOLESTAGE_CODEGEN_ENABLED.key, 
"true")
        val values = 10
        withTempPath { dir =>
          withTempTable("t1", "tempTable") {
            sqlContext.range(values).registerTempTable("t1")
            sqlContext.sql("select id % 2 as p, cast(id as INT) as id from t1")
              .write.partitionBy("p").parquet(dir.getCanonicalPath)
            
sqlContext.read.parquet(dir.getCanonicalPath).registerTempTable("tempTable")
            sqlContext.sql("select sum(p), sum(id) from tempTable").collect
          }
        }
    ````
    
    Code snippet generated by this PR
    ````
    ...
        /* 073 */   private void rdd_processBatches() throws 
java.io.IOException {
        /* 074 */     while (true) {
        /* 075 */       int numRows = rdd_batch.numRows();
        /* 076 */       if (rdd_batchIdx == 0) rdd_metricValue.add(numRows);
        /* 077 */
        /* 078 */       while (!shouldStop() && rdd_batchIdx < numRows) {
        /* 079 */         
org.apache.spark.sql.execution.vectorized.ColumnVector rdd_col0 = 
rdd_batch.column(0);org.apache.spark.sql.execution.vectorized.ColumnVector r
    dd_col1 = rdd_batch.column(1);
        /* 080 */         /*** CONSUME: TungstenAggregate(key=[], 
functions=[(sum(cast(p#4 as 
bigint)),mode=Partial,isDistinct=false),(sum(cast(id#3 as bigint)),mode=Pa
    rtial,isDistinct=false)], output=[sum#13L,sum#14L]) */
        /* 081 */         /* input[0, int] */
        /* 082 */         boolean rdd_isNull = rdd_col0.getIsNull(rdd_batchIdx);
        /* 083 */         int rdd_value = rdd_isNull ? -1 : 
(rdd_col0.getInt(rdd_batchIdx));
        /* 084 */         /* input[1, int] */
        /* 085 */         boolean rdd_isNull1 = 
rdd_col1.getIsNull(rdd_batchIdx);
        /* 086 */         int rdd_value1 = rdd_isNull1 ? -1 : 
(rdd_col1.getInt(rdd_batchIdx));
        /* 087 */
        /* 088 */         // do aggregate
    ...
    ````


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