0

We have text data in a column named title like below

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

Need to extract just the display name (Jund lee in this example) from the above text data in hive, I have tried using substring function but don't seem to work,Please help

user86683
  • 121
  • 1
  • 6

1 Answers1

0

Use regexp_extract function with the matching regex to capture only the displayName from your title field value.

Ex:

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  |
+-----------+--+
notNull
  • 30,258
  • 4
  • 35
  • 50