从配置单元的文本列中提取子字符串

extracting a substring from a text column in hive

我们在名为 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"

需要从上面的 hive 文本数据中提取显示名称(本例中为 Jund lee),我试过使用 substring 函数但似乎不起作用,请帮助

regexp_extract 函数与 matching 正则表达式结合使用,仅从您的 title 字段值中捕获 displayName

例如:

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  |
+-----------+--+