{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/77941648","id":77941648,"diff_hunk":"@@ -318,44 +331,51 @@ class HiveDDLSuite\n         assert(catalog.tableExists(TableIdentifier(tabName)))\n         assert(catalog.tableExists(TableIdentifier(oldViewName)))\n \n-        var message = intercept[AnalysisException] {\n-          sql(s\"ALTER VIEW $tabName RENAME TO $newViewName\")\n-        }.getMessage\n-        assert(message.contains(\n-          \"Cannot alter a table with ALTER VIEW. Please use ALTER TABLE instead\"))\n+        checkMisuseForAlterTableOrView(\n+          s\"$tabName RENAME TO $newViewName\", isAlterView = true)\n \n-        message = intercept[AnalysisException] {\n-          sql(s\"ALTER VIEW $tabName SET TBLPROPERTIES ('p' = 'an')\")\n-        }.getMessage\n-        assert(message.contains(\n-          \"Cannot alter a table with ALTER VIEW. Please use ALTER TABLE instead\"))\n+        checkMisuseForAlterTableOrView(\n+          s\"$oldViewName RENAME TO $newViewName\", isAlterView = false)\n \n-        message = intercept[AnalysisException] {\n-          sql(s\"ALTER VIEW $tabName UNSET TBLPROPERTIES ('p')\")\n-        }.getMessage\n-        assert(message.contains(\n-          \"Cannot alter a table with ALTER VIEW. Please use ALTER TABLE instead\"))\n+        checkMisuseForAlterTableOrView(\n+          s\"$tabName SET TBLPROPERTIES ('p' = 'an')\", isAlterView = true)\n \n-        message = intercept[AnalysisException] {\n-          sql(s\"ALTER TABLE $oldViewName RENAME TO $newViewName\")\n-        }.getMessage\n-        assert(message.contains(\n-          \"Cannot alter a view with ALTER TABLE. Please use ALTER VIEW instead\"))\n+        checkMisuseForAlterTableOrView(\n+          s\"$oldViewName SET TBLPROPERTIES ('p' = 'an')\", isAlterView = false)\n \n-        message = intercept[AnalysisException] {\n-          sql(s\"ALTER TABLE $oldViewName SET TBLPROPERTIES ('p' = 'an')\")\n-        }.getMessage\n-        assert(message.contains(\n-          \"Cannot alter a view with ALTER TABLE. Please use ALTER VIEW instead\"))\n+        checkMisuseForAlterTableOrView(\n+          s\"$tabName UNSET TBLPROPERTIES ('p')\", isAlterView = true)\n \n-        message = intercept[AnalysisException] {\n-          sql(s\"ALTER TABLE $oldViewName UNSET TBLPROPERTIES ('p')\")\n-        }.getMessage\n-        assert(message.contains(\n-          \"Cannot alter a view with ALTER TABLE. Please use ALTER VIEW instead\"))\n+        checkMisuseForAlterTableOrView(\n+          s\"$oldViewName UNSET TBLPROPERTIES ('p')\", isAlterView = false)\n+\n+        checkMisuseForAlterTableOrView(\n+          s\"$oldViewName SET LOCATION '/path/to/your/lovely/heart'\", isAlterView = false)\n+\n+        checkMisuseForAlterTableOrView(\n+          s\"$oldViewName SET SERDE 'whatever'\", isAlterView = false)\n+\n+        checkMisuseForAlterTableOrView(\n+          s\"$oldViewName SET SERDEPROPERTIES ('x' = 'y')\", isAlterView = false)\n+\n+        checkMisuseForAlterTableOrView(\n+          s\"$oldViewName PARTITION (a=1, b=2) SET SERDEPROPERTIES ('x' = 'y')\", isAlterView = false)\n+\n+        checkMisuseForAlterTableOrView(\n+          s\"$oldViewName ADD IF NOT EXISTS PARTITION (a='4', b='8')\", isAlterView = false)\n+","path":"sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveDDLSuite.scala","position":86,"original_position":86,"commit_id":"ea630f89ca3a3c0a3ae97bf2b9a14e4956657a9c","original_commit_id":"ea630f89ca3a3c0a3ae97bf2b9a14e4956657a9c","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},"body":"We also need to test `isAlterView` = `true` for `ADD PARTITION` and `DROP PARTITION`. Let me add them now...","created_at":"2016-09-08T03:36:49Z","updated_at":"2016-09-08T03:36:49Z","html_url":"https://github.com/apache/spark/pull/15004#discussion_r77941648","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/15004","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/77941648"},"html":{"href":"https://github.com/apache/spark/pull/15004#discussion_r77941648"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/15004"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/15004","id":84386198,"html_url":"https://github.com/apache/spark/pull/15004","diff_url":"https://github.com/apache/spark/pull/15004.diff","patch_url":"https://github.com/apache/spark/pull/15004.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/15004","number":15004,"state":"open","locked":false,"title":"[SPARK-17440] [SPARK-17441] Fixed Multiple Bugs in ALTER 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},"body":"### What changes were proposed in this pull request?\r\nFor the following `ALTER TABLE` DDL, we should issue an exception when the target table is a `VIEW`:\r\n```SQL\r\n ALTER TABLE viewName SET LOCATION '/path/to/your/lovely/heart'\r\n\r\n ALTER TABLE viewName SET SERDE 'whatever'\r\n\r\n ALTER TABLE viewName SET SERDEPROPERTIES ('x' = 'y')\r\n\r\n ALTER TABLE viewName PARTITION (a=1, b=2) SET SERDEPROPERTIES ('x' = 'y')\r\n\r\n ALTER TABLE viewName ADD IF NOT EXISTS PARTITION (a='4', b='8')\r\n\r\n ALTER TABLE viewName DROP IF EXISTS PARTITION (a='2')\r\n\r\n ALTER TABLE viewName RECOVER PARTITIONS\r\n\r\n ALTER TABLE viewName PARTITION (a='1', b='q') RENAME TO PARTITION (a='100', b='p')\r\n```\r\n\r\nIn addition, `ALTER TABLE RENAME PARTITION` is unable to handle data source tables, just like the other `ALTER PARTITION` commands. We should issue an exception instead. \r\n\r\n### How was this patch tested?\r\nAdded a few test cases.","created_at":"2016-09-07T22:37:54Z","updated_at":"2016-09-08T03:36:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9624882d4f532c9180687ab5a3dee6a0167c211b","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/15004/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/15004/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/spark/issues/15004/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/ea630f89ca3a3c0a3ae97bf2b9a14e4956657a9c","head":{"label":"gatorsmile:altertable","ref":"altertable","sha":"ea630f89ca3a3c0a3ae97bf2b9a14e4956657a9c","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},"repo":{"id":44710950,"name":"spark","full_name":"gatorsmile/spark","owner":{"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},"private":false,"html_url":"https://github.com/gatorsmile/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/gatorsmile/spark","forks_url":"https://api.github.com/repos/gatorsmile/spark/forks","keys_url":"https://api.github.com/repos/gatorsmile/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gatorsmile/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gatorsmile/spark/teams","hooks_url":"https://api.github.com/repos/gatorsmile/spark/hooks","issue_events_url":"https://api.github.com/repos/gatorsmile/spark/issues/events{/number}","events_url":"https://api.github.com/repos/gatorsmile/spark/events","assignees_url":"https://api.github.com/repos/gatorsmile/spark/assignees{/user}","branches_url":"https://api.github.com/repos/gatorsmile/spark/branches{/branch}","tags_url":"https://api.github.com/repos/gatorsmile/spark/tags","blobs_url":"https://api.github.com/repos/gatorsmile/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gatorsmile/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gatorsmile/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/gatorsmile/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gatorsmile/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/gatorsmile/spark/languages","stargazers_url":"https://api.github.com/repos/gatorsmile/spark/stargazers","contributors_url":"https://api.github.com/repos/gatorsmile/spark/contributors","subscribers_url":"https://api.github.com/repos/gatorsmile/spark/subscribers","subscription_url":"https://api.github.com/repos/gatorsmile/spark/subscription","commits_url":"https://api.github.com/repos/gatorsmile/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/gatorsmile/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/gatorsmile/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/gatorsmile/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/gatorsmile/spark/contents/{+path}","compare_url":"https://api.github.com/repos/gatorsmile/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gatorsmile/spark/merges","archive_url":"https://api.github.com/repos/gatorsmile/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gatorsmile/spark/downloads","issues_url":"https://api.github.com/repos/gatorsmile/spark/issues{/number}","pulls_url":"https://api.github.com/repos/gatorsmile/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/gatorsmile/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/gatorsmile/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gatorsmile/spark/labels{/name}","releases_url":"https://api.github.com/repos/gatorsmile/spark/releases{/id}","deployments_url":"https://api.github.com/repos/gatorsmile/spark/deployments","created_at":"2015-10-21T23:48:23Z","updated_at":"2015-10-21T23:48:54Z","pushed_at":"2016-09-07T22:33:07Z","git_url":"git://github.com/gatorsmile/spark.git","ssh_url":"git@github.com:gatorsmile/spark.git","clone_url":"https://github.com/gatorsmile/spark.git","svn_url":"https://github.com/gatorsmile/spark","homepage":null,"size":188789,"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":"binaryOutput"}},"base":{"label":"apache:master","ref":"master","sha":"b230fb92a53375b648fa0f9e1d852270156d79e5","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-09-08T00:49:43Z","pushed_at":"2016-09-08T03:34:34Z","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":523713,"stargazers_count":9928,"watchers_count":9928,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":9249,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":480,"forks":9249,"open_issues":480,"watchers":9928,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/15004"},"html":{"href":"https://github.com/apache/spark/pull/15004"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/15004"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/15004/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/15004/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/15004/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/ea630f89ca3a3c0a3ae97bf2b9a14e4956657a9c"}}}}
{"actor":{"display_login":"gatorsmile"}}