Skip to content

Commit 79bde35

Browse files
author
jackylk
committed
demo3
1 parent 95f6903 commit 79bde35

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

examples/spark-hbase-demo3.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
## Create spark sql table map to existing hbase (only single column mapping to hbase rowkey is supported)
2+
(1) Create table in hbase, populate data
3+
```
4+
create 'hbase10k', 'f'
5+
for i in '1'..'10000' do for j in '1'..'2' do put 'hbase10k', "row#{i}", "f:c#{j}", "#{i}#{j}" end end
6+
```
7+
8+
(2) Map hbase table with sparksql table
9+
```
10+
CREATE TABLE spark10k(rowkey STRING, a INTEGER, b INTEGER, PRIMARY KEY (rowkey)) MAPPED BY (hbase10k, COLS=[a=f.c1, b=f.c2]);
11+
```
12+
13+
(3) Query:
14+
```
15+
// test count *
16+
(1) select count(*) from spark10k
17+
18+
// test group by
19+
(2) select avg(a), b from spark10k group by b
20+
```

0 commit comments

Comments
 (0)