-
Notifications
You must be signed in to change notification settings - Fork 28.5k
[SPARK-51884][SQL]Part 1.a Add outer scope attributes for SubqueryExpression #50822
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
Closed
AveryQi115
wants to merge
1
commit into
apache:master
from
AveryQi115:part_1_a_add_outer_scope_attributes
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,8 +44,10 @@ import org.apache.spark.sql.types.DataType | |
* | ||
* @param plan the logical plan provided as input for the table argument as either a logical | ||
* relation or as a more complex logical plan in the event of a table subquery. | ||
* @param outerAttrs outer references of this subquery plan, generally empty since these table | ||
* arguments do not allow correlated references currently | ||
* @param outerAttrs the outer references in the subquery plan and a boolean flag marking whether | ||
* the outer reference can be resolved in its immediate parent plan or not, | ||
* generally empty since these table arguments do not allow correlated | ||
* references currently. | ||
* @param exprId expression ID of this subquery expression, generally generated afresh each time | ||
* @param partitionByExpressions if non-empty, the TABLE argument included the PARTITION BY clause | ||
* to indicate that the input relation should be repartitioned by the | ||
|
@@ -66,7 +68,7 @@ import org.apache.spark.sql.types.DataType | |
*/ | ||
case class FunctionTableSubqueryArgumentExpression( | ||
plan: LogicalPlan, | ||
outerAttrs: Seq[Expression] = Seq.empty, | ||
outerAttrs: Seq[(Expression, Boolean)] = Seq.empty, | ||
exprId: ExprId = NamedExpression.newExprId, | ||
partitionByExpressions: Seq[Expression] = Seq.empty, | ||
withSinglePartition: Boolean = false, | ||
|
@@ -78,28 +80,37 @@ case class FunctionTableSubqueryArgumentExpression( | |
"WITH SINGLE PARTITION is mutually exclusive with PARTITION BY") | ||
|
||
override def dataType: DataType = plan.schema | ||
|
||
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 revert these new-line diffs? |
||
override def nullable: Boolean = false | ||
|
||
override def withNewPlan(plan: LogicalPlan): FunctionTableSubqueryArgumentExpression = | ||
copy(plan = plan) | ||
override def withNewOuterAttrs(outerAttrs: Seq[Expression]) | ||
|
||
override def withNewOuterAttrs(outerAttrs: Seq[(Expression, Boolean)]) | ||
: FunctionTableSubqueryArgumentExpression = copy(outerAttrs = outerAttrs) | ||
|
||
override def hint: Option[HintInfo] = None | ||
|
||
override def withNewHint(hint: Option[HintInfo]): FunctionTableSubqueryArgumentExpression = | ||
copy() | ||
|
||
override def toString: String = s"table-argument#${exprId.id} $conditionString" | ||
|
||
override lazy val canonicalized: Expression = { | ||
FunctionTableSubqueryArgumentExpression( | ||
plan.canonicalized, | ||
outerAttrs.map(_.canonicalized), | ||
outerAttrs.map {case (expr, b) => (expr.canonicalized, b)}, | ||
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. Let's not use |
||
ExprId(0), | ||
partitionByExpressions, | ||
withSinglePartition, | ||
orderByExpressions) | ||
} | ||
|
||
override protected def withNewChildrenInternal( | ||
newChildren: IndexedSeq[Expression]): FunctionTableSubqueryArgumentExpression = | ||
copy(outerAttrs = newChildren) | ||
newChildren: IndexedSeq[Expression]): FunctionTableSubqueryArgumentExpression = { | ||
val newOuterAttrs = newChildren.take(outerAttrs.size).zip(outerAttrs.map(_._2)) | ||
copy(outerAttrs = newOuterAttrs) | ||
} | ||
|
||
final override def nodePatternsInternal(): Seq[TreePattern] = | ||
Seq(FUNCTION_TABLE_RELATION_ARGUMENT_EXPRESSION) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
can we add a comment here to explain what this boolean means?
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.
I think a separate class to store this would be even better