我试图执行像这样的查询
SELECT replace(name, '\0', '') FROM example
使用sqoop中的参数--query
--query "select replace(name, '\\0', '')" from example e
但这种方法正在返回错误
ERROR tool.ImportTool: Imported Failed: No column by the name namefound while importing data; expecting one of [id, REPLACE_name___0_____]
如何解决这个问题?
答案 0 :(得分:1)
首先,您需要正确地附上SQL语句。然后你需要逃避" \"字符用" /"。
请检查下面为我工作:
sqoop import \
--connect "jdbc:mysql://quickstart.cloudera:3306/retail_db" \
--username=retail_dba \
--password=cloudera \
--query "select replace(department_name, '/\0', '*') from departments where 1=1 and \$CONDITIONS" \
--split-by "department_name" \
--target-dir "/km/op_sqoop/dept_names" \
-m 1
eval也有效:
sqoop eval \
--connect "jdbc:mysql://quickstart.cloudera:3306/retail_db" \
--username retail_dba \
--password cloudera \
--query "select department_id, department_name, replace(department_name, '/\0', '*') from departments"
我没有收到你的错误。希望它有所帮助。