【问题标题】:sqoop incremental import updated row and newly created recordsqoop 增量导入更新的行和新创建的记录
【发布时间】:2018-06-24 06:36:58
【问题描述】:

我创建了使用增量追加最后一个值的 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 表中?

你能帮帮我吗?

【问题讨论】:

    标签: mysql hive sqoop sqoop2


    【解决方案1】:

    您可以使用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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-31
      • 2017-05-12
      • 1970-01-01
      相关资源
      最近更新 更多