AngersZhuuuu edited a comment on issue #25028: [SPARK-28227][SQL] Support TRANSFORM with aggregation. URL: https://github.com/apache/spark/pull/25028#issuecomment-548694667 > 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 right since we now tread transform's child as an entire logical plan. It 's final output is two column, it's right. And transform use it 's out put as transform 's input. Reasonable
---------------------------------------------------------------- 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]
