将字段值与猪袋中的值匹配
Match a field value with a value in a bag in pig
我在猪中有以下格式的关系:
test = file::field1: chararray,x::y: {(z: chararray)}
例如:测试 = a,({(a),(b),(c),(d)})
我想检查包 x 中是否存在 field1 值(即 a)。如何在猪中实现这一目标?
我发现在 pig 中没有办法做到这一点。我已将 field 和 bag 都传递给 python UDF 并将其匹配如下:
@outputSchema('matchindx:int')
def pythudf(field1,bag):
for word in bag:
if (word[0] == field1):
return 1
return 0
我在猪中有以下格式的关系:
test = file::field1: chararray,x::y: {(z: chararray)}
例如:测试 = a,({(a),(b),(c),(d)})
我想检查包 x 中是否存在 field1 值(即 a)。如何在猪中实现这一目标?
我发现在 pig 中没有办法做到这一点。我已将 field 和 bag 都传递给 python UDF 并将其匹配如下:
@outputSchema('matchindx:int')
def pythudf(field1,bag):
for word in bag:
if (word[0] == field1):
return 1
return 0