Created
October 19, 2012 16:30
-
-
Save wyukawa/3919187 to your computer and use it in GitHub Desktop.
PigのCUBE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ cat cube.dat | |
| dog,miami,12 | |
| cat,miami,18 | |
| turtle,tampa,4 | |
| dog,tampa,14 | |
| cat,naples,9 | |
| dog,naples,5 | |
| turtle,naples,1 | |
| $ cat cube.pig | |
| a = load 'cube.dat' USING PigStorage(',') as (x:chararray,y:chararray,z:long); | |
| b = cube a BY cube(x, y); | |
| c = foreach b generate flatten(group) as (type,location), COUNT_STAR(cube) as count, SUM(cube.z) as total; | |
| DUMP c; | |
| $ bin/pig -version | |
| Apache Pig version 0.12.0-SNAPSHOT (r1400075) | |
| compiled 10 19 2012, 21:45:30 | |
| $ bin/pig -x local cube.pig | |
| --ログは省略-- | |
| (cat,miami,1,18) | |
| (cat,naples,1,9) | |
| (cat,,2,27) | |
| (dog,miami,1,12) | |
| (dog,tampa,1,14) | |
| (dog,naples,1,5) | |
| (dog,,3,31) | |
| (turtle,tampa,1,4) | |
| (turtle,naples,1,1) | |
| (turtle,,2,5) | |
| (,miami,2,30) | |
| (,tampa,2,18) | |
| (,naples,3,15) | |
| (,,7,63) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment