LoginSignup
1
2

More than 5 years have passed since last update.

Apache Sqoopを使ってみる その2

Posted at

前回のApache Sqoopを使ってみるに引き続きSqoopネタです。

前回は、インポート(MySQL -> HDFS )を試しましたが、今回は、MySQLから直接Hiveテーブルに転送します。

とは言うものの、Hiveへの転送は、--hive-importオプションをつけるだで、Hiveテーブルの作成からINSERTまで行ってくれます。

[root@sandbox ~]# sqoop import --connect jdbc:mysql://localhost/sqoopsample --table employees -m 1 --hive-import 

...
...

Time taken: 3.121 seconds
Loading data to table default.employees
Table default.employees stats: [numFiles=2, numRows=0, totalSize=103, rawDataSize=0]
OK
Time taken: 0.969 seconds

Hiveのスキーマは、データソースのテーブルのスキーマから自動決定されるようです。

[root@sandbox ~]# hive
Logging initialized using configuration in file:/etc/hive/conf.dist/hive-log4j.properties
hive> select * from employees;
select * from employees;
OK
1       TANAKA Ichiro   30      1984-10-10      hoge
2       TANAKA Jiro     29      1985-12-22      fuge
3       TANAKA Saburo   28      1986-08-01      null
Time taken: 2.247 seconds, Fetched: 3 row(s)

というわけで以上。

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2