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 {
   +  extends Expression with Unevaluable {
      override def dataType: DataType = child.dataType
      override def nullable: Boolean = child.nullable
      override def prettyName: String = "scoped"
    
      override def sql: String = s"$prettyName(${child.sql}, $scope)"
    
   -  override def withNewChildInternal(newChild: Expression): ScopedExpression 
= copy(child = newChild)
   +  override def withNewChildren(newChildren: Seq[Expression]): 
ScopedExpression = {
   +    val scope = newChildren.tail
   +    assert(scope.forall(_.isInstanceOf[Attribute]), "Scope children have to 
be attributes")
   +    copy(child = newChildren.head, scope = 
scope.map(_.asInstanceOf[Attribute]))
   +  }
    }
   ```



-- 
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]

Reply via email to