John Sherman created HIVE-26398: ----------------------------------- Summary: INSERT INTO complex type with varchar/char field fails CBO Key: HIVE-26398 URL: https://issues.apache.org/jira/browse/HIVE-26398 Project: Hive Issue Type: Bug Components: HiveServer2 Affects Versions: 4.0.0 Reporter: John Sherman Assignee: John Sherman
{code} CREATE EXTERNAL TABLE test_complex_struct(struct_type struct<string_type : STRING, varchar_type : VARCHAR(100), char_type : CHAR(34)>) STORED AS PARQUET; INSERT INTO test_complex_struct SELECT named_struct("string_type", 'str1', "varchar_type", cast('varchar1' as varchar(100)), "char_type", cast('char' as char(34))); {code} fails with {code} org.apache.hadoop.hive.ql.parse.SemanticException: Line 2:12 Cannot insert into target table because column number/types are different 'test_complex_struct': Cannot convert column 0 from struct<string_type:string,varchar_type:string,char_type:string> to struct<string_type:string,varchar_type:varchar(100),char_type:char(34)>.{code} This also fails with maps: {code} CREATE EXTERNAL TABLE test_complex_map(t_map map<varchar(100), char(10)>) STORED AS PARQUET; INSERT INTO test_complex_map SELECT map(cast("test" as varchar(100)), cast("value" as char(10))); {code} It seems that the cast is being lost or ignored somewhere along the way (and it stays a string). The queries do complete when ran on the non-CBO path. (Disabling CBO or falling back) -- This message was sent by Atlassian Jira (v8.20.10#820010)