I'd like to extract texts based on some key words from Hive database.
It works if my script looks like,
SELECT text
FROM table
WHERE text RLIKE '.?(aaa|bbb|ccc).?';
But in order to make the script more readable, I'd like to set the key words as a variable in hive. But the script fails if it looks like,
SET hivevar:KeyWords='.?(aaa|bbb|ccc).?';
SELECT text
FROM table
WHERE text RLIKE ${hivevar:KeyWords};
Any idea? Thanks.
Fu
'.?(aaa|bbb|ccc).?'is actually the same as'aaa|bbb|ccc'in this case, you are using it withRLIKE.set KeyWords='aaa|bbb|ccc'and thenRLIKE ${hiveconf:KeyWords}. What is your Hive version? Thehivevarvariables can be used with the 0.8.0 version and higher.table) and column name (probably nottext) (2) check the value ofset hive.variable.substitute