sqoop导入为正确的sql查询提供了错误的结果
问题描述:
我在MySQL
中使用类似下面的查询。我正在得到我想要的结果。sqoop导入为正确的sql查询提供了错误的结果
select TABLE_NAME,count(column_name) as no_of_columns from information_schema.columns where TABLE_SCHEMA = 'testing' and TABLE_NAME NOT REGEXP 'temp|bkup|RemoveMe|test' group by TABLE_NAME
当我在sqoop import语句中使用相同的查询时,结果是不同的。
sqoop
导入语句如下。
sqoop import --connect jdbc:mysql://xxxxxx:3306/information_schema --username xxxxx --password-file /user/xxxxx/passwds/mysql.file --query "select TABLE_NAME,count(column_name) as no_of_columns from information_schema.columns where TABLE_SCHEMA = 'testing' and TABLE_NAME NOT REGEXP 'temp|bkup|RemoveMe|test' group by TABLE_NAME and \$CONDITIONS" -m 1 --target-dir /user/hive/warehouse/xxxx.db/testing_columns --outdir /home/xxxxx/logs/outdir
这是怎么回事,什么我应该按顺序做,从而获得所需结果
答
的$CONDITIONS
令牌必须是WHERE
子句中:
sqoop import --connect jdbc:mysql://xxxxxx:3306/information_schema \
--username xxxxx --password-file /user/xxxxx/passwds/mysql.file \
--query "select TABLE_NAME,count(column_name) as no_of_columns \
from information_schema.columns \
where TABLE_SCHEMA = 'testing' \
and TABLE_NAME NOT REGEXP 'temp|bkup|RemoveMe|test' \
and \$CONDITIONS \
group by TABLE_NAME" \
-m 1 --target-dir /user/hive/warehouse/xxxx.db/testing_columns \
--outdir /home/xxxxx/logs/outdir
,根据Sqoop User Guide也可以考虑:
在当前v中使用自由格式查询的工具Sqoop 的限制仅限于在
WHERE
子句中没有模糊投影 和OR
条件的简单查询。使用复杂查询,如 作为具有子查询或连接导致模糊 投影的查询可能会导致意外的结果。
你能提供完整的控制台输出吗? – Shubhangi