Skip to content

Commit

Permalink
Run Hive snippets against distributed Hadoop.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomwhite committed Jan 28, 2012
1 parent ae3337a commit 4893fed
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
2 changes: 2 additions & 0 deletions ch12/src/main/hive/buckets.hive
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ SELECT * FROM users;

dfs -ls /user/hive/warehouse/bucketed_users;

dfs -cat /user/hive/warehouse/bucketed_users/000000_0;

! echo; # vv sample_1_in_4;
SELECT * FROM bucketed_users
TABLESAMPLE(BUCKET 1 OUT OF 4 ON id);
Expand Down
7 changes: 0 additions & 7 deletions ch12/src/main/hive/joins.hive
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
! echo; # == left_outer_join;
! echo; # == right_outer_join;
! echo; # == full_outer_join;
! echo; # == select_things_in_sales;
! echo; # == semi_join;
! echo; # == map_join;

Expand Down Expand Up @@ -46,12 +45,6 @@ SELECT sales.*, things.*
FROM sales FULL OUTER JOIN things ON (sales.id = things.id);
! echo; # ^^ full_outer_join;

! echo; # vv select_things_in_sales;
SELECT *
FROM things
WHERE things.id IN (SELECT id from sales);
! echo; # ^^ select_things_in_sales;

! echo; # vv semi_join;
SELECT *
FROM things LEFT SEMI JOIN sales ON (sales.id = things.id);
Expand Down
6 changes: 5 additions & 1 deletion snippet/bin/hiver.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/bin/bash
#
# Usage:
# hiver.sh
# hiver.sh -hiveconf fs.default.name=file:/// -hiveconf mapred.job.tracker=local

set -x
set -e
Expand All @@ -15,7 +19,7 @@ mkdir -p $actual/ch12

for f in ch12/src/main/hive/*.hive; do
out=$f.output.txt
hive -hiveconf fs.default.name=file:/// -hiveconf mapred.job.tracker=local -S < $f 2> /dev/null \
hive "$@" -S < $f 2> /dev/null \
| grep -v '^hive> $' \
| grep -v '^$' \
| sed -e 's|&|\&amp;|g' \
Expand Down

0 comments on commit 4893fed

Please sign in to comment.