Моя цель - конвертировать файл в CSV, а также включать заголовки столбцов. Я решил проблему с помощью флага сортировки, чтобы убедиться, что имена столбцов находятся в первой строке. Однако мое идеальное решение - добавить эту строку без дополнительного столбца сортировки. Помощь?
SET mapreduce.job.reduces=1;
create table impala_ad_hoc_db.amazon_sox_KS7246_1file ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' STORED AS textfile AS
select * from
(select
0 as sort_flag,
"week_day" as week_day,
"crawl_time_pst" as crawl_time_pst,
"kenshoo_server"as kenshoo_server,
"account_id"as account_id,
"account_name" as account_name,
"search_term" as search_term,
"brand_name" as brand_name,
"paid_1_organic_0" as paid_1_organic_0,
"serp_position" as serp_position,
"product_id" as product_id,
"title" as title,
"product_price" as product_price,
"average_review" as average_review,
"total_reviews" as total_reviews,
"amazon_choice" as amazon_choice,
"best_seller" as best_seller,
"subscribe_and_save" as subscribe_and_save,
"coupon" as coupon ,
"prime" as prime,
"pantry" as pantry,
"fresh" as fresh
from impala_ad_hoc_db.amazon_sox_january limit 1
union all
select
1 as sort_flag,
week_day,
crawl_time_pst,
kenshoo_server,
account_id,
account_name,
search_term,
brand_name,
paid_1_organic_0,
serp_position,
product_id,
title,
product_price,
average_review,
total_reviews,
amazon_choice,
best_seller,
subscribe_and_save,
coupon,
prime,
pantry,
fresh
from impala_ad_hoc_db.amazon_sox_KS7246 ) as tbl
order by sort_flag,week_day