Faisons une démonstration simple pour comprendre ce problème.
dire un fichier 'a.txt' stockés au dossier '/tmp/a.txt' dans HDFS
A = CHARGE '/tmp/a.txt' en utilisant PigStorage ('') AS (nom: chararray, terme: chararray, gpa: float);
Dump A;
(John, fl, 3,9)
(John, fl, 3,7)
(John, sp, 4,0)
(John, sm, 3,8)
(Mary, fl, 3,8)
(Mary, fl, 3,9)
(Mary, sp, 4.0)
(Mary, sm, 4.0)
Maintenant, le groupe de laisser par cet alias A »sur la base de certains paramètres dire le nom et la durée
B = GROUPE UN (nom, terme);
dump B;
((John, fl), {(John, fl, 3,7), (John, fl, 3,9)})
((John, sm), {(John, sm, 3,8)})
((John, sp), {(John, sp, 4.0)})
((Mary, fl), {(Mary, fl, 3,9), (Mary, fl, 3,8)})
((Mary, sm), {(Mary, sm, 4.0)})
((Mary, sp), {(Mary, sp, 4.0)})
décrivent B;
B: {groupe: (nom: chararray, terme: chararray), A: {(nom: chararray, terme: chararray, gpa: float)}}
maintenant il est devenu le problème déclaration que vous avez demandé.Permettez-moi de vous montrer comment accéder aux éléments d'un groupe de tuple ou d'un élément de A tuple ou les deux
C = pour chaque B générer groupe.nom, groupe.term, A.nom, A.term, A.gpa;
dump C;
(John, fl, {(Jean), (John)}, {(fl), (fl)}, {(3,7), (3,9)})
(John, sm, { (John)}, {(sm)}, {(3,8)})
(John, sp, {(John)}, {(sp)}, {(4,0)})
(Mary , fl, {(Mary), (Mary)}, {(fl), (fl)}, {(3.9), (3.8)})
(Mary, sm, {(Mary)}, {(sm)}, {(4.0)})
(Mary, sp, {(Mary)}, {(sp)}, {(4.0)})
Nous avons donc accédé à tous les éléments de cette manière.
espérons que cela a aidé