{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/22619369","id":22619369,"diff_hunk":"@@ -67,15 +89,25 @@ private[sql] class DDLParser extends StandardTokenParsers with PackratParsers wi\n   protected lazy val ddl: Parser[LogicalPlan] = createTable\n \n   /**\n-   * CREATE TEMPORARY TABLE avroTable\n+   * `CREATE TEMPORARY TABLE avroTable\n    * USING org.apache.spark.sql.avro\n-   * OPTIONS (path \"../hive/src/test/resources/data/files/episodes.avro\")\n+   * OPTIONS (path \"../hive/src/test/resources/data/files/episodes.avro\")`\n+   * or\n+   * `CREATE TEMPORARY TABLE avroTable(intField int, stringField string...)\n+   * USING org.apache.spark.sql.avro\n+   * OPTIONS (path \"../hive/src/test/resources/data/files/episodes.avro\")`\n    */\n   protected lazy val createTable: Parser[LogicalPlan] =\n-    CREATE ~ TEMPORARY ~ TABLE ~> ident ~ (USING ~> className) ~ (OPTIONS ~> options) ^^ {\n-      case tableName ~ provider ~ opts =>\n-        CreateTableUsing(tableName, provider, opts)\n+  (\n+    CREATE ~ TEMPORARY ~ TABLE ~> ident\n+      ~ (tableCols).? ~ (USING ~> className) ~ (OPTIONS ~> options) ^^ {\n+      case tableName ~ columns ~ provider ~ opts =>\n+        val tblColumns = if(columns.isEmpty) Seq.empty else columns.get","path":"sql/core/src/main/scala/org/apache/spark/sql/sources/ddl.scala","position":81,"original_position":81,"commit_id":"b621c8f8885dbcc67dc34c53fbef79346900cb9c","original_commit_id":"b621c8f8885dbcc67dc34c53fbef79346900cb9c","user":{"login":"yhuai","id":2072857,"avatar_url":"https://avatars.githubusercontent.com/u/2072857?v=3","gravatar_id":"","url":"https://api.github.com/users/yhuai","html_url":"https://github.com/yhuai","followers_url":"https://api.github.com/users/yhuai/followers","following_url":"https://api.github.com/users/yhuai/following{/other_user}","gists_url":"https://api.github.com/users/yhuai/gists{/gist_id}","starred_url":"https://api.github.com/users/yhuai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yhuai/subscriptions","organizations_url":"https://api.github.com/users/yhuai/orgs","repos_url":"https://api.github.com/users/yhuai/repos","events_url":"https://api.github.com/users/yhuai/events{/privacy}","received_events_url":"https://api.github.com/users/yhuai/received_events","type":"User","site_admin":false},"body":"I feel it is better to use the `Option` instead of converting a `None` to an empty `Seq`.","created_at":"2015-01-07T21:53:57Z","updated_at":"2015-01-07T21:53:57Z","html_url":"https://github.com/apache/spark/pull/3431#discussion_r22619369","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/3431","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/22619369"},"html":{"href":"https://github.com/apache/spark/pull/3431#discussion_r22619369"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/3431"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/3431","id":24938486,"html_url":"https://github.com/apache/spark/pull/3431","diff_url":"https://github.com/apache/spark/pull/3431.diff","patch_url":"https://github.com/apache/spark/pull/3431.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/3431","number":3431,"state":"open","locked":false,"title":"[SPARK-4574][SQL] Adding support for defining schema in foreign DDL commands.","user":{"login":"scwf","id":7018048,"avatar_url":"https://avatars.githubusercontent.com/u/7018048?v=3","gravatar_id":"","url":"https://api.github.com/users/scwf","html_url":"https://github.com/scwf","followers_url":"https://api.github.com/users/scwf/followers","following_url":"https://api.github.com/users/scwf/following{/other_user}","gists_url":"https://api.github.com/users/scwf/gists{/gist_id}","starred_url":"https://api.github.com/users/scwf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scwf/subscriptions","organizations_url":"https://api.github.com/users/scwf/orgs","repos_url":"https://api.github.com/users/scwf/repos","events_url":"https://api.github.com/users/scwf/events{/privacy}","received_events_url":"https://api.github.com/users/scwf/received_events","type":"User","site_admin":false},"body":"Adding support for defining schema in foreign DDL commands. Now foreign DDL support commands like:\r\n```\r\nCREATE TEMPORARY TABLE avroTable\r\nUSING org.apache.spark.sql.avro\r\nOPTIONS (path \"../hive/src/test/resources/data/files/episodes.avro\")\r\n```\r\nWith this PR user can define schema instead of infer from file, so  support ddl command as follows:\r\n```\r\nCREATE TEMPORARY TABLE avroTable(a int, b string)\r\nUSING org.apache.spark.sql.avro\r\nOPTIONS (path \"../hive/src/test/resources/data/files/episodes.avro\")\r\n```","created_at":"2014-11-24T15:14:32Z","updated_at":"2015-01-07T21:53:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2d172c50276b28a2759275f39f2b6adfb0e7a149","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/3431/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/3431/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments/{number}","comments_url":"https://api.github.com/repos/apache/spark/issues/3431/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/b621c8f8885dbcc67dc34c53fbef79346900cb9c","head":{"label":"scwf:ddl","ref":"ddl","sha":"b621c8f8885dbcc67dc34c53fbef79346900cb9c","user":{"login":"scwf","id":7018048,"avatar_url":"https://avatars.githubusercontent.com/u/7018048?v=3","gravatar_id":"","url":"https://api.github.com/users/scwf","html_url":"https://github.com/scwf","followers_url":"https://api.github.com/users/scwf/followers","following_url":"https://api.github.com/users/scwf/following{/other_user}","gists_url":"https://api.github.com/users/scwf/gists{/gist_id}","starred_url":"https://api.github.com/users/scwf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scwf/subscriptions","organizations_url":"https://api.github.com/users/scwf/orgs","repos_url":"https://api.github.com/users/scwf/repos","events_url":"https://api.github.com/users/scwf/events{/privacy}","received_events_url":"https://api.github.com/users/scwf/received_events","type":"User","site_admin":false},"repo":{"id":18058739,"name":"spark","full_name":"scwf/spark","owner":{"login":"scwf","id":7018048,"avatar_url":"https://avatars.githubusercontent.com/u/7018048?v=3","gravatar_id":"","url":"https://api.github.com/users/scwf","html_url":"https://github.com/scwf","followers_url":"https://api.github.com/users/scwf/followers","following_url":"https://api.github.com/users/scwf/following{/other_user}","gists_url":"https://api.github.com/users/scwf/gists{/gist_id}","starred_url":"https://api.github.com/users/scwf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scwf/subscriptions","organizations_url":"https://api.github.com/users/scwf/orgs","repos_url":"https://api.github.com/users/scwf/repos","events_url":"https://api.github.com/users/scwf/events{/privacy}","received_events_url":"https://api.github.com/users/scwf/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/scwf/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/scwf/spark","forks_url":"https://api.github.com/repos/scwf/spark/forks","keys_url":"https://api.github.com/repos/scwf/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/scwf/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/scwf/spark/teams","hooks_url":"https://api.github.com/repos/scwf/spark/hooks","issue_events_url":"https://api.github.com/repos/scwf/spark/issues/events{/number}","events_url":"https://api.github.com/repos/scwf/spark/events","assignees_url":"https://api.github.com/repos/scwf/spark/assignees{/user}","branches_url":"https://api.github.com/repos/scwf/spark/branches{/branch}","tags_url":"https://api.github.com/repos/scwf/spark/tags","blobs_url":"https://api.github.com/repos/scwf/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/scwf/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/scwf/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/scwf/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/scwf/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/scwf/spark/languages","stargazers_url":"https://api.github.com/repos/scwf/spark/stargazers","contributors_url":"https://api.github.com/repos/scwf/spark/contributors","subscribers_url":"https://api.github.com/repos/scwf/spark/subscribers","subscription_url":"https://api.github.com/repos/scwf/spark/subscription","commits_url":"https://api.github.com/repos/scwf/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/scwf/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/scwf/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/scwf/spark/issues/comments/{number}","contents_url":"https://api.github.com/repos/scwf/spark/contents/{+path}","compare_url":"https://api.github.com/repos/scwf/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/scwf/spark/merges","archive_url":"https://api.github.com/repos/scwf/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/scwf/spark/downloads","issues_url":"https://api.github.com/repos/scwf/spark/issues{/number}","pulls_url":"https://api.github.com/repos/scwf/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/scwf/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/scwf/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/scwf/spark/labels{/name}","releases_url":"https://api.github.com/repos/scwf/spark/releases{/id}","created_at":"2014-03-24T10:24:49Z","updated_at":"2014-12-21T06:50:00Z","pushed_at":"2015-01-07T15:03:46Z","git_url":"git://github.com/scwf/spark.git","ssh_url":"git@github.com:scwf/spark.git","clone_url":"https://github.com/scwf/spark.git","svn_url":"https://github.com/scwf/spark","homepage":null,"size":92871,"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":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"040d6f2d13b132b3ef2a1e4f12f9f0e781c5a0b8","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}","created_at":"2014-02-25T08:00:08Z","updated_at":"2015-01-07T20:09:41Z","pushed_at":"2015-01-07T20:10:29Z","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":1097044,"stargazers_count":2501,"watchers_count":2501,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2216,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":298,"forks":2216,"open_issues":298,"watchers":2501,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/3431"},"html":{"href":"https://github.com/apache/spark/pull/3431"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/3431"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/3431/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/3431/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/3431/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/b621c8f8885dbcc67dc34c53fbef79346900cb9c"}}}}