Skip to content

Conversation

@jiangxb1987
Copy link
Contributor

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.

@SparkQA
Copy link

SparkQA commented Oct 22, 2016

Test build #67379 has finished for PR 15597 at commit 2fe728f.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@rxin
Copy link
Contributor

rxin commented Oct 23, 2016

cc @sameeragarwal

@SparkQA
Copy link

SparkQA commented Oct 24, 2016

Test build #67433 has finished for PR 15597 at commit 32e0b36.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

Copy link
Member

@sameeragarwal sameeragarwal left a 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
Copy link
Member

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)

Copy link
Contributor Author

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
Copy link
Member

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?

@jiangxb1987
Copy link
Contributor Author

@sameeragarwal I've addressed your comments! Thank you!

@SparkQA
Copy link

SparkQA commented Oct 25, 2016

Test build #67504 has finished for PR 15597 at commit 3f07493.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@sameeragarwal
Copy link
Member

LGTM, thanks!

@sameeragarwal
Copy link
Member

Just to be extra safe, it'd be great to re-run the test suite on this once #15319 is merged.

@hvanhovell
Copy link
Contributor

retest this please

@SparkQA
Copy link

SparkQA commented Oct 26, 2016

Test build #67583 has finished for PR 15597 at commit 3f07493.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@rxin
Copy link
Contributor

rxin commented Oct 26, 2016

Merging this in master/branch-2.0.

asfgit pushed a commit that referenced this pull request Oct 26, 2016
## 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]>
@asfgit asfgit closed this in fa7d9d7 Oct 26, 2016
@jiangxb1987 jiangxb1987 deleted the alias-constraints branch October 27, 2016 02:02
robert3005 pushed a commit to palantir/spark that referenced this pull request Nov 1, 2016
## 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.
uzadude pushed a commit to uzadude/spark that referenced this pull request Jan 27, 2017
## 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants