我的数据如下所示:
bizunit
nam-bu1-us-credit
nam-bu2-us-debit
latam-bu3-mx-debit现在,我想将nam & latam提取到一个名为region的单独列中,并将bu1、bu2、bu3提取到一个名为business unit的单独列中,将us、mx提取到另一个名为<代码>D10的单独列中。
我将使用什么配置单元函数和SQL?请分享一个示例hive SQL,将上述数据分成3列进行提取。
发布于 2021-10-14 18:44:34
CREATE TABLE myTably(
myText string
)
INSERT INTO TABLE concat_test VALUES
('nam-bu1-us-credit'),
('nam-bu2-us-debit'),
('latam-bu3-mx-debit');以下是提取地区、业务单位和国家的查询
select
regexp_extract(myText, '([^-]+)-([^-]+)-([^-]+)-', 1),
regexp_extract(myText, '([^-]+)-([^-]+)-([^-]+)-', 2),
regexp_extract(myText, '([^-]+)-([^-]+)-([^-]+)-', 3) from MyTablehttps://stackoverflow.com/questions/69575058
复制相似问题