Skip to content

Instantly share code, notes, and snippets.

@larkz
Last active September 2, 2015 02:38
Show Gist options
  • Save larkz/76fa22acfac74cb0e255 to your computer and use it in GitHub Desktop.
Save larkz/76fa22acfac74cb0e255 to your computer and use it in GitHub Desktop.
Hive Query to union parquet tables, and select attribute
create external table larkin_workspace.afp_flat_2015_08_19
(
created_at string,
title string,
customer_id bigint,
email string,
phone string,
remote_ip string,
subtotal int,
order_discount int,
grandtotal int,
promo_code string,
product_id bigint,
vertical_id int,
merchant_id bigint,
sku string,
name string,
selling_price double,
qty_ordered int,
info string,
order_id bigint,
pincode string,
firstname string,
lastname string,
city string,
state string,
address string,
address2 string,
address_fingerprint string,
gibberish_email_prediction double
)
stored as parquet
location
'/user/larkin/sales_order_flat_table/2015-08-19/';
set vid = 18;
CREATE TABLE union_test2 AS
select * from larkin_workspace.afp_flat_2015_07_01
WHERE vertical_id = '${hiveconf:vid}'
UNION ALL
select * from larkin_workspace.afp_flat_2015_07_02
WHERE vertical_id = '${hiveconf:vid}'
UNION ALL
select * from larkin_workspace.afp_flat_2015_07_03
WHERE vertical_id = '${hiveconf:vid}';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment