2016-12-28 3 views
0

mysqlテーブルのレコードに基づいてハイブテーブルを更新しようとしています。ハイブテーブルの更新にsqoopインクリメンタルアップデートを使用する

mysql-table: (table name: delimiter_test) 

+---------------+-----------------+ 
| department_id | department_name | 
+---------------+-----------------+ 
|    2 | Fitness   | 
|    3 | Footwear  | 
|    4 | Apparel   | 
|    5 | Golf   | 
|    6 | Outdoors  | 
|    7 | Fan Shop  | 
|    8 | Test   | 
+---------------+-----------------+ 

hive-table (table name: my_test) 

2 Fitness 
3 Footwear 
4 Apparel 
5 Golf 
6 Outdoors 
7 Fan Shop 

私はsqoopでインクリメンタル更新を使用してハイブ表に、DEPARTMENT_ID 8とMySQLのテーブルの最後のレコードをインポートするには、sqoopを使用しようとしています。

私-sqoopコマンド:

sqoop import --connect "jdbc:mysql://quickstart.cloudera:3306/retail_db" --username xxx --password xxx --table delimiter_test --hive-import --hive-table my_test --split-by department_id --check-column department_id --incremental append --last-value 7 

私はすべてのエラーを得ていないのですが、DEPARTMENT_ID 8とMySQLのテーブルから余分なレコードがハイブテーブルに更新取得されません。

私が間違っているところを教えてください。

+0

コマンド私には良いようです。 swoopコマンドの最後に '--verbose'を追加して拡張ログを見て、エラーが見つかったかどうか確認できますか? –

+0

@devツ私は、10( - m 10)、department_id 8の追加レコードをハイブテーブルに2回挿入し、 - m 6、レコード正しく挿入されました。 – vikky

+0

department _id文字列はハイブテーブルにありますか? '--verbose'の後ろに全ログを共有してください –

答えて

0

おそらく私たちが反省ラボに取り組んでいるかどうかはわかりません。さて、私は以下のコードを使ってこのことを行いました。おそらくそれもあなたのために働くことができます。ハイブ

sqoop import --connect jdbc:mysql://xxxxx/retail_db --username xxxx --password xxxx \ 
--table departments --where department_id=2 --hive-import --hive-database poc --hive-table departments_sqoop \ 
--target-dir /user/ingenieroandresangel/sqoop/dep_hive --split-by department_id -m 1 

まず負荷データは、その後、私は以下のスクリプトを使用してアップデートを実行します。

sqoop import --connect jdbc:mysql://xxxxxx/retail_db --username xxxxx --password xxxx \ 
--table departments --where 'department_id>=2' --hive-import --hive-database poc --hive-table departments_sqoop --incremental append \ 
--check-column department_id --last-value 2 --target-dir /user/ingenieroandresangel/sqoop/dep_hive --split-by department_id -m 1 
関連する問題