cloud-fan commented on code in PR #37525:
URL: https://github.com/apache/spark/pull/37525#discussion_r1090101865
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/AliasAwareOutputExpression.scala:
##########
@@ -16,52 +16,55 @@
*/
package org.apache.spark.sql.execution
-import org.apache.spark.sql.catalyst.expressions.{Alias, Expression,
NamedExpression, SortOrder}
-import org.apache.spark.sql.catalyst.plans.physical.{HashPartitioning,
Partitioning, PartitioningCollection, UnknownPartitioning}
+import scala.collection.mutable
-/**
- * A trait that provides functionality to handle aliases in the
`outputExpressions`.
- */
-trait AliasAwareOutputExpression extends UnaryExecNode {
- protected def outputExpressions: Seq[NamedExpression]
-
- private lazy val aliasMap = outputExpressions.collect {
- case a @ Alias(child, _) => child.canonicalized -> a.toAttribute
- }.toMap
-
- protected def hasAlias: Boolean = aliasMap.nonEmpty
-
- protected def normalizeExpression(exp: Expression): Expression = {
- exp.transformDown {
- case e: Expression => aliasMap.getOrElse(e.canonicalized, e)
- }
- }
-}
+import org.apache.spark.sql.catalyst.expressions.Expression
+import org.apache.spark.sql.catalyst.plans.{AliasAwareOutputExpression,
AliasAwareQueryOutputOrdering}
+import org.apache.spark.sql.catalyst.plans.physical.{Partitioning,
PartitioningCollection, UnknownPartitioning}
/**
* A trait that handles aliases in the `outputExpressions` to produce
`outputPartitioning` that
* satisfies distribution requirements.
*/
-trait AliasAwareOutputPartitioning extends AliasAwareOutputExpression {
+trait AliasAwareOutputPartitioning extends UnaryExecNode
+ with AliasAwareOutputExpression {
final override def outputPartitioning: Partitioning = {
- val normalizedOutputPartitioning = if (hasAlias) {
- child.outputPartitioning match {
+ if (hasAlias) {
+ flattenPartitioning(child.outputPartitioning).flatMap {
+ case p: PartitioningCollection =>
Review Comment:
how can we still hit `PartitioningCollection` after `flattenPartitioning`?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]