GitHub user marmbrus opened a pull request:
https://github.com/apache/spark/pull/11338
[SPARK-13092][SQL] Add ExpressionSet for constraint tracking
This PR adds a new abstraction called an `ExpressionSet` which attempts to
canonicalize expressions to remove cosmetic differences. Deterministic
expressions that are in the set after canonicalization will always return the
same answer given the same input (i.e. false positives should not be possible).
However, it is possible that two canonical expressions that are not equal will
in fact return the same answer given any input (i.e. false negatives are
possible).
```scala
val set = AttributeSet(a + 1, 1 + a)
set.iterator => Iterator(a + 1)
set.contains(a + 1) => true
set.contains(1 + a) => true
set.contains(a + 2) => false
```
Other relevant changes include:
- Since this concept overlaps with the existing `semanticEquals` and
`semanticHash`, those functions are also ported to this new infrastructure.
- A memoized `canonicalized` version of the expression is added as a `lazy
val` to `Expression` and is used by both `semanticEquals` and `ExpressionSet`.
- A set of unit tests for `ExpressionSet` are added
- Tests which expect `semanticEquals` to be less intelligent than it now
is are updated.
As a followup, we should consider auditing the places where we do `O(n)`
`semanticEquals` operations and replace them with `ExpressionSet`. We should
also consider consolidating `AttributeSet` as a specialized factory for an
`ExpressionSet.`
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/marmbrus/spark expressionSet
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/11338.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #11338
----
commit 2a4f4de5f27cda3e5ad1bb899e45f06b6560ab4d
Author: Michael Armbrust <[email protected]>
Date: 2016-02-24T00:46:31Z
[SPARK-13092][SQL] Add ExpressionSet for constraint tracking
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]