-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-18063][SQL] Failed to infer constraints over multiple aliases #15597
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
Conversation
|
Test build #67379 has finished for PR 15597 at commit
|
|
Test build #67433 has finished for PR 15597 at commit
|
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.
Looks good modulo a couple of comments. Thanks!
| */ | ||
| protected def getAliasedConstraints(projectList: Seq[NamedExpression]): Set[Expression] = { | ||
| projectList.flatMap { | ||
| var aliasedConstraints = child.constraints.toSet |
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.
Remove toSet (ExpressionSet should support all these operations)
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 transformed child.constraints to Set[Expression] as we need to apply ++= operator on it.
| case _ => // Don't change. | ||
| } | ||
|
|
||
| aliasedConstraints |
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.
This should really return aliasedConstraints -- child.constraints. Perhaps rename aliasedConstraints to allConstraints and then return allConstraints -- child.constraints?
|
@sameeragarwal I've addressed your comments! Thank you! |
|
Test build #67504 has finished for PR 15597 at commit
|
|
LGTM, thanks! |
|
Just to be extra safe, it'd be great to re-run the test suite on this once #15319 is merged. |
|
retest this please |
|
Test build #67583 has finished for PR 15597 at commit
|
|
Merging this in master/branch-2.0. |
## What changes were proposed in this pull request?
The `UnaryNode.getAliasedConstraints` function fails to replace all expressions by their alias where constraints contains more than one expression to be replaced.
For example:
```
val tr = LocalRelation('a.int, 'b.string, 'c.int)
val multiAlias = tr.where('a === 'c + 10).select('a.as('x), 'c.as('y))
multiAlias.analyze.constraints
```
currently outputs:
```
ExpressionSet(Seq(
IsNotNull(resolveColumn(multiAlias.analyze, "x")),
IsNotNull(resolveColumn(multiAlias.analyze, "y"))
)
```
The constraint `resolveColumn(multiAlias.analyze, "x") === resolveColumn(multiAlias.analyze, "y") + 10)` is missing.
## How was this patch tested?
Add new test cases in `ConstraintPropagationSuite`.
Author: jiangxingbo <[email protected]>
Closes #15597 from jiangxb1987/alias-constraints.
(cherry picked from commit fa7d9d7)
Signed-off-by: Reynold Xin <[email protected]>
## What changes were proposed in this pull request?
The `UnaryNode.getAliasedConstraints` function fails to replace all expressions by their alias where constraints contains more than one expression to be replaced.
For example:
```
val tr = LocalRelation('a.int, 'b.string, 'c.int)
val multiAlias = tr.where('a === 'c + 10).select('a.as('x), 'c.as('y))
multiAlias.analyze.constraints
```
currently outputs:
```
ExpressionSet(Seq(
IsNotNull(resolveColumn(multiAlias.analyze, "x")),
IsNotNull(resolveColumn(multiAlias.analyze, "y"))
)
```
The constraint `resolveColumn(multiAlias.analyze, "x") === resolveColumn(multiAlias.analyze, "y") + 10)` is missing.
## How was this patch tested?
Add new test cases in `ConstraintPropagationSuite`.
Author: jiangxingbo <[email protected]>
Closes apache#15597 from jiangxb1987/alias-constraints.
## What changes were proposed in this pull request?
The `UnaryNode.getAliasedConstraints` function fails to replace all expressions by their alias where constraints contains more than one expression to be replaced.
For example:
```
val tr = LocalRelation('a.int, 'b.string, 'c.int)
val multiAlias = tr.where('a === 'c + 10).select('a.as('x), 'c.as('y))
multiAlias.analyze.constraints
```
currently outputs:
```
ExpressionSet(Seq(
IsNotNull(resolveColumn(multiAlias.analyze, "x")),
IsNotNull(resolveColumn(multiAlias.analyze, "y"))
)
```
The constraint `resolveColumn(multiAlias.analyze, "x") === resolveColumn(multiAlias.analyze, "y") + 10)` is missing.
## How was this patch tested?
Add new test cases in `ConstraintPropagationSuite`.
Author: jiangxingbo <[email protected]>
Closes apache#15597 from jiangxb1987/alias-constraints.
What changes were proposed in this pull request?
The
UnaryNode.getAliasedConstraintsfunction fails to replace all expressions by their alias where constraints contains more than one expression to be replaced.For example:
currently outputs:
The constraint
resolveColumn(multiAlias.analyze, "x") === resolveColumn(multiAlias.analyze, "y") + 10)is missing.How was this patch tested?
Add new test cases in
ConstraintPropagationSuite.