gpt4 book ai didi

hadoop - 如何加入并在PIG中寻找值(value)?

转载 作者:行者123 更新时间:2023-12-02 21:03:29 26 4
gpt4 key购买 nike

* hwo合并这两个表并检查NDAKOTA地区的ID大于1600 *

1阿拉斯加罗伯特
2波士顿礼来
3 NDakota Michael
4 NDakota威尔
5 NDakota马克

1A 1 09/09/2012 1200
2A 2 2016年8月9日3400
3B 3 4/5/2016 2300

customers = LOAD '/home/vis/Documents/customers' using PigStorage(' ')               AS(cust_id:int,region:chararray,name:chararray);

sales = LOAD '/home/vis/Documents/sales' using PigStorage(' ')
AS(sales_id:int,cust_id:int,date:datetime,amount:int);

salesNA = FILTER customers BY region =='NDakota';

joined = JOIN sales BY cust_id,salesNA BY cust_id;

grouped = GROUP joined BY cust_id;

summed= FOREACH grouped GENERATE GROUP,SUM(sales.amount);

bigSpenders= FILTER summed BY 1$>1600;

DUMP sorted;

接收错误为

enter image description here

最佳答案

来自Apache Pig文档

Use the disambiguate operator ( :: ) to identify field names after JOIN, COGROUP, CROSS, or FLATTEN operators.



下面的代码片段应足以实现目标,如果您发现任何问题,请告诉我。
customers = LOAD 'customers.txt' using PigStorage(' ')  AS(cust_id:int,region:chararray,name:chararray);
sales = LOAD 'sales.txt' using PigStorage(' ') AS(sales_id:chararray,cust_id:int,date:chararray,amount:int);
custNA = FILTER customers BY region =='NDakota';
joined = JOIN sales BY cust_id,custNA BY cust_id;
req_data = FILTER joined BY amount > 1600;
DUMP req_data;

关于hadoop - 如何加入并在PIG中寻找值(value)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42587011/

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