| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- create database if not exists ${DB};
- use ${DB};
- drop table if exists web_sales;
- create table web_sales
- (
- ws_sold_time_sk bigint,
- ws_ship_date_sk bigint,
- ws_item_sk bigint,
- ws_bill_customer_sk bigint,
- ws_bill_cdemo_sk bigint,
- ws_bill_hdemo_sk bigint,
- ws_bill_addr_sk bigint,
- ws_ship_customer_sk bigint,
- ws_ship_cdemo_sk bigint,
- ws_ship_hdemo_sk bigint,
- ws_ship_addr_sk bigint,
- ws_web_page_sk bigint,
- ws_web_site_sk bigint,
- ws_ship_mode_sk bigint,
- ws_warehouse_sk bigint,
- ws_promo_sk bigint,
- ws_order_number bigint,
- ws_quantity int,
- ws_wholesale_cost double,
- ws_list_price double,
- ws_sales_price double,
- ws_ext_discount_amt double,
- ws_ext_sales_price double,
- ws_ext_wholesale_cost double,
- ws_ext_list_price double,
- ws_ext_tax double,
- ws_coupon_amt double,
- ws_ext_ship_cost double,
- ws_net_paid double,
- ws_net_paid_inc_tax double,
- ws_net_paid_inc_ship double,
- ws_net_paid_inc_ship_tax double,
- ws_net_profit double
- )
- partitioned by (ws_sold_date_sk bigint)
- stored as ${FILE};
- from ${SOURCE}.web_sales ws
- insert overwrite table web_sales partition (ws_sold_date_sk)
- select
- ws.ws_sold_time_sk,
- ws.ws_ship_date_sk,
- ws.ws_item_sk,
- ws.ws_bill_customer_sk,
- ws.ws_bill_cdemo_sk,
- ws.ws_bill_hdemo_sk,
- ws.ws_bill_addr_sk,
- ws.ws_ship_customer_sk,
- ws.ws_ship_cdemo_sk,
- ws.ws_ship_hdemo_sk,
- ws.ws_ship_addr_sk,
- ws.ws_web_page_sk,
- ws.ws_web_site_sk,
- ws.ws_ship_mode_sk,
- ws.ws_warehouse_sk,
- ws.ws_promo_sk,
- ws.ws_order_number,
- ws.ws_quantity,
- ws.ws_wholesale_cost,
- ws.ws_list_price,
- ws.ws_sales_price,
- ws.ws_ext_discount_amt,
- ws.ws_ext_sales_price,
- ws.ws_ext_wholesale_cost,
- ws.ws_ext_list_price,
- ws.ws_ext_tax,
- ws.ws_coupon_amt,
- ws.ws_ext_ship_cost,
- ws.ws_net_paid,
- ws.ws_net_paid_inc_tax,
- ws.ws_net_paid_inc_ship,
- ws.ws_net_paid_inc_ship_tax,
- ws.ws_net_profit,
- ws.ws_sold_date_sk
- where ws.ws_sold_date_sk is not null
- insert overwrite table web_sales partition (ws_sold_date_sk)
- select
- ws.ws_sold_time_sk,
- ws.ws_ship_date_sk,
- ws.ws_item_sk,
- ws.ws_bill_customer_sk,
- ws.ws_bill_cdemo_sk,
- ws.ws_bill_hdemo_sk,
- ws.ws_bill_addr_sk,
- ws.ws_ship_customer_sk,
- ws.ws_ship_cdemo_sk,
- ws.ws_ship_hdemo_sk,
- ws.ws_ship_addr_sk,
- ws.ws_web_page_sk,
- ws.ws_web_site_sk,
- ws.ws_ship_mode_sk,
- ws.ws_warehouse_sk,
- ws.ws_promo_sk,
- ws.ws_order_number,
- ws.ws_quantity,
- ws.ws_wholesale_cost,
- ws.ws_list_price,
- ws.ws_sales_price,
- ws.ws_ext_discount_amt,
- ws.ws_ext_sales_price,
- ws.ws_ext_wholesale_cost,
- ws.ws_ext_list_price,
- ws.ws_ext_tax,
- ws.ws_coupon_amt,
- ws.ws_ext_ship_cost,
- ws.ws_net_paid,
- ws.ws_net_paid_inc_tax,
- ws.ws_net_paid_inc_ship,
- ws.ws_net_paid_inc_ship_tax,
- ws.ws_net_profit,
- ws.ws_sold_date_sk
- where ws.ws_sold_date_sk is null
- sort by ws.ws_sold_date_sk
- ;
|