{"action":"created","issue":{"url":"https://api.github.com/repos/apache/spark/issues/14410","repository_url":"https://api.github.com/repos/apache/spark","labels_url":"https://api.github.com/repos/apache/spark/issues/14410/labels{/name}","comments_url":"https://api.github.com/repos/apache/spark/issues/14410/comments","events_url":"https://api.github.com/repos/apache/spark/issues/14410/events","html_url":"https://github.com/apache/spark/pull/14410","id":168418675,"number":14410,"title":"[SPARK-16803] [SQL] SaveAsTable does not work when source DataFrame is built on a Hive Table","user":{"login":"gatorsmile","id":11567269,"avatar_url":"https://avatars.githubusercontent.com/u/11567269?v=3","gravatar_id":"","url":"https://api.github.com/users/gatorsmile","html_url":"https://github.com/gatorsmile","followers_url":"https://api.github.com/users/gatorsmile/followers","following_url":"https://api.github.com/users/gatorsmile/following{/other_user}","gists_url":"https://api.github.com/users/gatorsmile/gists{/gist_id}","starred_url":"https://api.github.com/users/gatorsmile/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gatorsmile/subscriptions","organizations_url":"https://api.github.com/users/gatorsmile/orgs","repos_url":"https://api.github.com/users/gatorsmile/repos","events_url":"https://api.github.com/users/gatorsmile/events{/privacy}","received_events_url":"https://api.github.com/users/gatorsmile/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-07-29T21:30:38Z","updated_at":"2016-07-29T22:48:05Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/14410","html_url":"https://github.com/apache/spark/pull/14410","diff_url":"https://github.com/apache/spark/pull/14410.diff","patch_url":"https://github.com/apache/spark/pull/14410.patch"},"body":"### What changes were proposed in this pull request?\r\nIn Spark 2.0, `SaveAsTable` does not work when source DataFrame is built on a Hive Table, but Spark 1.6 works.\r\n\r\n**Spark 1.6**\r\n```Scala\r\nscala> sql(\"create table sample.sample stored as SEQUENCEFILE as select 1 as key, 'abc' as value\")\r\nres2: org.apache.spark.sql.DataFrame = []\r\n\r\nscala> val df = sql(\"select key, value as value from sample.sample\")\r\ndf: org.apache.spark.sql.DataFrame = [key: int, value: string]\r\n\r\nscala> df.write.mode(\"append\").saveAsTable(\"sample.sample\")\r\n\r\nscala> sql(\"select * from sample.sample\").show()\r\n+---+-----+\r\n|key|value|\r\n+---+-----+\r\n|  1|  abc|\r\n|  1|  abc|\r\n+---+-----+\r\n```\r\n**Spark 2.0**\r\n```Scala\r\nscala> df.write.mode(\"append\").saveAsTable(\"sample.sample\")\r\norg.apache.spark.sql.AnalysisException: Saving data in MetastoreRelation sample, sample\r\n is not supported.;\r\n```\r\n\r\nSo far, we do not plan to support it in Spark 2.0. Spark 1.6 works because it internally uses `insertInto`. But, if we change it back it will break the semantic of `saveAsTable` (this method uses by-name resolution instead of using by-position resolution used by `insertInto`).\r\n\r\nInstead, users should use `insertInto` API. This PR corrects the error messages. Users can understand how to bypass it before we support it in a separate PR.\r\n\r\n### How was this patch tested?\r\nTest cases are added"},"comment":{"url":"https://api.github.com/repos/apache/spark/issues/comments/236312558","html_url":"https://github.com/apache/spark/pull/14410#issuecomment-236312558","issue_url":"https://api.github.com/repos/apache/spark/issues/14410","id":236312558,"user":{"login":"AmplabJenkins","id":4031291,"avatar_url":"https://avatars.githubusercontent.com/u/4031291?v=3","gravatar_id":"","url":"https://api.github.com/users/AmplabJenkins","html_url":"https://github.com/AmplabJenkins","followers_url":"https://api.github.com/users/AmplabJenkins/followers","following_url":"https://api.github.com/users/AmplabJenkins/following{/other_user}","gists_url":"https://api.github.com/users/AmplabJenkins/gists{/gist_id}","starred_url":"https://api.github.com/users/AmplabJenkins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AmplabJenkins/subscriptions","organizations_url":"https://api.github.com/users/AmplabJenkins/orgs","repos_url":"https://api.github.com/users/AmplabJenkins/repos","events_url":"https://api.github.com/users/AmplabJenkins/events{/privacy}","received_events_url":"https://api.github.com/users/AmplabJenkins/received_events","type":"User","site_admin":false},"created_at":"2016-07-29T22:48:05Z","updated_at":"2016-07-29T22:48:05Z","body":"Test FAILed.\nRefer to this link for build results (access rights to CI server needed): \nhttps://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/63019/\nTest FAILed."}}
{"actor":{"display_login":"AmplabJenkins"}}