我们在名为title的列中有文本数据,如下所示
"id":"S-1-98-13474422323-33566802","name":"uid=Xzdpr0,ou=people,dc=vm,dc=com","shortName":"XZDPR0","displayName":"Jund Lee","emailAddress":"jund.lee@bm.com","title":"Leading Product Investor"
需要从蜂巢中的上述文本数据中仅提取显示名称(在本示例中为Jund Lee),我尝试使用子字符串功能,但似乎不起作用,请帮助
答案 0 :(得分:0)
将 regexp_extract 函数与matching
正则表达式一起使用,以仅从displayName
字段值中捕获title
。
例如:
hive> with tb as(select string('"id":"S-1-98-13474422323-33566802",
"name":"uid=Xzdpr0,ou=people,dc=vm,dc=com","shortName":"XZDPR0",
"displayName":"Jund Lee","emailAddress":"jund.lee@bm.com",
"title":"Leading Product Investor"')title)
select regexp_extract(title,'"displayName":"(.*?)"',1) title from tb;
+-----------+--+
| title |
+-----------+--+
| Jund Lee |
+-----------+--+