How to Define nested Collection items in Hive

后端 未结 1 1344
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-12 04:15

I am trying to create a hive table with nested Collection items. Suppose I have an array of struct.

    CREATE TABLE SAMPLE(
    record array

        
相关标签:
1条回答
  • 2021-01-12 04:51

    Try something like this:

    CREATE TABLE SAMPLE(
    id BIGINT,
    record array<struct<col1:string,col2:string>>
    )row format delimited
    fields terminated by ','
    collection items terminated by '|'
    map keys terminated by ':';
    

    Now you data in text file will look like this:

    1345653,110909316904:1341894546|221065796761:1341887508
    

    You can then query it like :

    select record.col1 from SAMPLE;
    
    0 讨论(0)
提交回复
热议问题