将行插入到具有数组作为字段之一的配置单元表时出现错误 10293

Jag*_*ish 3 hive

我有一个使用以下查询创建的配置单元表:

create table arraytbl (id string, model string, cost int, colors array <string>,size array <float>)
row format delimited fields terminated by ',' collection items terminated by '#';
Run Code Online (Sandbox Code Playgroud)

现在,在尝试插入一行时:

insert into mobilephones values 
("AA","AAA",5600,colors("red","blue","green"),size(5.6,4.3));
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

FAILED: SemanticException [Error 10293]: Unable to create temp file for insert values Expression of type TOK_FUNCTION not supported in insert/values
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个问题?

Gau*_*hah 5

在复杂数据类型中输入值的语法有点奇怪,但这是我个人的意见。

您需要一个虚拟表来将值插入具有复杂数据类型的配置单元表中。

insert into arraytbl select "AA","AAA",5600, array("red","blue","green"), array(CAST(5.6 AS FLOAT),CAST(4.3 AS FLOAT)) from (select 'a') x;
Run Code Online (Sandbox Code Playgroud)

这就是插入后的样子。

hive> select * from arraytbl;
OK
AA  AAA 5600    ["red","blue","green"]  [5.6,4.3]
Run Code Online (Sandbox Code Playgroud)