Analysis-Services/UsqlScripts/last_available_year/web_sales.usql

105 lines
2.5 KiB
Plaintext

@raw_parsed = EXTRACT child_id int,
ws_sold_date_sk string,
ws_sold_time_sk string,
ws_ship_date_sk string,
ws_item_sk string,
ws_bill_customer_sk string,
ws_bill_cdemo_sk string,
ws_bill_hdemo_sk string,
ws_bill_addr_sk string,
ws_ship_customer_sk string,
ws_ship_cdemo_sk string,
ws_ship_hdemo_sk string,
ws_ship_addr_sk string,
ws_web_page_sk string,
ws_web_site_sk string,
ws_ship_mode_sk string,
ws_warehouse_sk string,
ws_promo_sk string,
ws_order_number string,
ws_quantity string,
ws_wholesale_cost string,
ws_list_price string,
ws_sales_price string,
ws_ext_discount_amt string,
ws_ext_sales_price string,
ws_ext_wholesale_cost string,
ws_ext_list_price string,
ws_ext_tax string,
ws_coupon_amt string,
ws_ext_ship_cost string,
ws_net_paid string,
ws_net_paid_inc_tax string,
ws_net_paid_inc_ship string,
ws_net_paid_inc_ship_tax string,
ws_net_profit string,
empty string
FROM "wasb://web-sales@<blob storage account name>/{*}_{child_id}_100.dat"
USING Extractors.Text(delimiter: '|');
@date_dim = EXTRACT d_date_sk string,
d_date_id string,
d_date string,
d_month_seq string,
d_week_seq string,
d_quarter_seq string,
d_year int,
d_dow string,
d_moy string,
d_dom string,
d_qoy string,
d_fy_year string,
d_fy_quarter_seq string,
d_fy_week_seq string,
d_day_name string,
d_quarter_name string,
d_holiday string,
d_weekend string,
d_following_holiday string,
d_first_dom string,
d_last_dom string,
d_same_day_ly string,
d_same_day_lq string,
d_current_day string,
d_current_week string,
d_current_month string,
d_current_quarter string,
d_current_year string,
empty string
FROM "wasb://date-dim@<blob storage account name>/date_dim_1_100.dat"
USING Extractors.Text(delimiter: '|');
@filtered_results = SELECT ws_sold_date_sk,
ws_sold_time_sk,
ws_ship_date_sk,
ws_item_sk,
ws_bill_customer_sk,
ws_bill_addr_sk,
ws_ship_hdemo_sk,
ws_ship_addr_sk,
ws_web_page_sk,
ws_web_site_sk,
ws_ship_mode_sk,
ws_warehouse_sk,
ws_promo_sk,
ws_order_number,
ws_quantity,
ws_wholesale_cost,
ws_list_price,
ws_sales_price,
ws_ext_discount_amt,
ws_ext_sales_price,
ws_ext_wholesale_cost,
ws_ext_list_price,
ws_ext_ship_cost,
ws_net_paid,
ws_net_profit
FROM @raw_parsed
INNER JOIN (SELECT d_date_sk, d_year FROM @date_dim) AS dd
ON ws_sold_date_sk == dd.d_date_sk
WHERE dd.d_year == 2003;
OUTPUT @filtered_results
TO "/last_available_year/web_sales.csv"
USING Outputters.Csv(outputHeader: true);