gpt4 book ai didi

hadoop - pig : Create new column based off of two other columns

转载 作者:可可西里 更新时间:2023-11-01 16:13:48 25 4
gpt4 key购买 nike

我想知道是否有可能在 pig 身上做这样的事情:

一共有三列:

“类型 1”、“类型 2”、“类型 3”

B 101 , 159 , 74

我想这样定义 C 列:

如果 A == "type1"那么 C = B;否则 C = 0

这在 pig 身上可能吗?

最佳答案

是的,这是可能的。你可以这样写:

data = LOAD '$dataSource' using AvroStorage();
-- data = {A, B}

data2 = FOREACH data
GENERATE
A,
B,
(A == 'type1' ? B : 0) AS C;

dump data2;

关于hadoop - pig : Create new column based off of two other columns,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26286800/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com