sepuri sai krishna created FLINK-41320:
------------------------------------------
Summary: CAST of ARRAY, ROW or MAP to CHAR/VARCHAR(n) returns
fewer than n characters and can insert a '?'
Key: FLINK-41320
URL: https://issues.apache.org/jira/browse/FLINK-41320
Project: Flink
Issue Type: Bug
Components: Table SQL / Planner
Affects Versions: 2.4.0
Reporter: sepuri sai krishna
Casting a constructed type to a bounded character type returns fewer characters
than the target
allows, and can return a character that was not in the input. The same cast on
a string column is
correct.
{code:sql}
-- s is a STRING column holding '𝕏𝕏𝕏', three characters outside the BMP
SELECT CAST(s AS VARCHAR(2)), -- 𝕏𝕏, correct
CAST(ARRAY[s] AS VARCHAR(2)), -- [?
CHAR_LENGTH(CAST(ARRAY[s] AS VARCHAR(5))), -- 3
CHAR_LENGTH(CAST(ARRAY[s] AS CHAR(9))) -- 6
FROM t;
{code}
The rendered array is {{[𝕏𝕏𝕏]}}, five characters, so {{VARCHAR(5)}} should hold
all of it and returns
three. The {{?}} was not in the input. A {{CHAR(9)}} value should be nine
characters.
{{ROW}} and {{MAP}} sources behave the same way.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)