Exploding Array of Struct using HiveQL

后端 未结 1 1158
伪装坚强ぢ
伪装坚强ぢ 2021-01-07 03:02
CREATE TABLE IF NOT EXISTS Table2
(
USER_ID BIGINT,
PURCHASED_ITEM ARRAY>
) ROW FORMAT
 DELIMITED FIELDS TER         


        
1条回答
  •  礼貌的吻别
    2021-01-07 03:31

    You can use the function regexp_replace or regex_extract to get only the product id. Try this:

    SELECT  * FROM (select user_id, prod_and_ts.product_id as product_id,
    regex_replace(prod_and_ts.timestamps, "#\\d*", "")  as timestamps FROM table2 LATERAL VIEW
    explode(purchased_item) exploded_table as prod_and_ts) prod_and_ts;
    

    0 讨论(0)
提交回复
热议问题