-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-20392][SQL] Set barrier to prevent re-entering a tree #17770
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 1 commit
82978d7
24905e3
e15b001
a076d83
b29ded3
8c8fe1e
a855182
4ff9610
d0a94f4
02e11f9
17f1a02
4629959
c313e35
7e9dfac
fba3690
f63ea0b
b9d03cd
6a7204c
3437ae0
555fa8e
505aba6
f3e4208
c0bee01
1c1cc9d
eb0598e
cba784b
b478e55
8314cc3
6add9ec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -167,7 +167,7 @@ class Analyzer( | |
| UpdateOuterReferences), | ||
| Batch("Cleanup", fixedPoint, | ||
| CleanupAliases, | ||
| CleanupBarriers) | ||
| EliminateBarriers) | ||
| ) | ||
|
|
||
| /** | ||
|
|
@@ -673,7 +673,7 @@ class Analyzer( | |
| */ | ||
| private def dedupRight (left: LogicalPlan, oriRight: LogicalPlan): LogicalPlan = { | ||
| // Remove analysis barrier if any. | ||
| val right = CleanupBarriers(oriRight) | ||
| val right = EliminateBarriers(oriRight) | ||
| val conflictingAttributes = left.outputSet.intersect(right.outputSet) | ||
| logDebug(s"Conflicting attributes ${conflictingAttributes.mkString(",")} " + | ||
| s"between $left and $right") | ||
|
|
@@ -1050,7 +1050,7 @@ class Analyzer( | |
| case sa @ Sort(_, _, child: Aggregate) => sa | ||
|
|
||
| case s @ Sort(order, _, orgChild) if !s.resolved && orgChild.resolved => | ||
| val child = CleanupBarriers(orgChild) | ||
| val child = EliminateBarriers(orgChild) | ||
| try { | ||
| val newOrder = order.map(resolveExpressionRecursively(_, child).asInstanceOf[SortOrder]) | ||
| val requiredAttrs = AttributeSet(newOrder).filter(_.resolved) | ||
|
|
@@ -1072,7 +1072,7 @@ class Analyzer( | |
| } | ||
|
|
||
| case f @ Filter(cond, orgChild) if !f.resolved && orgChild.resolved => | ||
| val child = CleanupBarriers(orgChild) | ||
| val child = EliminateBarriers(orgChild) | ||
|
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. Actually, do we need to do this? can
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. Yes, we do need it. The logical plan added with missing attributes is needed to be traverse for some cases. At lease one test gets failed previously for that. So we can't keep the barrier at original position. |
||
| try { | ||
| val newCond = resolveExpressionRecursively(cond, child) | ||
| val requiredAttrs = newCond.references.filter(_.resolved) | ||
|
|
@@ -1553,7 +1553,7 @@ class Analyzer( | |
| object ResolveAggregateFunctions extends Rule[LogicalPlan] { | ||
| def apply(plan: LogicalPlan): LogicalPlan = plan.transformUp { | ||
| case filter @ Filter(havingCondition, AnalysisBarrier(aggregate: Aggregate)) => | ||
| apply(Filter(havingCondition, aggregate)).mapChildren(AnalysisBarrier(_)) | ||
| apply(Filter(havingCondition, aggregate)).mapChildren(AnalysisBarrier) | ||
| case filter @ Filter(havingCondition, | ||
| aggregate @ Aggregate(grouping, originalAggExprs, child)) | ||
| if aggregate.resolved => | ||
|
|
@@ -1614,7 +1614,7 @@ class Analyzer( | |
| } | ||
|
|
||
| case sort @ Sort(sortOrder, global, AnalysisBarrier(aggregate: Aggregate)) => | ||
| apply(Sort(sortOrder, global, aggregate)).mapChildren(AnalysisBarrier(_)) | ||
| apply(Sort(sortOrder, global, aggregate)).mapChildren(AnalysisBarrier) | ||
| case sort @ Sort(sortOrder, global, aggregate: Aggregate) if aggregate.resolved => | ||
|
|
||
| // Try resolving the ordering as though it is in the aggregate clause. | ||
|
|
@@ -2481,7 +2481,7 @@ object CleanupAliases extends Rule[LogicalPlan] { | |
| } | ||
|
|
||
| /** Remove the barrier nodes of analysis */ | ||
| object CleanupBarriers extends Rule[LogicalPlan] { | ||
| object EliminateBarriers extends Rule[LogicalPlan] { | ||
| override def apply(plan: LogicalPlan): LogicalPlan = plan transformDown { | ||
| case AnalysisBarrier(child) => child | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -187,7 +187,7 @@ class Dataset[T] private[sql]( | |
| } | ||
| } | ||
|
|
||
| // Wrap analyzed logical plan with an analysis barrier so we won't traverse/resolve it again. | ||
| // Wraps analyzed logical plans with an analysis barrier so we won't traverse/resolve it again. | ||
| @transient private val planWithBarrier: LogicalPlan = AnalysisBarrier(logicalPlan) | ||
|
||
|
|
||
| /** | ||
|
|
@@ -1744,7 +1744,7 @@ class Dataset[T] private[sql]( | |
| def union(other: Dataset[T]): Dataset[T] = withSetOperator { | ||
| // This breaks caching, but it's usually ok because it addresses a very specific use case: | ||
| // using union to union many files or partitions. | ||
| CombineUnions(Union(logicalPlan, other.logicalPlan)).mapChildren(AnalysisBarrier(_)) | ||
| CombineUnions(Union(logicalPlan, other.logicalPlan)).mapChildren(AnalysisBarrier) | ||
| } | ||
|
|
||
| /** | ||
|
|
||
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.
add the
AnalysisBarrierback at the end?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.
It is added back below at line 1102 in
addMissingAttr. The logical plans added with missing attributes seems need to be resolved again under some cases. One test gets failed before due to this issue.