Sqoop-從hive導出分區表到MySQL


經多次驗證,發現並沒有特殊的方法能夠直接把多個分區一次性讀入,並插入MySQL的方法,以后發現會在此添加。

Sqoop只提供了從MySQL導入到HIVE分區表的相關參數,反向並無特別參數。

從HIVE分區表導入到MySQL,需要依次導入每個分區的數據

sqoop export   \

--connect jdbc:mysql://server74:3306/Server74   \

--username root   \

--password 123456   \

--table dw_pvs_hour \

--hive-partition-key datestr \

--hive-partition-value ‘2017-11-05’ \

--export-dir /user/hive/warehouse/dw_pvs_hour/datestr=2017-11-15/  \

--input-fields-terminated-by '\001'   \

--input-lines-terminated-by '\n'

 

根據官方文檔的說法,---export-dir這個參數是必須的,指定hive表源文件路徑后,sqoop回到路徑下路徑下的文件,文件不是路徑否則報錯。所以分區表需要單獨指定每個分區的目錄,分別導入。

The --export-dir argument and one of --table or --call are required. These specify the table to populate in the database (or the stored procedure to call), and the directory in HDFS that contains the source data.

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM