Created
June 12, 2014 16:38
-
-
Save randyzwitch/b4163117578096d95773 to your computer and use it in GitHub Desktop.
Hive histogram as table
This file contains 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
SELECT | |
CAST(hist.x as int) as bin_center, | |
CAST(hist.y as bigint) as bin_height | |
FROM (select | |
histogram_numeric(salary, 20) as salary_hist | |
from | |
sample_08) a | |
LATERAL VIEW explode(salary_hist) exploded_table as hist; | |
--Results | |
bin_center bin_height | |
0 23507 255 | |
1 31881 340 | |
2 39824 287 | |
3 47615 181 | |
4 55667 164 | |
5 59952 8 | |
6 66034 137 | |
7 75642 82 | |
8 82496 44 | |
9 91431 60 | |
10 100665 21 | |
11 107326 15 | |
12 121248 16 | |
13 142070 2 | |
14 153896 6 | |
15 162310 6 | |
16 169810 2 | |
17 176740 2 | |
18 193925 8 | |
19 206770 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment