I'm trying to use regexp_extract to extract my required data from a column(string datatype) in my table, Im using this query:
select regexp_extract(concat(column_name,;),'.*a2=?(.*?);',1) from table;
But I get an error:
FAILED: ParseException line 1:43 cannot recognize input near '.' '*' 'a2' in select expression
I'm at my wit's end with this, could anyone tell me what I'm doing wrong? Can regexp_replace not be used on columns? Any help would be appreciated.
I'm using hive version 0.13.1
Finally figured it out, in hive you need to escape the semi-colon.
Hope this helps someone.
EDIT: Here's the answer that worked:
regexp_extract(concat(column_name,'\\;'),'.*a2=?(.*?)\\;',1)
I am concatenating a ';' because my logic requires it.
This should replace semicolons with '\\073' in the script below.
Apache Hive (version 1.2.1000.2.4.3.3-2)
select regexp_extract(concat("columna2=blablablatest",'\073'),'.*a2=?(.*?)\073',1);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.