{"action":"created","issue":{"url":"https://api.github.com/repos/apache/spark/issues/16672","repository_url":"https://api.github.com/repos/apache/spark","labels_url":"https://api.github.com/repos/apache/spark/issues/16672/labels{/name}","comments_url":"https://api.github.com/repos/apache/spark/issues/16672/comments","events_url":"https://api.github.com/repos/apache/spark/issues/16672/events","html_url":"https://github.com/apache/spark/pull/16672","id":202371873,"number":16672,"title":"[SPARK-19329][SQL]Reading from or writing to a table with a non pre-existing location should succeed","user":{"login":"windpiger","id":12979185,"avatar_url":"https://avatars.githubusercontent.com/u/12979185?v=3","gravatar_id":"","url":"https://api.github.com/users/windpiger","html_url":"https://github.com/windpiger","followers_url":"https://api.github.com/users/windpiger/followers","following_url":"https://api.github.com/users/windpiger/following{/other_user}","gists_url":"https://api.github.com/users/windpiger/gists{/gist_id}","starred_url":"https://api.github.com/users/windpiger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/windpiger/subscriptions","organizations_url":"https://api.github.com/users/windpiger/orgs","repos_url":"https://api.github.com/users/windpiger/repos","events_url":"https://api.github.com/users/windpiger/events{/privacy}","received_events_url":"https://api.github.com/users/windpiger/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":24,"created_at":"2017-01-22T09:30:43Z","updated_at":"2017-02-12T14:23:50Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/16672","html_url":"https://github.com/apache/spark/pull/16672","diff_url":"https://github.com/apache/spark/pull/16672.diff","patch_url":"https://github.com/apache/spark/pull/16672.patch"},"body":"## What changes were proposed in this pull request?\r\n\r\nwhen we insert data into a datasource table use `sqlText`, and the table has an not exists location,\r\nthis will throw an Exception.\r\n\r\nexample:\r\n\r\n```\r\nspark.sql(\"create table t(a string, b int) using parquet\")\r\nspark.sql(\"alter table t set location '/xx'\")\r\nspark.sql(\"insert into table t select 'c', 1\")\r\n```\r\n\r\nException:\r\n```\r\ncom.google.common.util.concurrent.UncheckedExecutionException: org.apache.spark.sql.AnalysisException: Path does not exist: /xx;\r\nat com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4814)\r\nat com.google.common.cache.LocalCache$LocalLoadingCache.apply(LocalCache.java:4830)\r\nat org.apache.spark.sql.hive.HiveMetastoreCatalog.lookupRelation(HiveMetastoreCatalog.scala:122)\r\nat org.apache.spark.sql.hive.HiveSessionCatalog.lookupRelation(HiveSessionCatalog.scala:69)\r\nat org.apache.spark.sql.catalyst.analysis.Analyzer$ResolveRelations$.org$apache$spark$sql$catalyst$analysis$Analyzer$ResolveRelations$$lookupTableFromCatalog(Analyzer.scala:456)\r\nat org.apache.spark.sql.catalyst.analysis.Analyzer$ResolveRelations$$anonfun$apply$8.applyOrElse(Analyzer.scala:465)\r\nat org.apache.spark.sql.catalyst.analysis.Analyzer$ResolveRelations$$anonfun$apply$8.applyOrElse(Analyzer.scala:463)\r\nat org.apache.spark.sql.catalyst.plans.logical.LogicalPlan$$anonfun$resolveOperators$1.apply(LogicalPlan.scala:61)\r\nat org.apache.spark.sql.catalyst.plans.logical.LogicalPlan$$anonfun$resolveOperators$1.apply(LogicalPlan.scala:61)\r\nat org.apache.spark.sql.catalyst.trees.CurrentOrigin$.withOrigin(TreeNode.scala:70)\r\nat org.apache.spark.sql.catalyst.plans.logical.LogicalPlan.resolveOperators(LogicalPlan.scala:60)\r\nat org.apache.spark.sql.catalyst.analysis.Analyzer$ResolveRelations$.apply(Analyzer.scala:463)\r\nat org.apache.spark.sql.catalyst.analysis.Analyzer$ResolveRelations$.apply(Analyzer.scala:453)\r\n```\r\n\r\nAs discussed following comments, we should unify the action when we reading from or writing to a datasource or hive serde table with a non pre-existing locaiton:\r\n\r\n1. reading from a datasource table: return 0 rows\r\n2. writing to a datasource table:  write data successfully\r\n3. reading from a hive serde table: return 0 rows\r\n4. writing to a  hive serde table:  write data successfully\r\n\r\n## How was this patch tested?\r\nunit test added"},"comment":{"url":"https://api.github.com/repos/apache/spark/issues/comments/279221826","html_url":"https://github.com/apache/spark/pull/16672#issuecomment-279221826","issue_url":"https://api.github.com/repos/apache/spark/issues/16672","id":279221826,"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":"2017-02-12T14:23:50Z","updated_at":"2017-02-12T14:23:50Z","body":"Merged build finished. Test PASSed."}}
{"actor":{"display_login":"AmplabJenkins"}}