{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/34185000","id":34185000,"diff_hunk":"@@ -689,6 +666,34 @@ private[hive] case class MetastoreRelation\n     }\n   )\n \n+  def getHiveQlPartitions(filter: Option[String]): Seq[Partition] = {","path":"sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveMetastoreCatalog.scala","position":56,"original_position":56,"commit_id":"dce7abf40003ad36675034e9467a5003f7e551ad","original_commit_id":"dce7abf40003ad36675034e9467a5003f7e551ad","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},"body":"minor: I'd consider having this function also take an `Expression` or a `Seq[Expression]` so that the conversion from expressions to string is isolated from the rest of the code.","created_at":"2015-07-08T18:56:25Z","updated_at":"2015-07-08T18:56:25Z","html_url":"https://github.com/apache/spark/pull/7216#discussion_r34185000","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/7216","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/34185000"},"html":{"href":"https://github.com/apache/spark/pull/7216#discussion_r34185000"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/7216"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/7216","id":39197564,"html_url":"https://github.com/apache/spark/pull/7216","diff_url":"https://github.com/apache/spark/pull/7216.diff","patch_url":"https://github.com/apache/spark/pull/7216.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/7216","number":7216,"state":"open","locked":false,"title":"[SPARK-6910] [SQL] Support for pushing predicates down to metastore for partition pruning","user":{"login":"piaozhexiu","id":179618,"avatar_url":"https://avatars.githubusercontent.com/u/179618?v=3","gravatar_id":"","url":"https://api.github.com/users/piaozhexiu","html_url":"https://github.com/piaozhexiu","followers_url":"https://api.github.com/users/piaozhexiu/followers","following_url":"https://api.github.com/users/piaozhexiu/following{/other_user}","gists_url":"https://api.github.com/users/piaozhexiu/gists{/gist_id}","starred_url":"https://api.github.com/users/piaozhexiu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/piaozhexiu/subscriptions","organizations_url":"https://api.github.com/users/piaozhexiu/orgs","repos_url":"https://api.github.com/users/piaozhexiu/repos","events_url":"https://api.github.com/users/piaozhexiu/events{/privacy}","received_events_url":"https://api.github.com/users/piaozhexiu/received_events","type":"User","site_admin":false},"body":"This PR supersedes my old one #6921. Since my patch has changed quite a bit, I am opening a new PR to make it easier to review.\r\n\r\nThe changes include-\r\n* Implement `toMetastoreFilter()` function in `HiveShim` that takes `Seq[Expression]` and converts them into a filter string for Hive metastore.\r\n * This functions matches all the `AttributeReference` + `BinaryComparisonOp` + `Integral/StringType` patterns in `Seq[Expression]` and fold them into a string.\r\n* Change `hiveQlPartitions` field in `MetastoreRelation` to `getHiveQlPartitions()` function that takes a filter string parameter.\r\n* Call `getHiveQlPartitions()` in `HiveTableScan` with a filter string.\r\n\r\nBut there are some cases in which predicate pushdown is disabled-\r\n\r\nCase | Predicate pushdown\r\n------- | -----------------------------\r\nHive integral and string types | Yes\r\nHive varchar type | No\r\nHive 0.13 and newer | Yes\r\nHive 0.12 and older | No\r\nconvertMetastoreParquet=false | Yes\r\nconvertMetastoreParquet=true | No\r\n\r\nIn case of `convertMetastoreParquet=true`, predicates are not pushed down because this conversion happens in an `Analyzer` rule (`HiveMetastoreCatalog.ParquetConversions`). At this point, `HiveTableScan` hasn't run, so predicates are not available. But reading the source code, I think it is intentional to convert the entire Hive table w/ all the partitions into `ParquetRelation` because then `ParquetRelation` can be cached and reused for any query against that table. Please correct me if I am wrong.\r\n\r\ncc @marmbrus ","created_at":"2015-07-03T21:54:13Z","updated_at":"2015-07-08T18:56:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e7a475d0b273e5e74b4e5a00b6a88f8300933564","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/7216/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/7216/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/spark/issues/7216/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/dce7abf40003ad36675034e9467a5003f7e551ad","head":{"label":"piaozhexiu:SPARK-6910-2","ref":"SPARK-6910-2","sha":"dce7abf40003ad36675034e9467a5003f7e551ad","user":{"login":"piaozhexiu","id":179618,"avatar_url":"https://avatars.githubusercontent.com/u/179618?v=3","gravatar_id":"","url":"https://api.github.com/users/piaozhexiu","html_url":"https://github.com/piaozhexiu","followers_url":"https://api.github.com/users/piaozhexiu/followers","following_url":"https://api.github.com/users/piaozhexiu/following{/other_user}","gists_url":"https://api.github.com/users/piaozhexiu/gists{/gist_id}","starred_url":"https://api.github.com/users/piaozhexiu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/piaozhexiu/subscriptions","organizations_url":"https://api.github.com/users/piaozhexiu/orgs","repos_url":"https://api.github.com/users/piaozhexiu/repos","events_url":"https://api.github.com/users/piaozhexiu/events{/privacy}","received_events_url":"https://api.github.com/users/piaozhexiu/received_events","type":"User","site_admin":false},"repo":{"id":31330425,"name":"spark","full_name":"piaozhexiu/spark","owner":{"login":"piaozhexiu","id":179618,"avatar_url":"https://avatars.githubusercontent.com/u/179618?v=3","gravatar_id":"","url":"https://api.github.com/users/piaozhexiu","html_url":"https://github.com/piaozhexiu","followers_url":"https://api.github.com/users/piaozhexiu/followers","following_url":"https://api.github.com/users/piaozhexiu/following{/other_user}","gists_url":"https://api.github.com/users/piaozhexiu/gists{/gist_id}","starred_url":"https://api.github.com/users/piaozhexiu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/piaozhexiu/subscriptions","organizations_url":"https://api.github.com/users/piaozhexiu/orgs","repos_url":"https://api.github.com/users/piaozhexiu/repos","events_url":"https://api.github.com/users/piaozhexiu/events{/privacy}","received_events_url":"https://api.github.com/users/piaozhexiu/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/piaozhexiu/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/piaozhexiu/spark","forks_url":"https://api.github.com/repos/piaozhexiu/spark/forks","keys_url":"https://api.github.com/repos/piaozhexiu/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/piaozhexiu/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/piaozhexiu/spark/teams","hooks_url":"https://api.github.com/repos/piaozhexiu/spark/hooks","issue_events_url":"https://api.github.com/repos/piaozhexiu/spark/issues/events{/number}","events_url":"https://api.github.com/repos/piaozhexiu/spark/events","assignees_url":"https://api.github.com/repos/piaozhexiu/spark/assignees{/user}","branches_url":"https://api.github.com/repos/piaozhexiu/spark/branches{/branch}","tags_url":"https://api.github.com/repos/piaozhexiu/spark/tags","blobs_url":"https://api.github.com/repos/piaozhexiu/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/piaozhexiu/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/piaozhexiu/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/piaozhexiu/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/piaozhexiu/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/piaozhexiu/spark/languages","stargazers_url":"https://api.github.com/repos/piaozhexiu/spark/stargazers","contributors_url":"https://api.github.com/repos/piaozhexiu/spark/contributors","subscribers_url":"https://api.github.com/repos/piaozhexiu/spark/subscribers","subscription_url":"https://api.github.com/repos/piaozhexiu/spark/subscription","commits_url":"https://api.github.com/repos/piaozhexiu/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/piaozhexiu/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/piaozhexiu/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/piaozhexiu/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/piaozhexiu/spark/contents/{+path}","compare_url":"https://api.github.com/repos/piaozhexiu/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/piaozhexiu/spark/merges","archive_url":"https://api.github.com/repos/piaozhexiu/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/piaozhexiu/spark/downloads","issues_url":"https://api.github.com/repos/piaozhexiu/spark/issues{/number}","pulls_url":"https://api.github.com/repos/piaozhexiu/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/piaozhexiu/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/piaozhexiu/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/piaozhexiu/spark/labels{/name}","releases_url":"https://api.github.com/repos/piaozhexiu/spark/releases{/id}","created_at":"2015-02-25T18:57:29Z","updated_at":"2015-04-02T00:01:52Z","pushed_at":"2015-07-03T20:51:04Z","git_url":"git://github.com/piaozhexiu/spark.git","ssh_url":"git@github.com:piaozhexiu/spark.git","clone_url":"https://github.com/piaozhexiu/spark.git","svn_url":"https://github.com/piaozhexiu/spark","homepage":null,"size":108864,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"apache:master","ref":"master","sha":"2848f4da47d5c395de93ab9960bd905edfbd3439","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":17165658,"name":"spark","full_name":"apache/spark","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/spark","description":"Mirror of Apache Spark","fork":false,"url":"https://api.github.com/repos/apache/spark","forks_url":"https://api.github.com/repos/apache/spark/forks","keys_url":"https://api.github.com/repos/apache/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/spark/teams","hooks_url":"https://api.github.com/repos/apache/spark/hooks","issue_events_url":"https://api.github.com/repos/apache/spark/issues/events{/number}","events_url":"https://api.github.com/repos/apache/spark/events","assignees_url":"https://api.github.com/repos/apache/spark/assignees{/user}","branches_url":"https://api.github.com/repos/apache/spark/branches{/branch}","tags_url":"https://api.github.com/repos/apache/spark/tags","blobs_url":"https://api.github.com/repos/apache/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/spark/languages","stargazers_url":"https://api.github.com/repos/apache/spark/stargazers","contributors_url":"https://api.github.com/repos/apache/spark/contributors","subscribers_url":"https://api.github.com/repos/apache/spark/subscribers","subscription_url":"https://api.github.com/repos/apache/spark/subscription","commits_url":"https://api.github.com/repos/apache/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/spark/contents/{+path}","compare_url":"https://api.github.com/repos/apache/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/spark/merges","archive_url":"https://api.github.com/repos/apache/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/spark/downloads","issues_url":"https://api.github.com/repos/apache/spark/issues{/number}","pulls_url":"https://api.github.com/repos/apache/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/spark/labels{/name}","releases_url":"https://api.github.com/repos/apache/spark/releases{/id}","created_at":"2014-02-25T08:00:08Z","updated_at":"2015-07-08T17:59:55Z","pushed_at":"2015-07-08T18:56:11Z","git_url":"git://github.com/apache/spark.git","ssh_url":"git@github.com:apache/spark.git","clone_url":"https://github.com/apache/spark.git","svn_url":"https://github.com/apache/spark","homepage":null,"size":1508544,"stargazers_count":4678,"watchers_count":4678,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":4145,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":351,"forks":4145,"open_issues":351,"watchers":4678,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/7216"},"html":{"href":"https://github.com/apache/spark/pull/7216"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/7216"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/7216/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/7216/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/7216/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/dce7abf40003ad36675034e9467a5003f7e551ad"}}}}