简体   繁体   English

sqoop增量导入更新的行和新创建的记录

[英]sqoop incremental import updated row and newly created record

I have the sqoop job created with incremental append with last value 我有使用最后一个值的增量追加创建的sqoop作业

Job: 工作:

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

My question is: I want to import the newly created record and also updated record into a mysql table? 我的问题是:我想将新创建的记录以及更新后的记录导入到mysql表中?

Can you please help me in this? 你能帮我吗?

You can use the lastmodified mode for incremental Sqoop import. 您可以使用lastmodified模式进行增量Sqoop导入。

The append mode (used in your example) is used to import rows based on increasing row id values. append模式(在您的示例中使用)用于基于增加的行id值导入行。 So, when the job runs, it will import rows where --check-column (ie id ) is greater than --last-value (ie 0 ). 因此,当作业运行时,它将导入--check-column (即id )大于--last-value (即0 )的行。 If a row is updated, the id will generally remain the same and the updated row won't be imported. 如果更新了一行,则id通常将保持不变,并且不会导入更新的行。

The lastmodified mode is used to import rows based on a timestamp column (for example, last_modified_time ). lastmodified模式用于根据时间戳列(例如last_modified_time )导入行。 When the job runs, it will import rows where --check-column is more recent than specified via --last-value . 作业运行时,它将导入--check-column比通过--last-value指定的更新的行。 The application writing to the table should update the last_modified_time column on inserts and updates. 写入表的应用程序应在插入和更新时更新last_modified_time列。 This way, both newly inserted and updated rows will be imported when the Sqoop job runs. 这样,当Sqoop作业运行时,新插入的行和更新的行都将被导入。

A sample invocation based on your example with the lastmodified mode would be as below: 基于您的带有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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM