[英]How does Hive works regular expression with < and > symbols?
這是Siva Ramanjaneyulu,我正在研究蜂巢。 我的蜂巢有以下問題
sample.log: <ABC>
CREATE TABLE sample4( num1 STRING ) ROW FORMAT SERDE
'org.apache.hadoop.hive.contrib.serde2.RegexSerDe' WITH
SERDEPROPERTIES ( "input.regex" = "<.*>", "output.format.string" =
"%1$s" ) STORED AS TEXTFILE;
LOAD DATA LOCAL INPATH "../hive-0.9.0/sample.log" INTO TABLE sample4;
select * from sample4;
NULL
預期產量:ABC
為什么此.RegexSerDe
在常規表達式<.*>
上不起作用?
如何使用正則表達式刪除<和> symbels,您能為此提供解決方案嗎
嘗試這個 :
hive>使用SERDEPROPERTIES創建表s(num1字符串)行格式SERDE'org.apache.hadoop.hive.contrib.serde2.RegexSerDe'(“ input.regex” =“(<。*>)”,“ output.format。 string“ =”%1 $ s“)存儲為文本文件;
注意正則表達式的parentheses
。
之所以得到NULL值,是因為您沒有在正則表達式定義中包含括號。 如果您不希望將尖括號包含在輸出中,則需要將它們放在括號之外。 括號內的內容將作為輸出返回。
CREATE TABLE sample4 (num1 string)
ROW FORMAT SERDE 'org.apache.hadoop.hive.contrib.serde2.RegexSerDe'
WITH SERDEPROPERTIES (
"input.regex" = "<(.*)>"
, "output.format.string" = '%1$s'
)
STORED AS TEXTFILE;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.