sqoop 关于 用查询语句全表导入对$condition的理解

使用查询语句来完成全表导入

当想使用查询语句来完成全表导入时,此时where 和$CONDITIONS 缺一不可,可以用以下语句

 import
--connect
jdbc:mysql://hadoop102:3306/gmall
--username
root
--password
123
--target-dir
/test_table
--delete-target-dir
--query
'select id,spu_id,price,sku_name,sku_desc,weight,tm_id,category3_id,create_time from sku_info where 1=1 and $CONDITIONS'
--num-mappers
1
--fields-terminated-by
'\t'
--compress
--compression-codec
lzop

注意:这里用的是sqoop执行脚本的方式导入

查询语句需要用单引号,可能会有人想用双引号加转义符一样可以达到效果,即

"select id,spu_id,price,sku_name,sku_desc,weight,tm_id,category3_id,create_time from sku_info where 1=1 and \$CONDITIONS“

但执行时仍然会报错

 

 具体原因还不知道,可能不是走的shell解析那一套

posted @ 2020-04-04 12:02  可以看看你胖次吗  阅读(1190)  评论(0)    收藏  举报
Live2D