-
Notifications
You must be signed in to change notification settings - Fork 28.5k
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
[SPARK-20700][SQL] InferFiltersFromConstraints stackoverflows for query (v2) #18020
Conversation
@@ -172,30 +173,27 @@ class InferFiltersFromConstraintsSuite extends PlanTest { | |||
val t1 = testRelation.subquery('t1) | |||
val t2 = testRelation.subquery('t2) | |||
|
|||
val originalQuery = t1.select('a, 'b.as('d), Coalesce(Seq('a, 'b)).as('int_col)).as("t") | |||
val originalQuery = t1.select('a, 'b.as('d), Coalesce(Seq('a, 'b)).as('int_col)) |
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.
The modified test case would have failed on current master branch.
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.
How about keeping the existing test case untouched? Adding a new test case?
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.
Then they would look much the same... The modified test case also covers the original situation, so I think it may be okay to not add new test cases.
Test build #77027 has finished for PR 18020 at commit
|
@@ -82,10 +82,10 @@ abstract class QueryPlan[PlanType <: QueryPlan[PlanType]] extends TreeNode[PlanT | |||
} | |||
|
|||
// Collect aliases from expressions, so we may avoid producing recursive constraints. | |||
private lazy val aliasMap = AttributeMap( | |||
(expressions ++ children.flatMap(_.expressions)).collect { | |||
protected lazy val aliasMap: AttributeMap[Expression] = AttributeMap( |
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.
protected
?
LGTM |
Test build #77031 has finished for PR 18020 at commit
|
Test build #77035 has finished for PR 18020 at commit
|
…ry (v2) ## What changes were proposed in this pull request? In the previous approach we used `aliasMap` to link an `Attribute` to the expression with potentially the form `f(a, b)`, but we only searched the `expressions` and `children.expressions` for this, which is not enough when an `Alias` may lies deep in the logical plan. In that case, we can't generate the valid equivalent constraint classes and thus we fail at preventing the recursive deductions. We fix this problem by collecting all `Alias`s from the logical plan. ## How was this patch tested? No additional test case is added, but do modified one test case to cover this situation. Author: Xingbo Jiang <xingbo.jiang@databricks.com> Closes #18020 from jiangxb1987/inferConstrants. (cherry picked from commit b7aac15) Signed-off-by: Xiao Li <gatorsmile@gmail.com>
Thanks! Merging to master/2.2. |
…ry (v2) ## What changes were proposed in this pull request? In the previous approach we used `aliasMap` to link an `Attribute` to the expression with potentially the form `f(a, b)`, but we only searched the `expressions` and `children.expressions` for this, which is not enough when an `Alias` may lies deep in the logical plan. In that case, we can't generate the valid equivalent constraint classes and thus we fail at preventing the recursive deductions. We fix this problem by collecting all `Alias`s from the logical plan. ## How was this patch tested? No additional test case is added, but do modified one test case to cover this situation. Author: Xingbo Jiang <xingbo.jiang@databricks.com> Closes apache#18020 from jiangxb1987/inferConstrants.
…ry (v2) ## What changes were proposed in this pull request? In the previous approach we used `aliasMap` to link an `Attribute` to the expression with potentially the form `f(a, b)`, but we only searched the `expressions` and `children.expressions` for this, which is not enough when an `Alias` may lies deep in the logical plan. In that case, we can't generate the valid equivalent constraint classes and thus we fail at preventing the recursive deductions. We fix this problem by collecting all `Alias`s from the logical plan. ## How was this patch tested? No additional test case is added, but do modified one test case to cover this situation. Author: Xingbo Jiang <xingbo.jiang@databricks.com> Closes apache#18020 from jiangxb1987/inferConstrants.
What changes were proposed in this pull request?
In the previous approach we used
aliasMap
to link anAttribute
to the expression with potentially the formf(a, b)
, but we only searched theexpressions
andchildren.expressions
for this, which is not enough when anAlias
may lies deep in the logical plan. In that case, we can't generate the valid equivalent constraint classes and thus we fail at preventing the recursive deductions.We fix this problem by collecting all
Alias
s from the logical plan.How was this patch tested?
No additional test case is added, but do modified one test case to cover this situation.