You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/02/16 17:18:09 UTC

[GitHub] HyukjinKwon opened a new pull request #23810: [SPARK-26901][SQL][R] Avoid to prune columns for vectorized gapply()

HyukjinKwon opened a new pull request #23810: [SPARK-26901][SQL][R] Avoid to prune columns for vectorized gapply()
URL: https://github.com/apache/spark/pull/23810
 
 
   ## What changes were proposed in this pull request?
   
   Currently, looks column pruning is done to vectorized `gapply()`. Given R native function could use all referred fields so it shouldn't be pruned.
    
   ```r
   df <- createDataFrame(mtcars)
   explain(count(groupBy(gapply(df,
                                "gear",
                                function(key, group) {
                                  data.frame(gear = key[[1]], disp = mean(group$disp))
                                },
                                structType("gear double, disp double")))), TRUE)
   ```
   
   Before:
   
   ```
   == Optimized Logical Plan ==
   Aggregate [count(1) AS count#41L]
   +- Project
      +- FlatMapGroupsInRWithArrow [...]
         +- Project [gear#9]
            +- LogicalRDD [mpg#0, cyl#1, disp#2, hp#3, drat#4, wt#5, qsec#6, vs#7, am#8, gear#9, carb#10], false
   
   == Physical Plan ==
   *(4) HashAggregate(keys=[], functions=[count(1)], output=[count#41L])
   +- Exchange SinglePartition
      +- *(3) HashAggregate(keys=[], functions=[partial_count(1)], output=[count#44L])
         +- *(3) Project
            +- FlatMapGroupsInRWithArrow [...]
               +- *(2) Sort [gear#9 ASC NULLS FIRST], false, 0
                  +- Exchange hashpartitioning(gear#9, 200)
                     +- *(1) Project [gear#9]
                        +- *(1) Scan ExistingRDD arrow[mpg#0,cyl#1,disp#2,hp#3,drat#4,wt#5,qsec#6,vs#7,am#8,gear#9,carb#10]
   ```
   
   After:
   
   ```
   == Optimized Logical Plan ==
   Aggregate [count(1) AS count#86L]
   +- Project
      +- FlatMapGroupsInRWithArrow [...]
         +- LogicalRDD [mpg#45, cyl#46, disp#47, hp#48, drat#49, wt#50, qsec#51, vs#52, am#53, gear#54, carb#55], false
   
   == Physical Plan ==
   *(4) HashAggregate(keys=[], functions=[count(1)], output=[count#86L])
   +- Exchange SinglePartition
      +- *(3) HashAggregate(keys=[], functions=[partial_count(1)], output=[count#89L])
         +- *(3) Project
            +- FlatMapGroupsInRWithArrow [...]
               +- *(2) Sort [gear#54 ASC NULLS FIRST], false, 0
                  +- Exchange hashpartitioning(gear#54, 200)
                     +- *(1) Scan ExistingRDD arrow[mpg#45,cyl#46,disp#47,hp#48,drat#49,wt#50,qsec#51,vs#52,am#53,gear#54,carb#55]
   ```
   
   Currently, it adds corrupt values such as:
   
   ```r
     c(7.90505033345994e-323, 7.90505033345994e-323, 7.90505033345994e-323, 7.90505033345994e-323, 7.90505033345994e-323, 7.90505033345994e-323, 7.90505033345994e-323, 7.90505033345994e-323, 7.90505033345994e-323, 7.90505033345994e-323, 7.90505033345994e-323, 7.90505033345994e-323, 0, 0, 4.17777978645388e-314)
     c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1.04669129845114e+219)
     c(3.4482690635875e-313, 3.4482690635875e-313, 3.4482690635875e-313, 
     c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2.47032822920623e-323)
   ```
   
   which should be something like:
   
   ```r
     c(4, 4, 1, 2, 2, 4, 4, 1, 2, 1, 1, 2)
     c(26, 30.4, 15.8, 19.7, 15)
     c(4, 4, 8, 6, 8)
     c(120.3, 95.1, 351, 145, 301)
   ```
   
   ## How was this patch tested?
   
   Manually tested, and unit tests were added.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org