{"action":"created","issue":{"url":"https://api.github.com/repos/apache/drill/issues/819","repository_url":"https://api.github.com/repos/apache/drill","labels_url":"https://api.github.com/repos/apache/drill/issues/819/labels{/name}","comments_url":"https://api.github.com/repos/apache/drill/issues/819/comments","events_url":"https://api.github.com/repos/apache/drill/issues/819/events","html_url":"https://github.com/apache/drill/pull/819","id":224178762,"number":819,"title":"DRILL-5419: Calculate return string length for literals & some string…","user":{"login":"arina-ielchiieva","id":15086720,"avatar_url":"https://avatars0.githubusercontent.com/u/15086720?v=3","gravatar_id":"","url":"https://api.github.com/users/arina-ielchiieva","html_url":"https://github.com/arina-ielchiieva","followers_url":"https://api.github.com/users/arina-ielchiieva/followers","following_url":"https://api.github.com/users/arina-ielchiieva/following{/other_user}","gists_url":"https://api.github.com/users/arina-ielchiieva/gists{/gist_id}","starred_url":"https://api.github.com/users/arina-ielchiieva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arina-ielchiieva/subscriptions","organizations_url":"https://api.github.com/users/arina-ielchiieva/orgs","repos_url":"https://api.github.com/users/arina-ielchiieva/repos","events_url":"https://api.github.com/users/arina-ielchiieva/events{/privacy}","received_events_url":"https://api.github.com/users/arina-ielchiieva/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-04-25T15:27:14Z","updated_at":"2017-05-05T19:17:49Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/apache/drill/pulls/819","html_url":"https://github.com/apache/drill/pull/819","diff_url":"https://github.com/apache/drill/pull/819.diff","patch_url":"https://github.com/apache/drill/pull/819.patch"},"body":"… functions\r\n\r\n1. Revisited calculation logic for string literals and some string functions (cast, upper, lower, initcap, reverse, concat, concat operator, rpad, lpad, case statement, coalesce, first_value, last_value, lag, lead).\r\n2. Deprecated width and changed it to precision for string types.\r\n3. Synchronized return type length calculation logic between limit 0 and regular queries.\r\n4. Performed minor refactoring, added appropriate unit tests."},"comment":{"url":"https://api.github.com/repos/apache/drill/issues/comments/299552662","html_url":"https://github.com/apache/drill/pull/819#issuecomment-299552662","issue_url":"https://api.github.com/repos/apache/drill/issues/819","id":299552662,"user":{"login":"jinfengni","id":5742011,"avatar_url":"https://avatars3.githubusercontent.com/u/5742011?v=3","gravatar_id":"","url":"https://api.github.com/users/jinfengni","html_url":"https://github.com/jinfengni","followers_url":"https://api.github.com/users/jinfengni/followers","following_url":"https://api.github.com/users/jinfengni/following{/other_user}","gists_url":"https://api.github.com/users/jinfengni/gists{/gist_id}","starred_url":"https://api.github.com/users/jinfengni/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jinfengni/subscriptions","organizations_url":"https://api.github.com/users/jinfengni/orgs","repos_url":"https://api.github.com/users/jinfengni/repos","events_url":"https://api.github.com/users/jinfengni/events{/privacy}","received_events_url":"https://api.github.com/users/jinfengni/received_events","type":"User","site_admin":false},"created_at":"2017-05-05T19:17:49Z","updated_at":"2017-05-05T19:17:49Z","body":"My understanding is Drill would hit a schema change between column with type of varchar(5) and varchar(10).  However, the length calculated in this PR is from the query metadeta (function parameter, string literal), which will not change across different batches. In that sense, we should not see schema change exception, just because of varchar length.\r\n\r\nThe following code shows that varchar(5) is different from varchar(10), also different from varchar without setting length. \r\n\r\n```java\r\n   TypeProtos.MajorType varchar5 = TypeProtos.MajorType.newBuilder()\r\n        .setMinorType(TypeProtos.MinorType.VARCHAR)\r\n        .setMode(TypeProtos.DataMode.OPTIONAL)\r\n        .setPrecision(5)\r\n        .build();\r\n    TypeProtos.MajorType varchar10 = TypeProtos.MajorType.newBuilder()\r\n        .setMinorType(TypeProtos.MinorType.VARCHAR)\r\n        .setMode(TypeProtos.DataMode.OPTIONAL)\r\n        .setPrecision(10)\r\n        .build();\r\n    TypeProtos.MajorType varcharNoLength = TypeProtos.MajorType.newBuilder()\r\n        .setMinorType(TypeProtos.MinorType.VARCHAR)\r\n        .setMode(TypeProtos.DataMode.OPTIONAL)\r\n        .build();\r\n\r\n    System.out.println(varchar5.equals(varchar10) ? \"varchar5 equals varchr10\" : \"varchar5 NOT equals varchr10\" );\r\n    System.out.println(varchar5.equals(varcharNoLength) ? \"varchar5 equals varchrNoLength\" : \"varchar5 NOT equals varchrNoLength\" );\r\n```\r\n\r\noutput:\r\n```\r\nvarchar5 NOT equals varchr10\r\nvarchar5 NOT equals varchrNoLength\r\n```"}}
{"actor":{"display_login":"jinfengni"}}