我创建了带有最后一个值的增量附加的 sqoop 作业
工作:
sqoop job --create myjob2 -- import --connect jdbc:mysql://host/DBnam -username user -password passwor --table savingssmal --check-column id --incremental append --last-value 0 --target-dir /user/xxxx/prac/sqoop --split-by id --as-parquetfile -m 1
我的问题是:我想将新创建的记录和更新的记录导入 mysql 表?
你能帮我吗?
您可以使用lastmodified
模式进行增量 Sqoop 导入。
append
模式(在您的示例中使用(用于根据增加的行 ID 值导入行。因此,当作业运行时,它将导入--check-column
(即id
( 大于--last-value
(即0
(。如果更新了行,则id
通常保持不变,并且不会导入更新的行。
lastmodified
模式用于基于时间戳列(例如,last_modified_time
(导入行。当作业运行时,它将导入--check-column
比通过--last-value
指定的更新的行。写入表的应用程序应更新插入和更新的last_modified_time
列。这样,当 Sqoop 作业运行时,将导入新插入和更新的行。
基于您的lastmodified
模式示例调用示例如下所示:
sqoop job --create myjob2 -- import --connect jdbc:mysql://host/DBnam -username user -password passwor --table savingssmal --check-column last_update_time --incremental lastmodified --last-value "2018-02-03 04:38:39.0" --target-dir /user/xxxx/prac/sqoop --as-parquetfile -m 1