EnricoMi commented on code in PR #39754:
URL: https://github.com/apache/spark/pull/39754#discussion_r1455209994
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/namedExpressions.scala:
##########
@@ -410,6 +410,20 @@ case class PrettyAttribute(
override def nullable: Boolean = true
}
+/**
+ * An expression that has to be resolved against a scope of resolved
attributes.
+ */
+case class ScopedExpression(child: Expression, scope: AttributeSeq)
Review Comment:
> shall we put Seq[Attribute]
yes, done:
```diff
-case class ScopedExpression(child: Expression, scope: AttributeSeq)
+case class ScopedExpression(child: Expression, scope: Seq[Attribute])
```
> include it as children?
as in
```diff
case class ScopedExpression(child: Expression, scope: Seq[Attribute])
- extends UnaryExpression with Unevaluable {
- override def dataType: DataType = child.dataType
- override def nullable: Boolean = child.nullable
+ extends Expression with Unevaluable {
+ override def children: Seq[Expression] = expr +: scope
+ override def dataType: DataType = expr.dataType
+ override def nullable: Boolean = expr.nullable
override def prettyName: String = "scoped"
- override def sql: String = s"$prettyName(${child.sql}, $scope)"
+ override def sql: String = s"$prettyName(${expr.sql}, $scope)"
+ override lazy val resolved: Boolean = expr.resolved
- override def withNewChildInternal(newChild: Expression): ScopedExpression
= copy(child = newChild)
+ override protected def withNewChildrenInternal(children:
IndexedSeq[Expression]): Expression = {
+ val scope = children.tail
+ assert(scope.forall(_.isInstanceOf[Attribute]), "Scope children have to
be attributes")
+ copy(expr = children.head, scope = scope.map(_.asInstanceOf[Attribute]))
+ }
}
```
https://github.com/apache/spark/pull/39754/commits/f8d5aa63ebef5b2c67495002b539c9f942586931#diff-cf96171d13fd77e670764766ae22afafbc4a396316bd758a89b60a6fe70d5b0d
--
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]