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
--Add in STORE_GET_SHOW2() | |
CREATE OR REPLACE PROCEDURE STORE_GET_SHOW2 (OBJECT STRING) | |
RETURNS STRING | |
LANGUAGE JAVASCRIPT | |
EXECUTE AS CALLER | |
AS | |
$$ | |
try { | |
//First call the show command for the input object | |
var sqlcmd = `SHOW ` + OBJECT + `;` |
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
--Queries to Visualize Run & Timing for Explicit Tasks Tree | |
--Parent Task Visual Heat Map | |
select | |
query_id, | |
database_name || '.' || schema_name || '.' || name as task_name, | |
scheduled_time, | |
datediff('seconds',query_start_time, completed_time) as run_time_in_seconds | |
from table( | |
information_schema.task_history( | |
scheduled_time_range_start=>dateadd('hour',-24,current_timestamp()), |
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
--Query to Visualize All Dependencies for Tasks Dynamic with a Recursive CTE | |
with recursive tasks_layering (layer_id, top_level_task_name, task_name, predecessor_name, dependency_tree) as ( | |
select | |
1 as layer_id, | |
path as top_level_task_name, | |
path as task_name, | |
predecessor as predecessor_name, | |
path as dependency_tree from | |
(select v:name::string as name, v:schedule::string as schedule, | |
v:predecessors::string as predecessor, |
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
--Call Get Show 2 with Tasks | |
call store_get_show2('tasks'); | |
select v::variant from tasks_table; | |
--Query to Visualize Dependencies Explicit | |
select *, sys_connect_by_path (path, '->') as dependency_tree , level | |
from (select v:name::string as name, v:schedule::string as schedule, | |
v:predecessors::string as predecessor, | |
v:database_name::string || '.' || v:schema_name::string || '.' || v:name::string as path | |
from demo.public.tasks_table) |
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
--Full Task History | |
(select * | |
from table( | |
information_schema.task_history( | |
scheduled_time_range_start=>dateadd('hour',-24,current_timestamp()), | |
result_limit => 100, | |
task_name=>'t01_ctas'))) | |
union | |
(select * | |
from table( |
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
--Context | |
use role accountadmin; | |
use database demo; | |
use schema public; | |
use warehouse demo_wh; | |
--Show all Tasks in Account | |
show tasks in account; | |
--Show all Tasks in Demo Database |
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
//Quadrant (County Deaths & Cases) | |
//Q1 | |
IF (SUM([DEATHS_PER_100K]) > WINDOW_AVG(SUM([DEATHS_PER_100K])) AND | |
SUM([CASES_PER_100K]) > WINDOW_AVG(SUM([CASES_PER_100K]))) THEN | |
"Quadrant I - High Deaths and High Infections" | |
//Q2 | |
ELSEIF (SUM([DEATHS_PER_100K]) > WINDOW_AVG(SUM([DEATHS_PER_100K])) AND | |
SUM([CASES_PER_100K]) < WINDOW_AVG(SUM([CASES_PER_100K]))) THEN |
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
--County Data with Populations, Deaths and Cases | |
WITH | |
cases AS ( | |
SELECT JHU.FIPS, JHU.PROVINCE_STATE, JHU.COUNTY, JHU.DATE, GEOSQL.COUNTY_POPULATION, | |
SUM(JHU.CASES) AS COUNTY_CASES, | |
DIV0(COUNTY_CASES,GEOSQL.COUNTY_POPULATION) AS CASES_PER_CAPITA_COUNTY, | |
CASES_PER_CAPITA_COUNTY * 100000 AS CASES_PER_100K | |
FROM STARSCHEMA_COVID19.PUBLIC.JHU_COVID_19 JHU | |
LEFT JOIN ( | |
SELECT LEFT(CBG,5) AS FIPS, SUM(GEO.TOTAL_POPULATION) AS COUNTY_POPULATION |
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
{ | |
"AUTO_CLUSTERING_ON": "NO", | |
"BYTES": 105472, | |
"COLUMNS": [ | |
{ | |
"COLUMN_NAME": "CAL_DATE", | |
"COLUMN_PATH": "ANALYTICS.PUBLIC.CALENDAR_DATE.CAL_DATE", | |
"DATA_TYPE": "DATE", | |
"IS_IDENTITY": "NO", | |
"IS_NULLABLE": "NO", |
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
--2 Tables, Nested, BAM! | |
WITH | |
TABLES_JSON AS ( | |
SELECT TABLE_CATALOG || '.' || TABLE_SCHEMA || '.' || TABLE_NAME AS TABLE_PATH, | |
TABLE_CATALOG, | |
TABLE_SCHEMA, | |
TABLE_NAME, | |
TABLE_OWNER, | |
TABLE_TYPE, | |
CLUSTERING_KEY, |