Analysis-Services/UsqlScripts/last_available_year/catalog_sales.usql

109 lines
2.6 KiB
Plaintext

@raw_parsed = EXTRACT child_id int,
cs_sold_date_sk string,
cs_sold_time_sk string,
cs_ship_date_sk string,
cs_bill_customer_sk string,
cs_bill_cdemo_sk string,
cs_bill_hdemo_sk string,
cs_bill_addr_sk string,
cs_ship_customer_sk string,
cs_ship_cdemo_sk string,
cs_ship_hdemo_sk string,
cs_ship_addr_sk string,
cs_call_center_sk string,
cs_catalog_page_sk string,
cs_ship_mode_sk string,
cs_warehouse_sk string,
cs_item_sk string,
cs_promo_sk string,
cs_order_number string,
cs_quantity string,
cs_wholesale_cost string,
cs_list_price string,
cs_sales_price string,
cs_ext_discount_amt string,
cs_ext_sales_price string,
cs_ext_wholesale_cost string,
cs_ext_list_price string,
cs_ext_tax string,
cs_coupon_amt string,
cs_ext_ship_cost string,
cs_net_paid string,
cs_net_paid_inc_tax string,
cs_net_paid_inc_ship string,
cs_net_paid_inc_ship_tax string,
cs_net_profit string,
empty string
FROM "wasb://catalog-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 cs_sold_date_sk,
cs_sold_time_sk,
cs_ship_date_sk,
cs_bill_customer_sk,
cs_bill_cdemo_sk,
cs_bill_hdemo_sk,
cs_bill_addr_sk,
cs_ship_customer_sk,
cs_ship_hdemo_sk,
cs_ship_addr_sk,
cs_call_center_sk,
cs_catalog_page_sk,
cs_ship_mode_sk,
cs_warehouse_sk,
cs_item_sk,
cs_promo_sk,
cs_order_number,
cs_quantity,
cs_wholesale_cost,
cs_list_price,
cs_sales_price,
cs_ext_discount_amt,
cs_ext_sales_price,
cs_ext_wholesale_cost,
cs_ext_list_price,
cs_coupon_amt,
cs_ext_ship_cost,
cs_net_paid,
cs_net_profit
FROM @raw_parsed
INNER JOIN (SELECT d_date_sk, d_year FROM @date_dim) AS dd
ON cs_sold_date_sk == dd.d_date_sk
WHERE dd.d_year == 2003;
OUTPUT @filtered_results
TO "/last_available_year/catalog_sales.csv"
USING Outputters.Csv(outputHeader: true);