This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH wlh as ( | |
SELECT DATE_TRUNC('hour', wl.start_time) start_time_trunced_at_hour, HOUR(wl.start_time) start_time_hour, | |
AVG(avg_running) avg_running, AVG(avg_queued_load) avg_queued_load, | |
AVG(avg_queued_provisioning) avg_queued_provisioning, AVG(avg_blocked) avg_blocked | |
FROM snowflake.account_usage.warehouse_load_history wl | |
WHERE DATE_TRUNC('DAY', wl.start_time) = '2020-03-26' | |
AND wl.warehouse_name = 'PUT_YOUR_WAREHOUSE_NAME' | |
GROUP BY start_time_trunced_at_hour, start_time_hour | |
ORDER BY start_time_trunced_at_hour asc | |
), |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE STREAM db_dev.revenue.od_forecast_booking_stream | |
ON TABLE db_dev.revenue.od_forecast_booking | |
APPEND_ONLY = TRUE; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SHOW STREAMS LIKE 'od_forecast_booking_stream' IN db_dev.revenue; | |
DESCRIBE STREAM db_dev.revenue.od_forecast_booking_stream; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT * FROM db_dev.revenue.od_forecast_booking_stream; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE VIEW db_dev.revenue.fleet_assigner_vw | |
AS | |
SELECT | |
airline_code || LPAD(flight_number, 4, 0) || | |
TO_CHAR(depature_date, 'ddMMyyyy') || | |
depature_airport || | |
arrival_airport || | |
flight_cabin || | |
booking_class | |
AS FA_OUT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSTemplateFormatVersion: 2010-09-09 | |
Description: 'Cloudformation Stack to create a outbound bucket for Fleet Assigner Data' | |
Resources: | |
DataBucketDev: | |
Type: 'AWS::S3::Bucket' | |
Properties: | |
AccessControl: Private | |
PublicAccessBlockConfiguration: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE STAGE db_dev.stage.dev_data_outbound_fleetassigner | |
URL = 's3://dev-outbound-fleetassigner' | |
CREDENTIALS = (AWS_KEY_ID = 'YOUR_ACCESS_KEY' AWS_SECRET_KEY = 'YOUR_SECRET_KEY') | |
COMMENT = 'This stage is for Fleet Assigner data unload from Snowflake'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create or replace procedure db_dev.revenue.fa_unload_sp() | |
returns string not null | |
language javascript | |
as | |
$$ | |
// Get Current Date | |
var date_now = new Date() | |
// Get Year as YYYY | |
var full_year = date_now.getFullYear() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE TASK db_dev.revenue.fa_unload_task | |
WAREHOUSE = LOAD_DEV | |
SCHEDULE = 'USING CRON 0 18 * * * UTC' | |
WHEN | |
SYSTEM$STREAM_HAS_DATA('OD_FORECAST_BOOKING_STREAM') | |
AS | |
call db_dev.revenue.fa_unload_sp(); | |
ALTER TASK IF EXISTS db_dev.revenue.fa_unload_task RESUME; |