使用 sqoop 增量更新更新 Hive table

Using sqoop incremental update for updating Hive table

我正在尝试根据 mysql table.

中的记录更新配置单元 table
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,使用 sqoop 中的增量更新将 mysql table 和 department_id 8 中的最后一条记录导入配置单元 table .

我的 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

我没有收到任何错误,但是来自 mysql table 和 department_id 8 的额外记录没有更新到配置单元 table。

请指出我哪里出错了。

我不知道我们是否正在研究大学实验室。好吧,我已经使用下面的代码完成了这件事。也许这对你也有用。

首先在配置单元中加载数据

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