[
https://issues.apache.org/jira/browse/IMPALA-14421?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18039113#comment-18039113
]
ASF subversion and git services commented on IMPALA-14421:
----------------------------------------------------------
Commit 52334ba4261b1a0a097a390d8aa2ffb45edc8bd1 in impala's branch
refs/heads/master from Steve Carlin
[ https://gitbox.apache.org/repos/asf?p=impala.git;h=52334ba42 ]
IMPALA-14421: Calcite planner: case statement returning wrong types for char,
varchar
The 'case' function resolver in the original Impala planner has a quirk in it
which caused issues in the Calcite planner.
The function resolver for the original planner resolves all case statements with
the "boolean" version. Later on, in the analysis of the CaseExpr, the proper
types are assessed and the necessary casting is added.
The Calcite planner follows a similar path. The resolver always returns boolean
as well and the coerce nodes module determines the proper return type for
the case statement.
Two other related issues are also fixed here:
Literal strings should be treated as type STRING instead of CHAR(X), but a null
should literal should not be changed from a CHAR(x) to a STRING. This broke a
'case' test in the test framework where the columns were non-literals with type
char(x), and the return value was a "null" which should not have forced a cast
to string.
A cast from a varchar to a varchar should be ignored.
Testing:
Added a test to calcite.test.
Ensured the existing cast test in test_chars.py passed.
Ran through the Jenkins Calcite testing framework.
Change-Id: I82d657f4bfce432c458ee8198188dadf9f23f2ef
Reviewed-on: http://gerrit.cloudera.org:8080/23560
Reviewed-by: Impala Public Jenkins <[email protected]>
Tested-by: Impala Public Jenkins <[email protected]>
> Calcite planner: case statement returning wrong types for char, varchar
> -----------------------------------------------------------------------
>
> Key: IMPALA-14421
> URL: https://issues.apache.org/jira/browse/IMPALA-14421
> Project: IMPALA
> Issue Type: Sub-task
> Reporter: Steve Carlin
> Priority: Major
>
> The following case statement in chars.test is returning the wrong types (all
> STRING)
> WITH numbered AS (
> SELECT *, row_number() over (order by cs) as rn
> FROM chars_tiny)
> SELECT *
> FROM (
> SELECT CASE WHEN rn % 2 = 0 THEN cs END cs,
> CASE WHEN rn % 2 = 1 THEN cl END cl,
> CASE WHEN rn % 3 = 0 THEN vc END vc
> FROM numbered
> UNION ALL
> SELECT CASE WHEN rn % 2 = 1 THEN cs END cs,
> CASE WHEN rn % 2 = 0 THEN cl END cl,
> CASE WHEN rn % 3 = 1 THEN vc END vc
> FROM numbered) v
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]