{"action":"created","comment":{"url":"https://api.github.com/repos/databricks/spark-redshift/pulls/comments/38020113","id":38020113,"diff_hunk":"@@ -141,7 +141,13 @@ private[redshift] class JDBCWrapper extends Logging {\n         case ShortType => \"INTEGER\"\n         case ByteType => \"SMALLINT\" // Redshift does not support the BYTE type.\n         case BooleanType => \"BOOLEAN\"\n-        case StringType => \"TEXT\"\n+        case StringType =>\n+          val maxlength = if (field.metadata.contains(\"maxlength\")) {\n+            field.metadata.getLong(\"maxlength\")\n+          } else {\n+            255 // TODO: make this default configurable?","path":"src/main/scala/com/databricks/spark/redshift/RedshiftJDBCWrapper.scala","position":9,"original_position":9,"commit_id":"2e08c659f72f1b70cd38e5212cefbe960a4e94c8","original_commit_id":"2e08c659f72f1b70cd38e5212cefbe960a4e94c8","user":{"login":"marmbrus","id":527,"avatar_url":"https://avatars.githubusercontent.com/u/527?v=3","gravatar_id":"","url":"https://api.github.com/users/marmbrus","html_url":"https://github.com/marmbrus","followers_url":"https://api.github.com/users/marmbrus/followers","following_url":"https://api.github.com/users/marmbrus/following{/other_user}","gists_url":"https://api.github.com/users/marmbrus/gists{/gist_id}","starred_url":"https://api.github.com/users/marmbrus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marmbrus/subscriptions","organizations_url":"https://api.github.com/users/marmbrus/orgs","repos_url":"https://api.github.com/users/marmbrus/repos","events_url":"https://api.github.com/users/marmbrus/events{/privacy}","received_events_url":"https://api.github.com/users/marmbrus/received_events","type":"User","site_admin":false},"body":"Should we just use `TEXT` in this case, which essentially defers the default to redshift?","created_at":"2015-08-26T18:49:26Z","updated_at":"2015-08-26T18:49:26Z","html_url":"https://github.com/databricks/spark-redshift/pull/54#discussion_r38020113","pull_request_url":"https://api.github.com/repos/databricks/spark-redshift/pulls/54","_links":{"self":{"href":"https://api.github.com/repos/databricks/spark-redshift/pulls/comments/38020113"},"html":{"href":"https://github.com/databricks/spark-redshift/pull/54#discussion_r38020113"},"pull_request":{"href":"https://api.github.com/repos/databricks/spark-redshift/pulls/54"}}},"pull_request":{"url":"https://api.github.com/repos/databricks/spark-redshift/pulls/54","id":43372428,"html_url":"https://github.com/databricks/spark-redshift/pull/54","diff_url":"https://github.com/databricks/spark-redshift/pull/54.diff","patch_url":"https://github.com/databricks/spark-redshift/pull/54.patch","issue_url":"https://api.github.com/repos/databricks/spark-redshift/issues/54","number":54,"state":"open","locked":false,"title":"[WIP] Use maxlength metadata to configure VARCHAR column lengths","user":{"login":"JoshRosen","id":50748,"avatar_url":"https://avatars.githubusercontent.com/u/50748?v=3","gravatar_id":"","url":"https://api.github.com/users/JoshRosen","html_url":"https://github.com/JoshRosen","followers_url":"https://api.github.com/users/JoshRosen/followers","following_url":"https://api.github.com/users/JoshRosen/following{/other_user}","gists_url":"https://api.github.com/users/JoshRosen/gists{/gist_id}","starred_url":"https://api.github.com/users/JoshRosen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JoshRosen/subscriptions","organizations_url":"https://api.github.com/users/JoshRosen/orgs","repos_url":"https://api.github.com/users/JoshRosen/repos","events_url":"https://api.github.com/users/JoshRosen/events{/privacy}","received_events_url":"https://api.github.com/users/JoshRosen/received_events","type":"User","site_admin":false},"body":"This patch allows users to specify a `maxlength` column metadata entry for string columns in order to control the width of `VARCHAR` columns in generated Redshift table schemas. This is necessary in order to support string columns that are wider than 256 characters. In addition, this configuration can be used as an optimization to achieve space-savings in Redshift. For more background on the motivation of this feature, see #29.\r\n\r\nSee also: #53 to improve error reporting when LOAD fails.\r\n\r\nTODOS:\r\n\r\n- [ ] Documentation\r\n- [ ] Unit tests to verify `CREATE TABLE` command.\r\n- [ ] Confirm field naming capitalization.\r\n- [ ] Should the default length be configurable?","created_at":"2015-08-26T07:36:32Z","updated_at":"2015-08-26T18:49:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4171851ae96e19c49b1062ebba7034bb1a57727d","assignee":null,"milestone":{"url":"https://api.github.com/repos/databricks/spark-redshift/milestones/1","html_url":"https://github.com/databricks/spark-redshift/milestones/0.5","labels_url":"https://api.github.com/repos/databricks/spark-redshift/milestones/1/labels","id":1271999,"number":1,"title":"0.5","description":"","creator":{"login":"JoshRosen","id":50748,"avatar_url":"https://avatars.githubusercontent.com/u/50748?v=3","gravatar_id":"","url":"https://api.github.com/users/JoshRosen","html_url":"https://github.com/JoshRosen","followers_url":"https://api.github.com/users/JoshRosen/followers","following_url":"https://api.github.com/users/JoshRosen/following{/other_user}","gists_url":"https://api.github.com/users/JoshRosen/gists{/gist_id}","starred_url":"https://api.github.com/users/JoshRosen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JoshRosen/subscriptions","organizations_url":"https://api.github.com/users/JoshRosen/orgs","repos_url":"https://api.github.com/users/JoshRosen/repos","events_url":"https://api.github.com/users/JoshRosen/events{/privacy}","received_events_url":"https://api.github.com/users/JoshRosen/received_events","type":"User","site_admin":false},"open_issues":5,"closed_issues":3,"state":"open","created_at":"2015-08-25T18:03:39Z","updated_at":"2015-08-26T07:36:32Z","due_on":"2015-08-28T07:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/databricks/spark-redshift/pulls/54/commits","review_comments_url":"https://api.github.com/repos/databricks/spark-redshift/pulls/54/comments","review_comment_url":"https://api.github.com/repos/databricks/spark-redshift/pulls/comments{/number}","comments_url":"https://api.github.com/repos/databricks/spark-redshift/issues/54/comments","statuses_url":"https://api.github.com/repos/databricks/spark-redshift/statuses/2e08c659f72f1b70cd38e5212cefbe960a4e94c8","head":{"label":"databricks:max-length","ref":"max-length","sha":"2e08c659f72f1b70cd38e5212cefbe960a4e94c8","user":{"login":"databricks","id":4998052,"avatar_url":"https://avatars.githubusercontent.com/u/4998052?v=3","gravatar_id":"","url":"https://api.github.com/users/databricks","html_url":"https://github.com/databricks","followers_url":"https://api.github.com/users/databricks/followers","following_url":"https://api.github.com/users/databricks/following{/other_user}","gists_url":"https://api.github.com/users/databricks/gists{/gist_id}","starred_url":"https://api.github.com/users/databricks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/databricks/subscriptions","organizations_url":"https://api.github.com/users/databricks/orgs","repos_url":"https://api.github.com/users/databricks/repos","events_url":"https://api.github.com/users/databricks/events{/privacy}","received_events_url":"https://api.github.com/users/databricks/received_events","type":"Organization","site_admin":false},"repo":{"id":26562411,"name":"spark-redshift","full_name":"databricks/spark-redshift","owner":{"login":"databricks","id":4998052,"avatar_url":"https://avatars.githubusercontent.com/u/4998052?v=3","gravatar_id":"","url":"https://api.github.com/users/databricks","html_url":"https://github.com/databricks","followers_url":"https://api.github.com/users/databricks/followers","following_url":"https://api.github.com/users/databricks/following{/other_user}","gists_url":"https://api.github.com/users/databricks/gists{/gist_id}","starred_url":"https://api.github.com/users/databricks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/databricks/subscriptions","organizations_url":"https://api.github.com/users/databricks/orgs","repos_url":"https://api.github.com/users/databricks/repos","events_url":"https://api.github.com/users/databricks/events{/privacy}","received_events_url":"https://api.github.com/users/databricks/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/databricks/spark-redshift","description":"Spark and Redshift integration","fork":false,"url":"https://api.github.com/repos/databricks/spark-redshift","forks_url":"https://api.github.com/repos/databricks/spark-redshift/forks","keys_url":"https://api.github.com/repos/databricks/spark-redshift/keys{/key_id}","collaborators_url":"https://api.github.com/repos/databricks/spark-redshift/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/databricks/spark-redshift/teams","hooks_url":"https://api.github.com/repos/databricks/spark-redshift/hooks","issue_events_url":"https://api.github.com/repos/databricks/spark-redshift/issues/events{/number}","events_url":"https://api.github.com/repos/databricks/spark-redshift/events","assignees_url":"https://api.github.com/repos/databricks/spark-redshift/assignees{/user}","branches_url":"https://api.github.com/repos/databricks/spark-redshift/branches{/branch}","tags_url":"https://api.github.com/repos/databricks/spark-redshift/tags","blobs_url":"https://api.github.com/repos/databricks/spark-redshift/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/databricks/spark-redshift/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/databricks/spark-redshift/git/refs{/sha}","trees_url":"https://api.github.com/repos/databricks/spark-redshift/git/trees{/sha}","statuses_url":"https://api.github.com/repos/databricks/spark-redshift/statuses/{sha}","languages_url":"https://api.github.com/repos/databricks/spark-redshift/languages","stargazers_url":"https://api.github.com/repos/databricks/spark-redshift/stargazers","contributors_url":"https://api.github.com/repos/databricks/spark-redshift/contributors","subscribers_url":"https://api.github.com/repos/databricks/spark-redshift/subscribers","subscription_url":"https://api.github.com/repos/databricks/spark-redshift/subscription","commits_url":"https://api.github.com/repos/databricks/spark-redshift/commits{/sha}","git_commits_url":"https://api.github.com/repos/databricks/spark-redshift/git/commits{/sha}","comments_url":"https://api.github.com/repos/databricks/spark-redshift/comments{/number}","issue_comment_url":"https://api.github.com/repos/databricks/spark-redshift/issues/comments{/number}","contents_url":"https://api.github.com/repos/databricks/spark-redshift/contents/{+path}","compare_url":"https://api.github.com/repos/databricks/spark-redshift/compare/{base}...{head}","merges_url":"https://api.github.com/repos/databricks/spark-redshift/merges","archive_url":"https://api.github.com/repos/databricks/spark-redshift/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/databricks/spark-redshift/downloads","issues_url":"https://api.github.com/repos/databricks/spark-redshift/issues{/number}","pulls_url":"https://api.github.com/repos/databricks/spark-redshift/pulls{/number}","milestones_url":"https://api.github.com/repos/databricks/spark-redshift/milestones{/number}","notifications_url":"https://api.github.com/repos/databricks/spark-redshift/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/databricks/spark-redshift/labels{/name}","releases_url":"https://api.github.com/repos/databricks/spark-redshift/releases{/id}","created_at":"2014-11-13T00:08:13Z","updated_at":"2015-08-26T15:59:05Z","pushed_at":"2015-08-26T09:03:48Z","git_url":"git://github.com/databricks/spark-redshift.git","ssh_url":"git@github.com:databricks/spark-redshift.git","clone_url":"https://github.com/databricks/spark-redshift.git","svn_url":"https://github.com/databricks/spark-redshift","homepage":null,"size":1392,"stargazers_count":63,"watchers_count":63,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":24,"mirror_url":null,"open_issues_count":13,"forks":24,"open_issues":13,"watchers":63,"default_branch":"master"}},"base":{"label":"databricks:master","ref":"master","sha":"acec3367a2d57ae2fea44fb3498fbf334afd1238","user":{"login":"databricks","id":4998052,"avatar_url":"https://avatars.githubusercontent.com/u/4998052?v=3","gravatar_id":"","url":"https://api.github.com/users/databricks","html_url":"https://github.com/databricks","followers_url":"https://api.github.com/users/databricks/followers","following_url":"https://api.github.com/users/databricks/following{/other_user}","gists_url":"https://api.github.com/users/databricks/gists{/gist_id}","starred_url":"https://api.github.com/users/databricks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/databricks/subscriptions","organizations_url":"https://api.github.com/users/databricks/orgs","repos_url":"https://api.github.com/users/databricks/repos","events_url":"https://api.github.com/users/databricks/events{/privacy}","received_events_url":"https://api.github.com/users/databricks/received_events","type":"Organization","site_admin":false},"repo":{"id":26562411,"name":"spark-redshift","full_name":"databricks/spark-redshift","owner":{"login":"databricks","id":4998052,"avatar_url":"https://avatars.githubusercontent.com/u/4998052?v=3","gravatar_id":"","url":"https://api.github.com/users/databricks","html_url":"https://github.com/databricks","followers_url":"https://api.github.com/users/databricks/followers","following_url":"https://api.github.com/users/databricks/following{/other_user}","gists_url":"https://api.github.com/users/databricks/gists{/gist_id}","starred_url":"https://api.github.com/users/databricks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/databricks/subscriptions","organizations_url":"https://api.github.com/users/databricks/orgs","repos_url":"https://api.github.com/users/databricks/repos","events_url":"https://api.github.com/users/databricks/events{/privacy}","received_events_url":"https://api.github.com/users/databricks/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/databricks/spark-redshift","description":"Spark and Redshift integration","fork":false,"url":"https://api.github.com/repos/databricks/spark-redshift","forks_url":"https://api.github.com/repos/databricks/spark-redshift/forks","keys_url":"https://api.github.com/repos/databricks/spark-redshift/keys{/key_id}","collaborators_url":"https://api.github.com/repos/databricks/spark-redshift/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/databricks/spark-redshift/teams","hooks_url":"https://api.github.com/repos/databricks/spark-redshift/hooks","issue_events_url":"https://api.github.com/repos/databricks/spark-redshift/issues/events{/number}","events_url":"https://api.github.com/repos/databricks/spark-redshift/events","assignees_url":"https://api.github.com/repos/databricks/spark-redshift/assignees{/user}","branches_url":"https://api.github.com/repos/databricks/spark-redshift/branches{/branch}","tags_url":"https://api.github.com/repos/databricks/spark-redshift/tags","blobs_url":"https://api.github.com/repos/databricks/spark-redshift/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/databricks/spark-redshift/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/databricks/spark-redshift/git/refs{/sha}","trees_url":"https://api.github.com/repos/databricks/spark-redshift/git/trees{/sha}","statuses_url":"https://api.github.com/repos/databricks/spark-redshift/statuses/{sha}","languages_url":"https://api.github.com/repos/databricks/spark-redshift/languages","stargazers_url":"https://api.github.com/repos/databricks/spark-redshift/stargazers","contributors_url":"https://api.github.com/repos/databricks/spark-redshift/contributors","subscribers_url":"https://api.github.com/repos/databricks/spark-redshift/subscribers","subscription_url":"https://api.github.com/repos/databricks/spark-redshift/subscription","commits_url":"https://api.github.com/repos/databricks/spark-redshift/commits{/sha}","git_commits_url":"https://api.github.com/repos/databricks/spark-redshift/git/commits{/sha}","comments_url":"https://api.github.com/repos/databricks/spark-redshift/comments{/number}","issue_comment_url":"https://api.github.com/repos/databricks/spark-redshift/issues/comments{/number}","contents_url":"https://api.github.com/repos/databricks/spark-redshift/contents/{+path}","compare_url":"https://api.github.com/repos/databricks/spark-redshift/compare/{base}...{head}","merges_url":"https://api.github.com/repos/databricks/spark-redshift/merges","archive_url":"https://api.github.com/repos/databricks/spark-redshift/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/databricks/spark-redshift/downloads","issues_url":"https://api.github.com/repos/databricks/spark-redshift/issues{/number}","pulls_url":"https://api.github.com/repos/databricks/spark-redshift/pulls{/number}","milestones_url":"https://api.github.com/repos/databricks/spark-redshift/milestones{/number}","notifications_url":"https://api.github.com/repos/databricks/spark-redshift/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/databricks/spark-redshift/labels{/name}","releases_url":"https://api.github.com/repos/databricks/spark-redshift/releases{/id}","created_at":"2014-11-13T00:08:13Z","updated_at":"2015-08-26T15:59:05Z","pushed_at":"2015-08-26T09:03:48Z","git_url":"git://github.com/databricks/spark-redshift.git","ssh_url":"git@github.com:databricks/spark-redshift.git","clone_url":"https://github.com/databricks/spark-redshift.git","svn_url":"https://github.com/databricks/spark-redshift","homepage":null,"size":1392,"stargazers_count":63,"watchers_count":63,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":24,"mirror_url":null,"open_issues_count":13,"forks":24,"open_issues":13,"watchers":63,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/databricks/spark-redshift/pulls/54"},"html":{"href":"https://github.com/databricks/spark-redshift/pull/54"},"issue":{"href":"https://api.github.com/repos/databricks/spark-redshift/issues/54"},"comments":{"href":"https://api.github.com/repos/databricks/spark-redshift/issues/54/comments"},"review_comments":{"href":"https://api.github.com/repos/databricks/spark-redshift/pulls/54/comments"},"review_comment":{"href":"https://api.github.com/repos/databricks/spark-redshift/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/databricks/spark-redshift/pulls/54/commits"},"statuses":{"href":"https://api.github.com/repos/databricks/spark-redshift/statuses/2e08c659f72f1b70cd38e5212cefbe960a4e94c8"}}}}