有没有办法从 sqoop 中的文件执行自由格式查询?

Is there a way to execute free form query from a file in sqoop?

已执行类似的 sqoop 命令,如下所示。下面提到的自由形式查询,我想把它保存在一个文件和 运行 sqoop 命令中,因为我的实时查询非常复杂而且更大。

想知道,有没有办法将查询保存在文件中并执行 sqoop 命令,该命令将引用文件内的自由格式查询并执行? 就像我们为 --password-file 案例所做的那样。提前致谢。

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 "|" 

不方便放在命令中的命令行选项,为了方便可以使用Sqoop--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 User Guide