-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-26370][SQL] Fix resolution of higher-order function for the same identifier. #23320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,12 +22,34 @@ import java.util.concurrent.atomic.AtomicReference | |
| import scala.collection.mutable | ||
|
|
||
| import org.apache.spark.sql.catalyst.InternalRow | ||
| import org.apache.spark.sql.catalyst.analysis.{TypeCheckResult, TypeCoercion, UnresolvedAttribute} | ||
| import org.apache.spark.sql.catalyst.analysis.{TypeCheckResult, TypeCoercion, UnresolvedAttribute, UnresolvedException} | ||
| import org.apache.spark.sql.catalyst.expressions.codegen._ | ||
| import org.apache.spark.sql.catalyst.util._ | ||
| import org.apache.spark.sql.types._ | ||
| import org.apache.spark.unsafe.array.ByteArrayMethods | ||
|
|
||
| /** | ||
| * A placeholder of lambda variables to prevent unexpected resolution of [[LambdaFunction]]. | ||
| */ | ||
| case class UnresolvedNamedLambdaVariable(nameParts: Seq[String]) | ||
| extends LeafExpression with NamedExpression with Unevaluable { | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we provide something like
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added |
||
| override def name: String = | ||
| nameParts.map(n => if (n.contains(".")) s"`$n`" else n).mkString(".") | ||
|
|
||
| override def exprId: ExprId = throw new UnresolvedException(this, "exprId") | ||
| override def dataType: DataType = throw new UnresolvedException(this, "dataType") | ||
| override def nullable: Boolean = throw new UnresolvedException(this, "nullable") | ||
| override def qualifier: Seq[String] = throw new UnresolvedException(this, "qualifier") | ||
| override def toAttribute: Attribute = throw new UnresolvedException(this, "toAttribute") | ||
| override def newInstance(): NamedExpression = throw new UnresolvedException(this, "newInstance") | ||
| override lazy val resolved = false | ||
|
|
||
| override def toString: String = s"lambda '$name" | ||
|
|
||
| override def sql: String = name | ||
| } | ||
|
|
||
| /** | ||
| * A named lambda variable. | ||
| */ | ||
|
|
@@ -79,7 +101,7 @@ case class LambdaFunction( | |
|
|
||
| object LambdaFunction { | ||
| val identity: LambdaFunction = { | ||
| val id = UnresolvedAttribute.quoted("id") | ||
| val id = UnresolvedNamedLambdaVariable(Seq("id")) | ||
| LambdaFunction(id, Seq(id)) | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does a lambda variable name can have multiple name parts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this implementation, this placeholder/wrapper type isn't just used to represent lambda variables, but also for all
UnresolvedAttributes inside of aLambdaFunction, so it needs to hold enough information to fallback to/reconstruct anUnresolvedAttributethe the name turned out not to be a lambda variable.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah i see!