1 将Map展开为多列多行。
CREATE TABLE source_table (
userId INT,
eventTime as '2021-10-01 08:08:08',
eventType as 'click',
productId INT,
-- 数组(Array)类型
productImages as ARRAY['image1','image2'],
-- 对象(Map)类型
pageInfo as MAP['pageId','1','pageName','yyds']
) WITH (
'connector' = 'datagen',
'number-of-rows' = '2',
'fields.userId.kind' = 'random',
'fields.userId.min' = '2',
'fields.userId.max' = '2',
'fields.productId.kind' = 'sequence',
'fields.productId.start' = '1',
'fields.productId.end' = '2'
);
将Map展开为多列多行。
基于UNNEST
SELECT userId,eventTime,eventType,productId,mapKey,mapValue
FROM source_table, UNNEST(pageInfo) as t(mapKey,mapValue);
</