공부 메모 중...


[환경]

 - centos 6.4

 - java 7

 - spark-2.0.0-bin-hadoop2.7

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
cd jars
# json format... 관련..
wget http://www.congiu.net/hive-json-serde/1.3/cdh5/json-serde-1.3-jar-with-dependencies.jar
 
sbin/start-thriftserver.sh
bin/beeline -u jdbc:hive2://localhost:10000
 
echo "1|abc|1.1|a" >> test.csv
echo "2|def|2.3|b" >> test.csv
 
create table if not exists testCsv (id INT, name STRING, score FLOAT, type STRING) ROW FORMAT DELIMITED FIELDS TERMINATED BY '|';
load data local inpath '/usr/local/tomcat/test.csv' into table testCsv;
 
0: jdbc:hive2://localhost:10000> select * from testCsv;
+-----+-------+--------------------+-------+--+
| id  | name  |       score        | type  |
+-----+-------+--------------------+-------+--+
| 1   | abc   | 1.100000023841858  | a     |
| 2   | def   | 2.299999952316284  | b     |
+-----+-------+--------------------+-------+--+
 
 
echo "{id: 1, name: 'abc', score: 1.1, type: 'a'}" >> test.json
echo "{id: 2, name: 'def', score: 2.2, type: 'b'}" >> test.json
 
create table if not exists testJson (id INT, name STRING, score FLOAT, type STRING) ROW FORMAT SERDE 'org.openx.data.jsonserde.JsonSerDe';
load data local inpath '/usr/local/tomcat/test.json' into table testJson;
 
0: jdbc:hive2://localhost:10000> select * from testJson;
+-----+-------+--------------------+-------+--+
| id  | name  |       score        | type  |
+-----+-------+--------------------+-------+--+
| 1   | abc   | 1.100000023841858  | a     |
| 2   | def   | 2.200000047683716  | b     |
+-----+-------+--------------------+-------+--+


+ Recent posts