{"action":"created","issue":{"url":"https://api.github.com/repos/apache/spark/issues/13860","repository_url":"https://api.github.com/repos/apache/spark","labels_url":"https://api.github.com/repos/apache/spark/issues/13860/labels{/name}","comments_url":"https://api.github.com/repos/apache/spark/issues/13860/comments","events_url":"https://api.github.com/repos/apache/spark/issues/13860/events","html_url":"https://github.com/apache/spark/pull/13860","id":161799907,"number":13860,"title":"[SPARK-16157] [SQL] Add New Methods for comments in StructField and StructType","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":18,"created_at":"2016-06-22T22:18:09Z","updated_at":"2016-06-29T06:35:14Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/13860","html_url":"https://github.com/apache/spark/pull/13860","diff_url":"https://github.com/apache/spark/pull/13860.diff","patch_url":"https://github.com/apache/spark/pull/13860.patch"},"body":"#### What changes were proposed in this pull request?\r\nBased on the previous discussion with @cloud-fan @hvanhovell in another related PR https://github.com/apache/spark/pull/13764#discussion_r67994276, it looks reasonable to add convenience methods for users to add `comment` when defining `StructField`.\r\n\r\nCurrently, the column-related `comment` attribute is stored in `Metadata` of `StructField`. For example, users can add the `comment` attribute using the following way:\r\n```Scala\r\nStructType(\r\n  StructField(\r\n    \"cl1\",\r\n    IntegerType,\r\n    nullable = false,\r\n    new MetadataBuilder().putString(\"comment\", \"test\").build()) :: Nil)\r\n```\r\nThis PR is to add more user friendly methods for the `comment` attribute when defining a `StructField`. After the changes, users are provided three different ways to do it:\r\n```Scala\r\nval struct = (new StructType)\r\n  .add(\"a\", \"int\", true, \"test1\")\r\n\r\nval struct = (new StructType)\r\n  .add(\"c\", StringType, true, \"test3\")\r\n\r\nval struct = (new StructType)\r\n  .add(StructField(\"d\", StringType).withComment(\"test4\"))\r\n```\r\n\r\n#### How was this patch tested?\r\nAdded test cases:\r\n- `DataTypeSuite` is for testing three types of API changes,\r\n- `DataFrameReaderWriterSuite` is for parquet, json and csv formats - using in-memory catalog\r\n- `OrcQuerySuite.scala` is for orc format using Hive-metastore"},"comment":{"url":"https://api.github.com/repos/apache/spark/issues/comments/229268989","html_url":"https://github.com/apache/spark/pull/13860#issuecomment-229268989","issue_url":"https://api.github.com/repos/apache/spark/issues/13860","id":229268989,"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},"created_at":"2016-06-29T06:35:14Z","updated_at":"2016-06-29T06:35:14Z","body":": ) Just found one in `AstBuilder.scala`. Let me know if anything I still missed. "}}
{"actor":{"display_login":"gatorsmile"}}