gpt4 book ai didi

hadoop - Apache sqoop增量保存的作业设置

转载 作者:行者123 更新时间:2023-12-02 19:54:46 27 4
gpt4 key购买 nike

对于使用sqoop保存的作业,官方文档指出将导入较新的记录。没问题。

但是,如果我们要使用保存的作业,并且想使用> =最后保存的值,例如在并发使用情况数据库中,此数据类型可能会发生时间戳记错误?我们可以影响保存的值或比较结果吗,即> =而不是>?

最佳答案

我们还尝试根据上次时间戳使用Sqoop作业使用增量上传。您将面临的挑战是,如果Sqoop服务重新启动,它将失去时间戳或您正在使用的控制变量的踪迹。

我建议改为调整导入查询。例如,如果您想将table_1从RDBMS增量导入到Hive,请在bash shell中使用以下内容:

    # Get the max id from the hive table
maxCount=`hive -S -e "SELECT MAX(id) FROM hivedb.table_1" | head -1 | cut -d ' ' -f1`

# If maxCount is not a number, make it zero.
re='^[0-9]+$'
if ! [[ $maxCount =~ $re ]] ; then
maxCount=0
fi

# Build the SQL query
sql_query="select col1, col2, ..., coln from table_1 (NOLOCK) WHERE id > ${maxCount}"

# Run the Sqoop import
sqoop import --connect 'jdbc:jdbcUrl;UserName=usrname;password=password;database=dbName' --query "$sql_query AND \$CONDITIONS" -m 4 --split-by id --hive-table hivedb.table_1 --hive-import ;

关于hadoop - Apache sqoop增量保存的作业设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58604354/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com