Daniel Becker has posted comments on this change. ( http://gerrit.cloudera.org:8080/20425 )
Change subject: IMPALA-10086: Implicit cast comparing char and varchar ...................................................................... Patch Set 1: (2 comments) http://gerrit.cloudera.org:8080/#/c/20425/1//COMMIT_MSG Commit Message: http://gerrit.cloudera.org:8080/#/c/20425/1//COMMIT_MSG@7 PS1, Line 7: IMPALA-10086 What's the relationship of this change to https://gerrit.cloudera.org/#/c/18001/? http://gerrit.cloudera.org:8080/#/c/20425/1/fe/src/main/java/org/apache/impala/catalog/DefaultCompatibility.java File fe/src/main/java/org/apache/impala/catalog/DefaultCompatibility.java: http://gerrit.cloudera.org:8080/#/c/20425/1/fe/src/main/java/org/apache/impala/catalog/DefaultCompatibility.java@151 PS1, Line 151: Choosing STRING as the common type of CHAR() and VARCHAR() is problematic if you want to insert the result into a VARCHAR(x) column. I ran into the problem in this change: https://gerrit.cloudera.org/#/c/18999/ Quoting from the commit message: """We choose VARCHAR instead of STRING as the common type because VARCHAR can be converted to any VARCHAR type shorter or the same length and also to STRING, while STRING cannot safely be converted to VARCHAR because its length is not bounded - we would therefore run into problems if the common type were STRING and the destination column were VARCHAR.""" The following works on master but fails if I run it on this patch: create table tmp (v varchar(6)); insert into tmp values (cast("aaabbb" as varchar(6))), (cast("cccddd" as char(6))); ERROR: AnalysisException: Possible loss of precision for target table 'default.tmp'. Expression 'CAST('cccddd' AS CHAR(6))' (type: STRING) would need to be cast to VARCHAR(6) for column 'v' -- To view, visit http://gerrit.cloudera.org:8080/20425 To unsubscribe, visit http://gerrit.cloudera.org:8080/settings Gerrit-Project: Impala-ASF Gerrit-Branch: master Gerrit-MessageType: comment Gerrit-Change-Id: Ib89d0a391bc8f2152ecd9151c8872a01ba19c436 Gerrit-Change-Number: 20425 Gerrit-PatchSet: 1 Gerrit-Owner: Michael Smith <[email protected]> Gerrit-Reviewer: Daniel Becker <[email protected]> Gerrit-Reviewer: Impala Public Jenkins <[email protected]> Gerrit-Reviewer: Joe McDonnell <[email protected]> Gerrit-Reviewer: Michael Smith <[email protected]> Gerrit-Reviewer: Quanlong Huang <[email protected]> Gerrit-Comment-Date: Tue, 29 Aug 2023 13:12:50 +0000 Gerrit-HasComments: Yes
