{"action":"created","issue":{"url":"https://api.github.com/repos/apache/spark/issues/11338","repository_url":"https://api.github.com/repos/apache/spark","labels_url":"https://api.github.com/repos/apache/spark/issues/11338/labels{/name}","comments_url":"https://api.github.com/repos/apache/spark/issues/11338/comments","events_url":"https://api.github.com/repos/apache/spark/issues/11338/events","html_url":"https://github.com/apache/spark/pull/11338","id":135915467,"number":11338,"title":"[SPARK-13092][SQL] Add ExpressionSet for constraint tracking","user":{"login":"marmbrus","id":527,"avatar_url":"https://avatars.githubusercontent.com/u/527?v=3","gravatar_id":"","url":"https://api.github.com/users/marmbrus","html_url":"https://github.com/marmbrus","followers_url":"https://api.github.com/users/marmbrus/followers","following_url":"https://api.github.com/users/marmbrus/following{/other_user}","gists_url":"https://api.github.com/users/marmbrus/gists{/gist_id}","starred_url":"https://api.github.com/users/marmbrus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marmbrus/subscriptions","organizations_url":"https://api.github.com/users/marmbrus/orgs","repos_url":"https://api.github.com/users/marmbrus/repos","events_url":"https://api.github.com/users/marmbrus/events{/privacy}","received_events_url":"https://api.github.com/users/marmbrus/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2016-02-24T00:54:33Z","updated_at":"2016-02-25T01:33:01Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/11338","html_url":"https://github.com/apache/spark/pull/11338","diff_url":"https://github.com/apache/spark/pull/11338.diff","patch_url":"https://github.com/apache/spark/pull/11338.patch"},"body":"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).\r\n\r\n```scala\r\nval set = AttributeSet('a + 1 :: 1 + 'a :: Nil)\r\n\r\nset.iterator => Iterator('a + 1)\r\nset.contains('a + 1) => true\r\nset.contains(1 + 'a) => true\r\nset.contains('a + 2) => false\r\n```\r\n\r\nOther relevant changes include:\r\n - Since this concept overlaps with the existing `semanticEquals` and `semanticHash`, those functions are also ported to this new infrastructure.\r\n - A memoized `canonicalized` version of the expression is added as a `lazy val` to `Expression` and is used by both `semanticEquals` and `ExpressionSet`.\r\n - A set of unit tests for `ExpressionSet` are added\r\n - Tests which expect `semanticEquals` to be less intelligent than it now is are updated.\r\n\r\nAs 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.`"},"comment":{"url":"https://api.github.com/repos/apache/spark/issues/comments/188551193","html_url":"https://github.com/apache/spark/pull/11338#issuecomment-188551193","issue_url":"https://api.github.com/repos/apache/spark/issues/11338","id":188551193,"user":{"login":"yhuai","id":2072857,"avatar_url":"https://avatars.githubusercontent.com/u/2072857?v=3","gravatar_id":"","url":"https://api.github.com/users/yhuai","html_url":"https://github.com/yhuai","followers_url":"https://api.github.com/users/yhuai/followers","following_url":"https://api.github.com/users/yhuai/following{/other_user}","gists_url":"https://api.github.com/users/yhuai/gists{/gist_id}","starred_url":"https://api.github.com/users/yhuai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yhuai/subscriptions","organizations_url":"https://api.github.com/users/yhuai/orgs","repos_url":"https://api.github.com/users/yhuai/repos","events_url":"https://api.github.com/users/yhuai/events{/privacy}","received_events_url":"https://api.github.com/users/yhuai/received_events","type":"User","site_admin":false},"created_at":"2016-02-25T01:33:01Z","updated_at":"2016-02-25T01:33:01Z","body":"test this please"}}