Hive - 在 string/row 中的任意位置找到 2 个字符 - RLIKE
Hive - find 2 characters anywhere in the string/row - RLIKE
如何获取分配给 "USA_RBB_WA_BU" 的仅“_WA”数据的数据?
但是,我查看的列中有包含 _WA 和 _SA (USA_CA_SAWANT)
的行
我用过,
select....
'USA_RBB_WA_BU' AS State ,
District
from TABLE where district like '%_WA%'
select ...
'USA_RBB_NSW_BU' AS State ,
District
from TABLE where district like '%_SA%'
但是我最终的数据输出table低于
**state district**
USA_RBB_NSW_BU USA_CA_SAWANT
USA_RBB_WA_BU USA_CA_SAWANT
USA_RBB_NSW_BU USA_CA_SAWANT
USA_RBB_WA_BU USA_CA_SAWANT
我试过了
select....
'USA_RBB_WA_BU' AS State ,
District
from TABLE where district like '_WA%'
output was was 0 results in hive
我猜你是想在这里转义_
。试试下面 -
SELECT <FIELD_LIST>
'USA_RBB_WA_BU' AS State ,
District
FROM TABLE
WHERE district RLIKE '.*_WA%'
where district rlike '_WA'
将正常工作(如果字符串包含 _WA,这将 return 为真)
如果你希望字符串在_WA
之前和之后包含一些东西,添加.+
(任意字符一次或多次):
where district rlike '.+_WA.+'
如何获取分配给 "USA_RBB_WA_BU" 的仅“_WA”数据的数据? 但是,我查看的列中有包含 _WA 和 _SA (USA_CA_SAWANT)
的行我用过,
select....
'USA_RBB_WA_BU' AS State ,
District
from TABLE where district like '%_WA%'
select ...
'USA_RBB_NSW_BU' AS State ,
District
from TABLE where district like '%_SA%'
但是我最终的数据输出table低于
**state district**
USA_RBB_NSW_BU USA_CA_SAWANT
USA_RBB_WA_BU USA_CA_SAWANT
USA_RBB_NSW_BU USA_CA_SAWANT
USA_RBB_WA_BU USA_CA_SAWANT
我试过了
select....
'USA_RBB_WA_BU' AS State ,
District
from TABLE where district like '_WA%'
output was was 0 results in hive
我猜你是想在这里转义_
。试试下面 -
SELECT <FIELD_LIST>
'USA_RBB_WA_BU' AS State ,
District
FROM TABLE
WHERE district RLIKE '.*_WA%'
where district rlike '_WA'
将正常工作(如果字符串包含 _WA,这将 return 为真)
如果你希望字符串在_WA
之前和之后包含一些东西,添加.+
(任意字符一次或多次):
where district rlike '.+_WA.+'