【发布时间】:2020-05-02 06:02:07
【问题描述】:
我正在运行一个查询,该查询使用 PrestoDB 和 AWS S3(以及用于元数据的 Glue)将数据从源表插入到目标表。
查询如下所示(尽管它有更多案例):
INSERT INTO my_table
SELECT other_field AS other_field ,
(CASE
WHEN regexp_like(LOWER(user_agent) , LOWER('bot')) THEN '1'
WHEN regexp_like(LOWER(user_agent) , LOWER('spider')) THEN '2'
WHEN regexp_like(LOWER(user_agent) , LOWER('crawler')) THEN '3'
WHEN regexp_like(LOWER(user_agent) , LOWER('Google-AdSense-Auto')) THEN '4'
WHEN regexp_like(LOWER(user_agent) , LOWER('Google-Adwords-DisplayAds-WebRender')) THEN '5'
ELSE NULL
END) AS bot_type
FROM source_table;
有没有办法更有效地做到这一点?我找不到任何有关此的资源。
【问题讨论】:
-
一个选项是单词和数字的映射表,可以在
insert之前使用join。
标签: regex amazon-s3 hive presto