๐Ÿ’ปTech/๐ŸHIVE

[Hive] ์ฟผ๋ฆฌ๊ฒฐ๊ณผ ํŒŒ์ผ ์ถ”์ถœ

_viper_ 2019. 5. 29. 14:00
๋ฐ˜์‘ํ˜•

โ—พ hive -e ๋ช…๋ น์–ด ์‚ฌ์šฉํ•˜์—ฌ ํŒŒ์ผ ์ €์žฅํ•˜๋Š” ๋ฐฉ๋ฒ•

- beeline์œผ๋กœ select ๊ฒฐ๊ณผ๋ฅผ ์ถœ๋ ฅํ•  ๊ฒฝ์šฐ ์ปฌ๋Ÿผ๋ช…๊ณผ ํ…Œ์ด๋ธ” ํ˜•ํƒœ๋„ ๊ฐ™์ด ๋‚˜์˜ค๊ธฐ ๋•Œ๋ฌธ์—,

outputformat=tsv2 ์˜ต์…˜์œผ๋กœ ์ œ๊ฑฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

hive --outputformat=tsv2 -e "select * from db.tb" > /local_path/test.dat

 

โ—พ delimiter ๋ณ€๊ฒฝํ•˜์—ฌ ํŒŒ์ผ ์ €์žฅํ•˜๋Š” ๋ฐฉ๋ฒ• (hive to file)

- ์•„๋ž˜๋‚ด์šฉ์—์„œ ์ €์žฅํ•  ํŒŒ์ผ์˜ ๋””๋ ‰ํ† ๋ฆฌ ์œ„์น˜์™€ ์›ํ•˜๋Š” ๊ตฌ๋ถ„์ž, ์ฟผ๋ฆฌ ์„ค์ • ํ›„ hql ํŒŒ์ผ ์ €์žฅ

INSERT OVERWRITE LOCAL DIRECTORY './directory_name'
ROW FORMAT DELIMITED 
FIELDS TERMINATED BY '\t'
STORED AS TEXTFILE
SELECT * FROM table WHERE id > 100;

 

- ์ €์žฅํ•œ ํŒŒ์ผ ์‹คํ–‰

hive -f test.hql