0
students = LOAD 'hdfs://localhost:9000/pig_data/students.txt' USING PigStorage(',')
   as (id:int, firstname:chararray, lastname:chararray, phone:chararray, city:chararray, cgpa:int);
group_all = Group students All;
student_count = foreach group_all  Generate COUNT(students.cgpa);
Dump student_count;

这是计算学生人数的简单程序。我怎样才能像任何变量名称学生计数值一样获得计数旁边的变量名称

4

2 回答 2

0
DUMP 'value',student_count.$0;
于 2020-07-24T13:24:00.463 回答
0

当您转储时,您应该看到列的名称,它将类似于 _c0

如果要重命名,可以定义一个新变量,如下所示:

student_count_named= foreach student_count generate $0 as a, $1 as b

您也可以尝试将 as 直接放在计数之后,但尚未尝试过。

于 2020-07-30T20:43:22.230 回答