使用查詢語句來完成全表導入
當想使用查詢語句來完成全表導入時,此時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解析那一套