alfozan commented on issue #25028: [SPARK-28227][SQL] Support TRANSFORM with 
aggregation.
URL: https://github.com/apache/spark/pull/25028#issuecomment-548691723
 
 
   Here's what I mean:
   
   test query:
   
   ```
   SELECT TRANSFORM(key, abs(key))
   USING 'cat'
   FROM (SELECT DISTINCT key FROM src);
   ```
   
   The physical plan without this PR (on master):
   ```
   ScriptTransformation [key#7, abs(key#7)], cat, [key#9, value#10], 
HiveScriptIOSchema(List(),List(),Some(org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe),Some(org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe),List((field.delim,
      )),List((field.delim,   
)),Some(org.apache.hadoop.hive.ql.exec.TextRecordReader),Some(org.apache.hadoop.hive.ql.exec.TextRecordWriter),true)
   +- *(2) HashAggregate(keys=[1#16], functions=[], output=[key#7])
      +- Exchange hashpartitioning(1#16, 1), true, [id=#27]
         +- *(1) HashAggregate(keys=[1 AS 1#16], functions=[], output=[1#16])
            +- *(1) Scan OneRowRelation[]
   ```
   
   
   
   The physical plan with this PR:
   ```
   ScriptTransformation [key#0, abs(key)#9], cat, [key#2, value#3], 
HiveScriptIOSchema(List(),List(),Some(org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe),Some(org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe),List((field.delim,
       )),List((field.delim,   
)),Some(org.apache.hadoop.hive.ql.exec.TextRecordReader),Some(org.apache.hadoop.hive.ql.exec.TextRecordWriter),true)
   +- *(2) HashAggregate(keys=[1#10], functions=[], output=[key#0, abs(key)#9])
      +- Exchange hashpartitioning(1#10, 1), true, [id=#21]
         +- *(1) HashAggregate(keys=[1 AS 1#10], functions=[], output=[1#10])
            +- *(1) Scan OneRowRelation[]
   ```
   
   
   Difference:
   `+- *(2) HashAggregate(keys=[1#16], functions=[], output=[key#7])
   `vs
   `+- *(2) HashAggregate(keys=[1#10], functions=[], output=[key#0, abs(key)#9])
   `
   

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


With regards,
Apache Git Services

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

Reply via email to