cloud-fan commented on code in PR #37407:
URL: https://github.com/apache/spark/pull/37407#discussion_r972860057
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/basicLogicalOperators.scala:
##########
@@ -1374,32 +1374,104 @@ case class Pivot(
override protected def withNewChildInternal(newChild: LogicalPlan): Pivot =
copy(child = newChild)
}
+/**
+ * Expression for [[Unpivot]] for one unpivot value column (one or more
expressions)
+ * and an optional alias. This node itself is not evaluable and resolvable.
+ * Only its children are to be resolved.
+ *
+ * @param exprs expressions to unpivot
+ * @param alias optional alias
+ */
+case class UnpivotExpr(exprs: Seq[NamedExpression], alias: Option[String])
extends Unevaluable {
Review Comment:
This reminds me of `ArraysZip`, where we need to enforce named expressions.
We can follow it to avoid analyzer hacks here and there
```
case class UnpivotExpr(exprs: Seq[Expression], names: Seq[Expression],
alias: Option[String]) extends Unevaluable {
def this(exprs: Seq[Expression], alias: Option[String]) = {
this(exprs, exprs.map {
case u: UnresolvedAttribute => Literal(u.nameParts.last)
case e: NamedExpression if e.resolved => Literal(e.name)
...
}, alias)
}
}
```
--
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]