[英]Hive query regexp_extract failing
I'm trying to use regexp_extract to extract my required data from a column(string datatype) in my table, Im using this query: 我正在尝试使用regexp_extract从表中的列(字符串数据类型)中提取所需的数据,我正在使用此查询:
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?
regexp_replace不能用于列吗? Any help would be appreciated.
任何帮助,将不胜感激。
I'm using hive version 0.13.1 我正在使用Hive版本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. 在下面的脚本中,这应该用'\\ 073'代替分号。
Apache Hive (version 1.2.1000.2.4.3.3-2) Apache Hive(版本1.2.1000.2.4.3.3-2)
select regexp_extract(concat("columna2=blablablatest",'\073'),'.*a2=?(.*?)\073',1);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.