{"action":"created","comment":{"url":"https://api.github.com/repos/prestodb/presto/pulls/comments/122560370","pull_request_review_id":44692621,"id":122560370,"diff_hunk":"@@ -18,61 +18,37 @@\n import com.facebook.presto.spi.predicate.Domain;\n import com.facebook.presto.spi.predicate.Range;\n import com.facebook.presto.spi.predicate.TupleDomain;\n+import com.google.common.base.Joiner;\n+import com.google.common.base.VerifyException;\n import com.google.common.collect.ImmutableList;\n import com.google.common.collect.ImmutableMap;\n-import com.google.common.collect.ImmutableSet;\n \n+import java.util.ArrayList;\n import java.util.HashMap;\n import java.util.List;\n import java.util.Map;\n-import java.util.Set;\n \n import static com.facebook.presto.cassandra.util.CassandraCqlUtils.toCQLCompatibleString;\n-import static com.google.common.collect.Sets.cartesianProduct;\n import static java.util.Objects.requireNonNull;\n \n public class CassandraClusteringPredicatesExtractor\n {\n-    private final List<CassandraColumnHandle> clusteringColumns;\n-    private final TupleDomain<ColumnHandle> predicates;\n     private final ClusteringPushDownResult clusteringPushDownResult;\n+    private final TupleDomain<ColumnHandle> predicates;\n \n-    public CassandraClusteringPredicatesExtractor(List<CassandraColumnHandle> clusteringColumns, TupleDomain<ColumnHandle> predicates)\n+    public CassandraClusteringPredicatesExtractor(List<CassandraColumnHandle> clusteringColumns, TupleDomain<ColumnHandle> predicates, String cassandraVersion)\n     {\n-        this.clusteringColumns = ImmutableList.copyOf(requireNonNull(clusteringColumns, \"clusteringColumns is null\"));\n         this.predicates = requireNonNull(predicates, \"predicates is null\");\n-        this.clusteringPushDownResult = getClusteringKeysSet(clusteringColumns, predicates);\n+        this.clusteringPushDownResult = getClusteringKeysSet(clusteringColumns, predicates, cassandraVersion);\n     }\n \n     public List<String> getClusteringKeyPredicates()\n     {\n-        Set<List<Object>> pushedDownDomainValues = clusteringPushDownResult.getDomainValues();\n-\n-        if (pushedDownDomainValues.isEmpty()) {\n+        if (clusteringPushDownResult.getDomainQuery().isEmpty()) {\n             return ImmutableList.of();\n         }\n-\n-        ImmutableList.Builder<String> clusteringPredicates = ImmutableList.builder();\n-        for (List<Object> clusteringKeys : pushedDownDomainValues) {\n-            if (clusteringKeys.isEmpty()) {\n-                continue;\n-            }\n-\n-            StringBuilder stringBuilder = new StringBuilder();\n-\n-            for (int i = 0; i < clusteringKeys.size(); i++) {\n-                if (i > 0) {\n-                    stringBuilder.append(\" AND \");\n-                }\n-\n-                stringBuilder.append(CassandraCqlUtils.validColumnName(clusteringColumns.get(i).getName()));\n-                stringBuilder.append(\" = \");\n-                stringBuilder.append(CassandraCqlUtils.cqlValue(toCQLCompatibleString(clusteringKeys.get(i)), clusteringColumns.get(i).getCassandraType()));\n-            }\n-\n-            clusteringPredicates.add(stringBuilder.toString());\n-        }\n-        return clusteringPredicates.build();\n+        ImmutableList.Builder<String> clusteringColumnSql = ImmutableList.builder();\n+        return clusteringColumnSql.add(Joiner.on(\" AND \").join(clusteringPushDownResult.getDomainQuery())).build();","path":"presto-cassandra/src/main/java/com/facebook/presto/cassandra/CassandraClusteringPredicatesExtractor.java","position":null,"original_position":67,"commit_id":"28b4fcf7347d0a038a243dbf1d6c8730bedcd907","original_commit_id":"f7c7f54279b268f8bb0606402cf82178f5953c3b","user":{"login":"sumitkgec","id":25983215,"avatar_url":"https://avatars3.githubusercontent.com/u/25983215?v=3","gravatar_id":"","url":"https://api.github.com/users/sumitkgec","html_url":"https://github.com/sumitkgec","followers_url":"https://api.github.com/users/sumitkgec/followers","following_url":"https://api.github.com/users/sumitkgec/following{/other_user}","gists_url":"https://api.github.com/users/sumitkgec/gists{/gist_id}","starred_url":"https://api.github.com/users/sumitkgec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sumitkgec/subscriptions","organizations_url":"https://api.github.com/users/sumitkgec/orgs","repos_url":"https://api.github.com/users/sumitkgec/repos","events_url":"https://api.github.com/users/sumitkgec/events{/privacy}","received_events_url":"https://api.github.com/users/sumitkgec/received_events","type":"User","site_admin":false},"body":"Changes completed. Now `getClusteringKeyPredicates` also will return single `String` instead of `List<String>`.","created_at":"2017-06-17T04:16:29Z","updated_at":"2017-06-17T04:16:29Z","html_url":"https://github.com/prestodb/presto/pull/7833#discussion_r122560370","pull_request_url":"https://api.github.com/repos/prestodb/presto/pulls/7833","_links":{"self":{"href":"https://api.github.com/repos/prestodb/presto/pulls/comments/122560370"},"html":{"href":"https://github.com/prestodb/presto/pull/7833#discussion_r122560370"},"pull_request":{"href":"https://api.github.com/repos/prestodb/presto/pulls/7833"}}},"pull_request":{"url":"https://api.github.com/repos/prestodb/presto/pulls/7833","id":115953441,"html_url":"https://github.com/prestodb/presto/pull/7833","diff_url":"https://github.com/prestodb/presto/pull/7833.diff","patch_url":"https://github.com/prestodb/presto/pull/7833.patch","issue_url":"https://api.github.com/repos/prestodb/presto/issues/7833","number":7833,"state":"open","locked":false,"title":"Support clustering key predicate pushdown(Equal, IN and Range) in Cassandra","user":{"login":"sumitkgec","id":25983215,"avatar_url":"https://avatars3.githubusercontent.com/u/25983215?v=3","gravatar_id":"","url":"https://api.github.com/users/sumitkgec","html_url":"https://github.com/sumitkgec","followers_url":"https://api.github.com/users/sumitkgec/followers","following_url":"https://api.github.com/users/sumitkgec/following{/other_user}","gists_url":"https://api.github.com/users/sumitkgec/gists{/gist_id}","starred_url":"https://api.github.com/users/sumitkgec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sumitkgec/subscriptions","organizations_url":"https://api.github.com/users/sumitkgec/orgs","repos_url":"https://api.github.com/users/sumitkgec/repos","events_url":"https://api.github.com/users/sumitkgec/events{/privacy}","received_events_url":"https://api.github.com/users/sumitkgec/received_events","type":"User","site_admin":false},"body":"**Problem statement:** \r\nDue to predicate push down for clustering keys was missing, Presto performance was getting hit. It taking entire partition data out of Cassandra and doing the calculation, this can be faster if Presto will pass the partition and clustering keys to Cassandra and do the calculation on the small portion of the data.\r\n\r\nI opened this pull request to support Cassandra predicate pushdown on clustering columns(partition key pushdown already available in Presto).\r\n\r\nJust for reference - Cassandra allow below restriction in WHERE clause for SELECT statements(except Secondary Index)\r\n**Partition keys restrictions**\r\nThe partition key columns support only two operators(except token function): = and IN.\r\n**Clustering column restrictions**\r\nClustering columns support the =, IN, >, >=, <=, < restrictions. Range restrictions only allowed in the last clustering column being restricted. IN is only supported in the last clustering column in Cassandra version < 2.2.X. ","created_at":"2017-04-14T16:21:25Z","updated_at":"2017-06-17T04:16:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b72997a258704a7e7a67ffa8f1f1ac2be7ec651d","assignee":{"login":"cawallin","id":3652644,"avatar_url":"https://avatars0.githubusercontent.com/u/3652644?v=3","gravatar_id":"","url":"https://api.github.com/users/cawallin","html_url":"https://github.com/cawallin","followers_url":"https://api.github.com/users/cawallin/followers","following_url":"https://api.github.com/users/cawallin/following{/other_user}","gists_url":"https://api.github.com/users/cawallin/gists{/gist_id}","starred_url":"https://api.github.com/users/cawallin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cawallin/subscriptions","organizations_url":"https://api.github.com/users/cawallin/orgs","repos_url":"https://api.github.com/users/cawallin/repos","events_url":"https://api.github.com/users/cawallin/events{/privacy}","received_events_url":"https://api.github.com/users/cawallin/received_events","type":"User","site_admin":false},"assignees":[{"login":"cawallin","id":3652644,"avatar_url":"https://avatars0.githubusercontent.com/u/3652644?v=3","gravatar_id":"","url":"https://api.github.com/users/cawallin","html_url":"https://github.com/cawallin","followers_url":"https://api.github.com/users/cawallin/followers","following_url":"https://api.github.com/users/cawallin/following{/other_user}","gists_url":"https://api.github.com/users/cawallin/gists{/gist_id}","starred_url":"https://api.github.com/users/cawallin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cawallin/subscriptions","organizations_url":"https://api.github.com/users/cawallin/orgs","repos_url":"https://api.github.com/users/cawallin/repos","events_url":"https://api.github.com/users/cawallin/events{/privacy}","received_events_url":"https://api.github.com/users/cawallin/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/prestodb/presto/pulls/7833/commits","review_comments_url":"https://api.github.com/repos/prestodb/presto/pulls/7833/comments","review_comment_url":"https://api.github.com/repos/prestodb/presto/pulls/comments{/number}","comments_url":"https://api.github.com/repos/prestodb/presto/issues/7833/comments","statuses_url":"https://api.github.com/repos/prestodb/presto/statuses/28b4fcf7347d0a038a243dbf1d6c8730bedcd907","head":{"label":"sumitkgec:master","ref":"master","sha":"28b4fcf7347d0a038a243dbf1d6c8730bedcd907","user":{"login":"sumitkgec","id":25983215,"avatar_url":"https://avatars3.githubusercontent.com/u/25983215?v=3","gravatar_id":"","url":"https://api.github.com/users/sumitkgec","html_url":"https://github.com/sumitkgec","followers_url":"https://api.github.com/users/sumitkgec/followers","following_url":"https://api.github.com/users/sumitkgec/following{/other_user}","gists_url":"https://api.github.com/users/sumitkgec/gists{/gist_id}","starred_url":"https://api.github.com/users/sumitkgec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sumitkgec/subscriptions","organizations_url":"https://api.github.com/users/sumitkgec/orgs","repos_url":"https://api.github.com/users/sumitkgec/repos","events_url":"https://api.github.com/users/sumitkgec/events{/privacy}","received_events_url":"https://api.github.com/users/sumitkgec/received_events","type":"User","site_admin":false},"repo":{"id":88279887,"name":"presto","full_name":"sumitkgec/presto","owner":{"login":"sumitkgec","id":25983215,"avatar_url":"https://avatars3.githubusercontent.com/u/25983215?v=3","gravatar_id":"","url":"https://api.github.com/users/sumitkgec","html_url":"https://github.com/sumitkgec","followers_url":"https://api.github.com/users/sumitkgec/followers","following_url":"https://api.github.com/users/sumitkgec/following{/other_user}","gists_url":"https://api.github.com/users/sumitkgec/gists{/gist_id}","starred_url":"https://api.github.com/users/sumitkgec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sumitkgec/subscriptions","organizations_url":"https://api.github.com/users/sumitkgec/orgs","repos_url":"https://api.github.com/users/sumitkgec/repos","events_url":"https://api.github.com/users/sumitkgec/events{/privacy}","received_events_url":"https://api.github.com/users/sumitkgec/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sumitkgec/presto","description":"Distributed SQL query engine for big data","fork":true,"url":"https://api.github.com/repos/sumitkgec/presto","forks_url":"https://api.github.com/repos/sumitkgec/presto/forks","keys_url":"https://api.github.com/repos/sumitkgec/presto/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sumitkgec/presto/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sumitkgec/presto/teams","hooks_url":"https://api.github.com/repos/sumitkgec/presto/hooks","issue_events_url":"https://api.github.com/repos/sumitkgec/presto/issues/events{/number}","events_url":"https://api.github.com/repos/sumitkgec/presto/events","assignees_url":"https://api.github.com/repos/sumitkgec/presto/assignees{/user}","branches_url":"https://api.github.com/repos/sumitkgec/presto/branches{/branch}","tags_url":"https://api.github.com/repos/sumitkgec/presto/tags","blobs_url":"https://api.github.com/repos/sumitkgec/presto/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sumitkgec/presto/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sumitkgec/presto/git/refs{/sha}","trees_url":"https://api.github.com/repos/sumitkgec/presto/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sumitkgec/presto/statuses/{sha}","languages_url":"https://api.github.com/repos/sumitkgec/presto/languages","stargazers_url":"https://api.github.com/repos/sumitkgec/presto/stargazers","contributors_url":"https://api.github.com/repos/sumitkgec/presto/contributors","subscribers_url":"https://api.github.com/repos/sumitkgec/presto/subscribers","subscription_url":"https://api.github.com/repos/sumitkgec/presto/subscription","commits_url":"https://api.github.com/repos/sumitkgec/presto/commits{/sha}","git_commits_url":"https://api.github.com/repos/sumitkgec/presto/git/commits{/sha}","comments_url":"https://api.github.com/repos/sumitkgec/presto/comments{/number}","issue_comment_url":"https://api.github.com/repos/sumitkgec/presto/issues/comments{/number}","contents_url":"https://api.github.com/repos/sumitkgec/presto/contents/{+path}","compare_url":"https://api.github.com/repos/sumitkgec/presto/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sumitkgec/presto/merges","archive_url":"https://api.github.com/repos/sumitkgec/presto/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sumitkgec/presto/downloads","issues_url":"https://api.github.com/repos/sumitkgec/presto/issues{/number}","pulls_url":"https://api.github.com/repos/sumitkgec/presto/pulls{/number}","milestones_url":"https://api.github.com/repos/sumitkgec/presto/milestones{/number}","notifications_url":"https://api.github.com/repos/sumitkgec/presto/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sumitkgec/presto/labels{/name}","releases_url":"https://api.github.com/repos/sumitkgec/presto/releases{/id}","deployments_url":"https://api.github.com/repos/sumitkgec/presto/deployments","created_at":"2017-04-14T15:34:05Z","updated_at":"2017-04-14T15:34:22Z","pushed_at":"2017-06-17T03:54:18Z","git_url":"git://github.com/sumitkgec/presto.git","ssh_url":"git@github.com:sumitkgec/presto.git","clone_url":"https://github.com/sumitkgec/presto.git","svn_url":"https://github.com/sumitkgec/presto","homepage":"https://prestodb.io","size":74310,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"prestodb:master","ref":"master","sha":"696825b0db180ebd982bc46c8ae71412731f8886","user":{"login":"prestodb","id":6882181,"avatar_url":"https://avatars3.githubusercontent.com/u/6882181?v=3","gravatar_id":"","url":"https://api.github.com/users/prestodb","html_url":"https://github.com/prestodb","followers_url":"https://api.github.com/users/prestodb/followers","following_url":"https://api.github.com/users/prestodb/following{/other_user}","gists_url":"https://api.github.com/users/prestodb/gists{/gist_id}","starred_url":"https://api.github.com/users/prestodb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prestodb/subscriptions","organizations_url":"https://api.github.com/users/prestodb/orgs","repos_url":"https://api.github.com/users/prestodb/repos","events_url":"https://api.github.com/users/prestodb/events{/privacy}","received_events_url":"https://api.github.com/users/prestodb/received_events","type":"Organization","site_admin":false},"repo":{"id":5349565,"name":"presto","full_name":"prestodb/presto","owner":{"login":"prestodb","id":6882181,"avatar_url":"https://avatars3.githubusercontent.com/u/6882181?v=3","gravatar_id":"","url":"https://api.github.com/users/prestodb","html_url":"https://github.com/prestodb","followers_url":"https://api.github.com/users/prestodb/followers","following_url":"https://api.github.com/users/prestodb/following{/other_user}","gists_url":"https://api.github.com/users/prestodb/gists{/gist_id}","starred_url":"https://api.github.com/users/prestodb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prestodb/subscriptions","organizations_url":"https://api.github.com/users/prestodb/orgs","repos_url":"https://api.github.com/users/prestodb/repos","events_url":"https://api.github.com/users/prestodb/events{/privacy}","received_events_url":"https://api.github.com/users/prestodb/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/prestodb/presto","description":"Distributed SQL query engine for big data","fork":false,"url":"https://api.github.com/repos/prestodb/presto","forks_url":"https://api.github.com/repos/prestodb/presto/forks","keys_url":"https://api.github.com/repos/prestodb/presto/keys{/key_id}","collaborators_url":"https://api.github.com/repos/prestodb/presto/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/prestodb/presto/teams","hooks_url":"https://api.github.com/repos/prestodb/presto/hooks","issue_events_url":"https://api.github.com/repos/prestodb/presto/issues/events{/number}","events_url":"https://api.github.com/repos/prestodb/presto/events","assignees_url":"https://api.github.com/repos/prestodb/presto/assignees{/user}","branches_url":"https://api.github.com/repos/prestodb/presto/branches{/branch}","tags_url":"https://api.github.com/repos/prestodb/presto/tags","blobs_url":"https://api.github.com/repos/prestodb/presto/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/prestodb/presto/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/prestodb/presto/git/refs{/sha}","trees_url":"https://api.github.com/repos/prestodb/presto/git/trees{/sha}","statuses_url":"https://api.github.com/repos/prestodb/presto/statuses/{sha}","languages_url":"https://api.github.com/repos/prestodb/presto/languages","stargazers_url":"https://api.github.com/repos/prestodb/presto/stargazers","contributors_url":"https://api.github.com/repos/prestodb/presto/contributors","subscribers_url":"https://api.github.com/repos/prestodb/presto/subscribers","subscription_url":"https://api.github.com/repos/prestodb/presto/subscription","commits_url":"https://api.github.com/repos/prestodb/presto/commits{/sha}","git_commits_url":"https://api.github.com/repos/prestodb/presto/git/commits{/sha}","comments_url":"https://api.github.com/repos/prestodb/presto/comments{/number}","issue_comment_url":"https://api.github.com/repos/prestodb/presto/issues/comments{/number}","contents_url":"https://api.github.com/repos/prestodb/presto/contents/{+path}","compare_url":"https://api.github.com/repos/prestodb/presto/compare/{base}...{head}","merges_url":"https://api.github.com/repos/prestodb/presto/merges","archive_url":"https://api.github.com/repos/prestodb/presto/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/prestodb/presto/downloads","issues_url":"https://api.github.com/repos/prestodb/presto/issues{/number}","pulls_url":"https://api.github.com/repos/prestodb/presto/pulls{/number}","milestones_url":"https://api.github.com/repos/prestodb/presto/milestones{/number}","notifications_url":"https://api.github.com/repos/prestodb/presto/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/prestodb/presto/labels{/name}","releases_url":"https://api.github.com/repos/prestodb/presto/releases{/id}","deployments_url":"https://api.github.com/repos/prestodb/presto/deployments","created_at":"2012-08-09T01:03:37Z","updated_at":"2017-06-17T00:36:40Z","pushed_at":"2017-06-17T03:54:23Z","git_url":"git://github.com/prestodb/presto.git","ssh_url":"git@github.com:prestodb/presto.git","clone_url":"https://github.com/prestodb/presto.git","svn_url":"https://github.com/prestodb/presto","homepage":"https://prestodb.io","size":74579,"stargazers_count":6149,"watchers_count":6149,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1992,"mirror_url":null,"open_issues_count":952,"forks":1992,"open_issues":952,"watchers":6149,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/prestodb/presto/pulls/7833"},"html":{"href":"https://github.com/prestodb/presto/pull/7833"},"issue":{"href":"https://api.github.com/repos/prestodb/presto/issues/7833"},"comments":{"href":"https://api.github.com/repos/prestodb/presto/issues/7833/comments"},"review_comments":{"href":"https://api.github.com/repos/prestodb/presto/pulls/7833/comments"},"review_comment":{"href":"https://api.github.com/repos/prestodb/presto/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/prestodb/presto/pulls/7833/commits"},"statuses":{"href":"https://api.github.com/repos/prestodb/presto/statuses/28b4fcf7347d0a038a243dbf1d6c8730bedcd907"}}}}
{"actor":{"display_login":"sumitkgec"}}