regexp_extract in hive giving error

流过昼夜 提交于 2021-02-05 06:39:25

问题


I have some data in table e.g.:

id,params  
123,utm_content=doit|utm_source=direct|   
234,utm_content=polo|utm_source=AndroidNew|

desired data using regexp_extract:

id,channel,content
123,direct,doit
234,AndroidNew,polo

Query used:

Select id, REGEXP_extract(lower(params),'(.*utm_source=)([^\|]*)(\|*)',2) as channel, REGEXP_extract(lower(params),'(.*utm_content=)([^\|]*)(\|*)',2)  as content from table;

It is showing error '* dangling meta character' and returning error code 2

Can someone help here please??


回答1:


Note that in hive, you need to double the backslashes.

Your regex should look like

(.*utm_content=)([^|]*)(\\|*)


来源:https://stackoverflow.com/questions/34836782/regexp-extract-in-hive-giving-error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!