Apache pig 猪型匹配
我试图找到字符串“标准保费是”在字符串中“在2015年,每月B部分标准保费是104.90美元”,但我无法在Pig中这样做 我在试着用正则表达式Apache pig 猪型匹配,apache-pig,Apache Pig,我试图找到字符串“标准保费是”在字符串中“在2015年,每月B部分标准保费是104.90美元”,但我无法在Pig中这样做 我在试着用正则表达式 `PlanServiceEng = FILTER PlanService BY language == 'English' and contractid !='' and planid !='' and segmentid !='' and benefit !='' and (benefit MATCHES '.*Standard Premium is
`PlanServiceEng = FILTER PlanService BY language == 'English' and contractid !='' and planid !='' and segmentid !='' and benefit !='' and (benefit MATCHES '.*Standard Premium is.*');`
但当我试图找到只是'溢价'与
下面是正则表达式,它可以工作:
PlanServiceEng = FILTER PlanService BY language == 'English' and contractid !='' and planid !='' and segmentid !='' and benefit !='' and (benefit matches '.*Premium.*');
您不能使用
EqualsIgnoreCase()
函数吗
EqualsIgnoreCase()
函数用于比较两个字符串并验证它们是否相等。如果两者相等,则此函数返回布尔值true,否则返回值false
PlanServiceEng = FOREACH PlanService GENERATE (language,benefit), EqualsIgnoreCase(benefit, 'Standard Premium is');
或者您可以尝试使用正则表达式函数regex_EXTRACT或regex_EXTRACT_ALL
我用REGEX
尝试了一些东西。请检查这是否适用于您
此处%s
将是您要匹配的文本
b = FOREACH a GENERATE $0,$1,REGEX_EXTRACT_ALL($1,'.*%s.*') ;
此语句将添加另一个匹配字段,该字段为()
。因此,为了得到匹配的数据,我们将运行一个过滤器
filtered = FILTER b BY $2 is not null;