AngersZhuuuu commented on issue #25028: [SPARK-28227][SQL] Support TRANSFORM with aggregation. URL: https://github.com/apache/spark/pull/25028#issuecomment-547248832 > Regarding the issue in [#25028 (comment)](https://github.com/apache/spark/pull/25028#issuecomment-547230458) > > Instead of > > ``` > val namedExpressions = expressions.map { > case e: NamedExpression => e > case e: Expression => UnresolvedAlias(e) > } > ``` > > How about also using a manual aliasing function to create an alias for complex column expressions (i.e. BinaryExpression) instead of relying on `toPrettySQL` > > Example: > > ``` > val aliasFunc = (position: Int, e: Expression) => s"gen_alias_${position}" > > val namedExpressions = expressions.zipWithIndex.map { > case (e: NamedExpression, _) => e > case (e: BinaryExpression, index) => UnresolvedAlias(e, Some(aliasFunc(index, _))) > case (e: Expression, _) => UnresolvedAlias(e) > } > ``` > > Test query runs successfully. Good suggestion, make subquery 's output and transform's input with same alias. Can solve this problem. Nice method.
---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org