Created
December 4, 2018 00:56
-
-
Save sofyan-ahmad/f98bd67343faa81cc62fdda3de98eb99 to your computer and use it in GitHub Desktop.
Export Hive to CSV
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
— Step 1: Create CSV table with dummy header column as first row. | |
CREATE TABLE table_csv_export_data | |
ROW FORMAT DELIMITED FIELDS TERMINATED BY ‘,’ | |
LINES TERMINATED BY ‘\n’ | |
STORED as textfile | |
AS | |
select | |
‘id’ as id | |
,’first_name’ as first_name | |
,’last_name’ as last_name | |
,’join_date’ as join_date; | |
— Step 2: Now insert data actual data into table | |
INSERT INTO table_csv_export_data | |
SELECT | |
id | |
,first_name | |
,last_name | |
,join_date | |
FROM | |
table_orc_data; | |
— Step 3 | |
hadoop fs -cat hdfs://servername/user/hive/warehouse/databasename/table_csv_export_data/* > ~/output.csv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment