我正在尝试将记录插入到蜂巢中的结构内的结构

时间:2019-04-06 14:39:34

标签: data-structures struct hive

使用如下所示在struct内部定义struct的表

CREATE TABLE IF NOT EXISTS test12(
source_row_nbr  int, 
claim_record STRUCT < claim_sub_record1: STRUCT<claim_nbr:INT,claim_txt:CHAR(10)>,  
                      claim_sub_record2: STRUCT<claim_nbr:INT,claim_addr:CHAR(20)>>
)  stored as ORC 
TBLPROPERTIES('orc.compress'='SNAPPY','transactional'='false');

如何使用NAMED_STRUCT关键字插入记录

1 个答案:

答案 0 :(得分:0)

insert into table test12
select 1             as source_row_nbr ,
       named_struct('claim_sub_record1', named_struct('claim_nbr',123,'claim_txt','claim 123'),
                    'claim_sub_record2', named_struct('claim_nbr',124,'claim_txt','claim 124')
                   ) as claim_record  
  from dummy_table limit 1;