Skip to content

Commit

Permalink
Make resolveExpressionByPlanOutput and …ByPlanChildren not resolve sc…
Browse files Browse the repository at this point in the history
…oped expression
  • Loading branch information
EnricoMi committed Nov 22, 2024
1 parent 1ce9a5e commit 058d60a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ trait ColumnResolutionHelper extends Logging with DataTypeErrorsBase {
u.copy(child = newChild)
}

case s : ScopedExpression => s.mapScope(innerResolve(_, isTopLevel = false))

case _ => e.mapChildren(innerResolve(_, isTopLevel = false))
}
resolved.copyTagsFrom(e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ case class ScopedExpression(expr: Expression, scope: Seq[Attribute])
override def sql: String = s"$prettyName(${expr.sql}, $scope)"
override lazy val resolved: Boolean = expr.resolved

def mapScope(f: Expression => Expression): Expression = {
// similar to mapChildren, but only for the scope children
if (scope.nonEmpty) {
this.copy(scope = scope.map(f).map(_.asInstanceOf[Attribute]))
} else {
this
}
}

override protected def withNewChildrenInternal(children: IndexedSeq[Expression]): Expression = {
val scope = children.tail
assert(scope.forall(_.isInstanceOf[Attribute]), "Scope children have to be attributes")
Expand Down

0 comments on commit 058d60a

Please sign in to comment.