已经执行了类似的sqoop命令,如下所示。下面提到的自由形式查询,我想把它保存在一个文件中并运行sqoop命令,因为我的实时查询非常复杂和庞大。
想知道,有没有一种方法可以将查询保存在文件中并执行sqoop命令,该命令将引用文件中的自由形式查询并执行?就像我们做的——密码文件箱。提前谢谢。
sqoop import --connect "jdbc:mysql://<localhost>:port" --username "admin" --password-file "<passwordfile>" --query "select * from employee" --split-by employee_id --target-dir "<target directory>" --incremental append --check-column employee_id --last-value 0 --fields-terminated-by "|"
1条答案
按热度按时间ctehm74n1#
不方便放入命令的命令行选项可以使用sqoop读取
--options-file
参数,因此可以使用选项文件读取查询。使用options file时,sqoop命令应类似于:sqoop import --connect $connect_string --username $username --password $pwd --options-file /home/user/sqoop_poc/query.txt --target-dir $target_dir --m 1
选项文件中的条目应如下所示:--query select * from TEST_OPTION where ID <= 10 AND $CONDITIONS
有关选项文件的更多详细信息,请参阅sqoop用户指南。