alfozan commented on issue #25028: [SPARK-28227][SQL] Support TRANSFORM with aggregation. URL: https://github.com/apache/spark/pull/25028#issuecomment-547246714 Regarding the issue in 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.
---------------------------------------------------------------- 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