[英]Error in Apache Hive regular expression
我對蜂巢中的正則表達式有疑問,它無法識別“;”。
insert overwrite table prueba
SELECT
regexp_extract(col_value, '^(?:([^;]*)\;?){1}', 1) VARIABLE,
regexp_extract(col_value, '^(?:([^;]*)\;?){2}', 1) TipoType
from temp;
發生的錯誤是:
H110無法提交對帳單。 編譯語句時出錯:
失敗:ParseException第3:29行無法識別'^''(('?'
在選擇表達式[ERROR_STATUS]
示例數據:
VARIABLE;Tipo/Type;
FECHA;DATE;
ID_CLIENTE;CHAR;
CUS_TYPE;CHAR;
CUS_SUBTYPE;CHAR;
NUEVOTITU;NUMBER;
TITULAR;NUMBER;
BAJATITU;NUMBER;
.
.
.
碼:
drop table temp;
drop table prueba;
create table temp (col_value string);
LOAD DATA INPATH '/tmp/data/prueba.csv' OVERWRITE INTO TABLE temp;
create table prueba(variable string, tipotype string);
insert overwrite table prueba
SELECT
regexp_extract(col_value, '^(([^\;]*)\;){1}', 1) variable,
regexp_extract(col_value, '^(([^\;]*)\;){2}', 1) tipotype
from temp;
臨時表:
temp.col_value
普魯巴表:
prueba.variable prueba.tipotype
我認為您需要轉義\\
,因此請嘗試
^(?:([^;]*)\\;?){1}
采用
SELECT
regexp_extract(col_value, '^(([^\;]*)\;){1}', 1) VARIABLE,
regexp_extract(col_value, '^(([^\;]*)\;){2}', 1) TipoType
from temp;
如果您需要不帶';'的列值 , 采用:
SELECT regexp_extract(col_value, '^(([^\;]*)){1}', 1) VARIABLE,regexp_extract(col_value, '(([^\;]*)\;){2}', 2) TipoType from temp;
編輯:我已經附上了截圖。 我的系統運行正常。 不知道為什么不對您執行。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.