我要澄清猪的数量
transactions = LOAD '/user/valivetv/transactions.csv' using PigStorage(',') as (transaction_id:long,transaction_date:datetime, cust_id:long, age:chararray, area:chararray, prod_subclass:int, prod_id:long, amt:int, asset:int, sales_price:int, phone_no:chararray, country_code:chararray);
data_grpd = GROUP transactions ALL;
string_stats = FOREACH data_grpd GENERATE group,COUNT_STAR(transactions.country_code),COUNT(transactions.country_code);
string_stats1 = FOREACH data_grpd GENERATE group,COUNT_STAR(transactions),COUNT(transactions);我注意到string_stats和string_stat1都给出了相同的输出。
计数(transactions.country_code)和计数(事务)有什么不同?
发布于 2021-01-04 02:36:13
COUNT(transactions.country_code)将只计算一包country_code元组,而COUNT(transactions)将计算一包元组将计算您加载的事务关系中的所有原始字段。
如果在没有看到原始数据的情况下看到相同的输出,那么可能每条记录都有country_code字段的数据?在这种情况下,COUNT实质上是返回原始数据中的记录数。
https://stackoverflow.com/questions/65419783
复制相似问题