{"action":"created","issue":{"url":"https://api.github.com/repos/apache/spark/issues/20525","repository_url":"https://api.github.com/repos/apache/spark","labels_url":"https://api.github.com/repos/apache/spark/issues/20525/labels{/name}","comments_url":"https://api.github.com/repos/apache/spark/issues/20525/comments","events_url":"https://api.github.com/repos/apache/spark/issues/20525/events","html_url":"https://github.com/apache/spark/pull/20525","id":295038456,"number":20525,"title":"[SPARK-23271[SQL] Parquet output contains only _SUCCESS file after writing an empty dataframe","user":{"login":"dilipbiswal","id":14225158,"avatar_url":"https://avatars0.githubusercontent.com/u/14225158?v=4","gravatar_id":"","url":"https://api.github.com/users/dilipbiswal","html_url":"https://github.com/dilipbiswal","followers_url":"https://api.github.com/users/dilipbiswal/followers","following_url":"https://api.github.com/users/dilipbiswal/following{/other_user}","gists_url":"https://api.github.com/users/dilipbiswal/gists{/gist_id}","starred_url":"https://api.github.com/users/dilipbiswal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dilipbiswal/subscriptions","organizations_url":"https://api.github.com/users/dilipbiswal/orgs","repos_url":"https://api.github.com/users/dilipbiswal/repos","events_url":"https://api.github.com/users/dilipbiswal/events{/privacy}","received_events_url":"https://api.github.com/users/dilipbiswal/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":36,"created_at":"2018-02-07T07:53:27Z","updated_at":"2018-03-08T06:54:22Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/20525","html_url":"https://github.com/apache/spark/pull/20525","diff_url":"https://github.com/apache/spark/pull/20525.diff","patch_url":"https://github.com/apache/spark/pull/20525.patch"},"body":"## What changes were proposed in this pull request?\r\nBelow are the two cases. \r\n``` SQL\r\ncase 1\r\n\r\nscala> List.empty[String].toDF().rdd.partitions.length\r\nres18: Int = 1\r\n```\r\nWhen we write the above data frame as parquet, we create a parquet file containing\r\njust the schema of the data frame. \r\n\r\nCase 2\r\n``` SQL\r\n\r\nscala> val anySchema = StructType(StructField(\"anyName\", StringType, nullable = false) :: Nil)\r\nanySchema: org.apache.spark.sql.types.StructType = StructType(StructField(anyName,StringType,false))\r\nscala> spark.read.schema(anySchema).csv(\"/tmp/empty_folder\").rdd.partitions.length\r\nres22: Int = 0\r\n```\r\nFor the 2nd case, since number of partitions = 0, we don't call the write task (the task has logic to create the empty metadata only parquet file)\r\n\r\nThe fix is to create a dummy single partition RDD and set up the write task based on it to ensure\r\nthe metadata-only file.\r\n\r\n## How was this patch tested?\r\n\r\nA new test is added to DataframeReaderWriterSuite."},"comment":{"url":"https://api.github.com/repos/apache/spark/issues/comments/371397365","html_url":"https://github.com/apache/spark/pull/20525#issuecomment-371397365","issue_url":"https://api.github.com/repos/apache/spark/issues/20525","id":371397365,"user":{"login":"SparkQA","id":8108735,"avatar_url":"https://avatars1.githubusercontent.com/u/8108735?v=4","gravatar_id":"","url":"https://api.github.com/users/SparkQA","html_url":"https://github.com/SparkQA","followers_url":"https://api.github.com/users/SparkQA/followers","following_url":"https://api.github.com/users/SparkQA/following{/other_user}","gists_url":"https://api.github.com/users/SparkQA/gists{/gist_id}","starred_url":"https://api.github.com/users/SparkQA/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SparkQA/subscriptions","organizations_url":"https://api.github.com/users/SparkQA/orgs","repos_url":"https://api.github.com/users/SparkQA/repos","events_url":"https://api.github.com/users/SparkQA/events{/privacy}","received_events_url":"https://api.github.com/users/SparkQA/received_events","type":"User","site_admin":false},"created_at":"2018-03-08T06:54:22Z","updated_at":"2018-03-08T06:54:22Z","author_association":"NONE","body":"**[Test build #88072 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/88072/testReport)** for PR 20525 at commit [`f28324a`](https://github.com/apache/spark/commit/f28324ad439598ff321b82773a4250b8d4f4f4c6).\n * This patch passes all tests.\n * This patch merges cleanly.\n * This patch adds no public classes."}}
{"actor":{"display_login":"SparkQA"}}