Michael Smith has submitted this change and it was merged. ( http://gerrit.cloudera.org:8080/20425 )
Change subject: IMPALA-10086: Implicit cast comparing char and varchar ...................................................................... IMPALA-10086: Implicit cast comparing char and varchar Until IMPALA-7368, Impala allowed comparing char and varchar slots as in select * from functional.chars_tiny where cs = vc; IMPALA-7368 added DATE type support, and as part of that changed function call resolution to use a fit function based on the number of arguments that match the call types. Previously the comparison above would take the first matching function, which happened to be equality between STRING and STRING; CHAR and VARCHAR can both be implicitly cast to STRING, so this function worked. With the new function resolution, the best fit is equality between VARCHAR and VARCHAR, however implicit casting to VARCHAR(*) from CHAR wasn't allowed. The behavior before IMPALA-7368 was somewhat accidental; it depended on the order that builtin EQ functions are added via BinaryPredicate.initBuiltins -> Type.getSupportedTypes. Supported types happened to be ordered with STRING preceding VARCHAR and CHAR. The fit function makes sense and changing its behavior may have other consequences; it also makes sense that CHAR should be castable to VARCHAR. This change allows implicit cast between matching types. Functionally it only changes how we handle char/varchar comparison with wildcard char/varchar, because decimals are handled before checking for matching types and other type matching is the same as equals. It now allows casting to a compatible type when it is a char or varchar and the target type is a wildcard version of the same. Does not attempt to address differences from CHAR padding (IMPALA-1652). Testing: - Adds tests covering cast comparison and other implicit conversions. - Passed exhaustive test run. Change-Id: Ib89d0a391bc8f2152ecd9151c8872a01ba19c436 Reviewed-on: http://gerrit.cloudera.org:8080/20425 Reviewed-by: Peter Rozsa <[email protected]> Reviewed-by: Daniel Becker <[email protected]> Tested-by: Impala Public Jenkins <[email protected]> --- M fe/src/main/java/org/apache/impala/analysis/Expr.java M fe/src/test/java/org/apache/impala/analysis/AnalyzeExprsTest.java M tests/query_test/test_cast_with_format.py 3 files changed, 71 insertions(+), 9 deletions(-) Approvals: Peter Rozsa: Looks good to me, but someone else must approve Daniel Becker: Looks good to me, approved Impala Public Jenkins: Verified -- 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: merged Gerrit-Change-Id: Ib89d0a391bc8f2152ecd9151c8872a01ba19c436 Gerrit-Change-Number: 20425 Gerrit-PatchSet: 7 Gerrit-Owner: Michael Smith <[email protected]> Gerrit-Reviewer: Csaba Ringhofer <[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: Peter Rozsa <[email protected]> Gerrit-Reviewer: Quanlong Huang <[email protected]>
