* hwo to combine these two tables and check the id's which are greater than 1600 for NDAKOTA regions*
1 alaska robert
2 boston lilly
3 NDakota Michael
4 NDakota Will
5 NDakota Mark
1A 1 09/09/2012 1200
2A 2 8/9/2016 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;
recieving errors as
From Apache Pig Docs
Use the disambiguate operator ( :: ) to identify field names after JOIN, COGROUP, CROSS, or FLATTEN operators.
Below code snippet should be suffice to achieve the objective, let me know if you see any issues.
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;