{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/75967137","id":75967137,"diff_hunk":"@@ -237,21 +237,26 @@ private[hive] class HiveMetastoreCatalog(sparkSession: SparkSession) extends Log\n           new Path(metastoreRelation.catalogTable.storage.locationUri.get),\n           partitionSpec)\n \n-        val inferredSchema = if (fileType.equals(\"parquet\")) {\n-          val inferredSchema =\n-            defaultSource.inferSchema(sparkSession, options, fileCatalog.allFiles())\n-          inferredSchema.map { inferred =>\n-            ParquetFileFormat.mergeMetastoreParquetSchema(metastoreSchema, inferred)\n-          }.getOrElse(metastoreSchema)\n-        } else {\n-          defaultSource.inferSchema(sparkSession, options, fileCatalog.allFiles()).get\n+        val inferredSchema =\n+          defaultSource.inferSchema(sparkSession, options, fileCatalog.allFiles())\n+        val schema = fileType match {\n+          case \"parquet\" =>\n+            // For Parquet, get correct schema by merging Metastore schema data types\n+            // and Parquet schema field names.\n+            inferredSchema.map { schema =>\n+              ParquetFileFormat.mergeMetastoreParquetSchema(metastoreSchema, schema)\n+            }.getOrElse(metastoreSchema)\n+          case \"orc\" =>\n+            inferredSchema.getOrElse(metastoreSchema)\n+          case _ =>\n+            inferredSchema.get","path":"sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveMetastoreCatalog.scala","position":null,"original_position":24,"commit_id":"eb8a955e9fd39b2c8b9b88cbc1f01b1937af1189","original_commit_id":"9a8838a962a347db7303944c0d911f1417fb80e7","user":{"login":"rajeshbalamohan","id":323339,"avatar_url":"https://avatars.githubusercontent.com/u/323339?v=3","gravatar_id":"","url":"https://api.github.com/users/rajeshbalamohan","html_url":"https://github.com/rajeshbalamohan","followers_url":"https://api.github.com/users/rajeshbalamohan/followers","following_url":"https://api.github.com/users/rajeshbalamohan/following{/other_user}","gists_url":"https://api.github.com/users/rajeshbalamohan/gists{/gist_id}","starred_url":"https://api.github.com/users/rajeshbalamohan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rajeshbalamohan/subscriptions","organizations_url":"https://api.github.com/users/rajeshbalamohan/orgs","repos_url":"https://api.github.com/users/rajeshbalamohan/repos","events_url":"https://api.github.com/users/rajeshbalamohan/events{/privacy}","received_events_url":"https://api.github.com/users/rajeshbalamohan/received_events","type":"User","site_admin":false},"body":"Thanks @mallman . Addressed this in latest commit.","created_at":"2016-08-23T22:58:29Z","updated_at":"2016-08-23T22:58:29Z","html_url":"https://github.com/apache/spark/pull/14537#discussion_r75967137","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/14537","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/75967137"},"html":{"href":"https://github.com/apache/spark/pull/14537#discussion_r75967137"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/14537"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/14537","id":80412102,"html_url":"https://github.com/apache/spark/pull/14537","diff_url":"https://github.com/apache/spark/pull/14537.diff","patch_url":"https://github.com/apache/spark/pull/14537.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/14537","number":14537,"state":"open","locked":false,"title":"[SPARK-16948][SQL] Querying empty partitioned orc tables  throws exceptions","user":{"login":"rajeshbalamohan","id":323339,"avatar_url":"https://avatars.githubusercontent.com/u/323339?v=3","gravatar_id":"","url":"https://api.github.com/users/rajeshbalamohan","html_url":"https://github.com/rajeshbalamohan","followers_url":"https://api.github.com/users/rajeshbalamohan/followers","following_url":"https://api.github.com/users/rajeshbalamohan/following{/other_user}","gists_url":"https://api.github.com/users/rajeshbalamohan/gists{/gist_id}","starred_url":"https://api.github.com/users/rajeshbalamohan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rajeshbalamohan/subscriptions","organizations_url":"https://api.github.com/users/rajeshbalamohan/orgs","repos_url":"https://api.github.com/users/rajeshbalamohan/repos","events_url":"https://api.github.com/users/rajeshbalamohan/events{/privacy}","received_events_url":"https://api.github.com/users/rajeshbalamohan/received_events","type":"User","site_admin":false},"body":"## What changes were proposed in this pull request?\r\nQuerying empty partitioned ORC tables from spark-sql throws exception with `spark.sql.hive.convertMetastoreOrc=true`.  This is due to the fact that the inferschema() would end up throwing `FileNotFoundException` when no files are present in partitioned orc tables.  Patch attempts to fix it, wherein it would fall back to metastore based schema information. \r\n\r\n## How was this patch tested?\r\nIncluded unit tests and also tested it in small scale cluster.\r\n","created_at":"2016-08-08T08:30:45Z","updated_at":"2016-08-23T22:58:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e997e87e54de95db3b518407bf31a66eb38e03ba","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/14537/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/14537/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/spark/issues/14537/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/eb8a955e9fd39b2c8b9b88cbc1f01b1937af1189","head":{"label":"rajeshbalamohan:SPARK-16948","ref":"SPARK-16948","sha":"eb8a955e9fd39b2c8b9b88cbc1f01b1937af1189","user":{"login":"rajeshbalamohan","id":323339,"avatar_url":"https://avatars.githubusercontent.com/u/323339?v=3","gravatar_id":"","url":"https://api.github.com/users/rajeshbalamohan","html_url":"https://github.com/rajeshbalamohan","followers_url":"https://api.github.com/users/rajeshbalamohan/followers","following_url":"https://api.github.com/users/rajeshbalamohan/following{/other_user}","gists_url":"https://api.github.com/users/rajeshbalamohan/gists{/gist_id}","starred_url":"https://api.github.com/users/rajeshbalamohan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rajeshbalamohan/subscriptions","organizations_url":"https://api.github.com/users/rajeshbalamohan/orgs","repos_url":"https://api.github.com/users/rajeshbalamohan/repos","events_url":"https://api.github.com/users/rajeshbalamohan/events{/privacy}","received_events_url":"https://api.github.com/users/rajeshbalamohan/received_events","type":"User","site_admin":false},"repo":{"id":49923428,"name":"spark","full_name":"rajeshbalamohan/spark","owner":{"login":"rajeshbalamohan","id":323339,"avatar_url":"https://avatars.githubusercontent.com/u/323339?v=3","gravatar_id":"","url":"https://api.github.com/users/rajeshbalamohan","html_url":"https://github.com/rajeshbalamohan","followers_url":"https://api.github.com/users/rajeshbalamohan/followers","following_url":"https://api.github.com/users/rajeshbalamohan/following{/other_user}","gists_url":"https://api.github.com/users/rajeshbalamohan/gists{/gist_id}","starred_url":"https://api.github.com/users/rajeshbalamohan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rajeshbalamohan/subscriptions","organizations_url":"https://api.github.com/users/rajeshbalamohan/orgs","repos_url":"https://api.github.com/users/rajeshbalamohan/repos","events_url":"https://api.github.com/users/rajeshbalamohan/events{/privacy}","received_events_url":"https://api.github.com/users/rajeshbalamohan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rajeshbalamohan/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/rajeshbalamohan/spark","forks_url":"https://api.github.com/repos/rajeshbalamohan/spark/forks","keys_url":"https://api.github.com/repos/rajeshbalamohan/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rajeshbalamohan/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rajeshbalamohan/spark/teams","hooks_url":"https://api.github.com/repos/rajeshbalamohan/spark/hooks","issue_events_url":"https://api.github.com/repos/rajeshbalamohan/spark/issues/events{/number}","events_url":"https://api.github.com/repos/rajeshbalamohan/spark/events","assignees_url":"https://api.github.com/repos/rajeshbalamohan/spark/assignees{/user}","branches_url":"https://api.github.com/repos/rajeshbalamohan/spark/branches{/branch}","tags_url":"https://api.github.com/repos/rajeshbalamohan/spark/tags","blobs_url":"https://api.github.com/repos/rajeshbalamohan/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rajeshbalamohan/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rajeshbalamohan/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/rajeshbalamohan/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rajeshbalamohan/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/rajeshbalamohan/spark/languages","stargazers_url":"https://api.github.com/repos/rajeshbalamohan/spark/stargazers","contributors_url":"https://api.github.com/repos/rajeshbalamohan/spark/contributors","subscribers_url":"https://api.github.com/repos/rajeshbalamohan/spark/subscribers","subscription_url":"https://api.github.com/repos/rajeshbalamohan/spark/subscription","commits_url":"https://api.github.com/repos/rajeshbalamohan/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/rajeshbalamohan/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/rajeshbalamohan/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/rajeshbalamohan/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/rajeshbalamohan/spark/contents/{+path}","compare_url":"https://api.github.com/repos/rajeshbalamohan/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rajeshbalamohan/spark/merges","archive_url":"https://api.github.com/repos/rajeshbalamohan/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rajeshbalamohan/spark/downloads","issues_url":"https://api.github.com/repos/rajeshbalamohan/spark/issues{/number}","pulls_url":"https://api.github.com/repos/rajeshbalamohan/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/rajeshbalamohan/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/rajeshbalamohan/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rajeshbalamohan/spark/labels{/name}","releases_url":"https://api.github.com/repos/rajeshbalamohan/spark/releases{/id}","deployments_url":"https://api.github.com/repos/rajeshbalamohan/spark/deployments","created_at":"2016-01-19T03:25:19Z","updated_at":"2016-01-19T03:25:44Z","pushed_at":"2016-08-23T22:57:36Z","git_url":"git://github.com/rajeshbalamohan/spark.git","ssh_url":"git@github.com:rajeshbalamohan/spark.git","clone_url":"https://github.com/rajeshbalamohan/spark.git","svn_url":"https://github.com/rajeshbalamohan/spark","homepage":null,"size":176846,"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":"b2074b664a9c269c4103760d40c4a14e7aeb1e83","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}","deployments_url":"https://api.github.com/repos/apache/spark/deployments","created_at":"2014-02-25T08:00:08Z","updated_at":"2016-08-23T20:47:54Z","pushed_at":"2016-08-23T22:57:38Z","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":511705,"stargazers_count":9755,"watchers_count":9755,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":9096,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":473,"forks":9096,"open_issues":473,"watchers":9755,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/14537"},"html":{"href":"https://github.com/apache/spark/pull/14537"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/14537"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/14537/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/14537/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/14537/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/eb8a955e9fd39b2c8b9b88cbc1f01b1937af1189"}}}}
{"actor":{"display_login":"rajeshbalamohan"}}