From 2b96fb194df0a1391e841b0a2a08430047aee97f Mon Sep 17 00:00:00 2001 From: Cody Austin Davis Date: Tue, 4 Feb 2025 07:54:44 -0800 Subject: [PATCH 1/4] DBSQL Cost Per Query PrPr Initial commit adding the following 2 assets: 1. SQL MV defining the cost per query allocation logic 2. JSON Dashboard analyzing cost per query --- .../DBSQL Cost Dashboard (PrPr).lvdash.json | 1 + .../PrPr/DBSQL Cost Per Query MV (PrPr).sql | 436 ++++++++++++++++++ 2 files changed, 437 insertions(+) create mode 100644 dbsql_cost_per_query/PrPr/DBSQL Cost Dashboard (PrPr).lvdash.json create mode 100644 dbsql_cost_per_query/PrPr/DBSQL Cost Per Query MV (PrPr).sql diff --git a/dbsql_cost_per_query/PrPr/DBSQL Cost Dashboard (PrPr).lvdash.json b/dbsql_cost_per_query/PrPr/DBSQL Cost Dashboard (PrPr).lvdash.json new file mode 100644 index 00000000..32702712 --- /dev/null +++ b/dbsql_cost_per_query/PrPr/DBSQL Cost Dashboard (PrPr).lvdash.json @@ -0,0 +1 @@ +{"datasets":[{"name":"8d75d358","displayName":"binary_options","query":"SELECT option\nFROM (VALUES ('Yes'), ('No')) AS options(option)"},{"name":"3e6fd95c","displayName":"statement_level_allocation","query":"WITH warehouse_snapshot AS (\n SELECT warehouse_id,\n warehouse_name,\n workspace_id,\n account_id\n change_time,\n delete_time,\n CASE WHEN delete_time IS NOT NULL THEN 'Deleted' ELSE 'Active' END AS is_deleted\n FROM system.compute.warehouses w\n WHERE\n -- workspace filter\n (array_contains(:workspace_id,w.workspace_id) OR array_contains(:workspace_id,'all'))\n -- warehouse filter\n AND (array_contains(:warehouse_name, CONCAT(w.warehouse_name, ' (id:', w.warehouse_id, ')')) OR array_contains(:warehouse_name,'all'))\n QUALIFY ROW_NUMBER() OVER (PARTITION BY workspace_id, warehouse_id ORDER BY change_time DESC) == 1 -- Get more recent snapshot\n),\n\nroot_table AS (\n SELECT * \n FROM main.default.dbsql_cost_per_query AS qq\n WHERE\n query_attributed_dollars_estimation IS NOT NULL\n -- workspace filter\n AND (array_contains(:workspace_id,qq.workspace_id) OR array_contains(:workspace_id,'all'))\n -- warehouse filter\n AND (array_contains(:warehouse_id,qq.warehouse_id) OR array_contains(:warehouse_id,'all'))\n -- time filter (based on query start time)\n AND query_start_hour BETWEEN CAST(:time_range.min AS TIMESTAMP) AND CAST(:time_range.max AS TIMESTAMP) -- for good pruning\n -- statement_id filter - optional\n AND (array_contains(:statement_id,qq.statement_id) OR array_contains(:statement_id,'all')) -- optional statement id filter\n),\n\ntop_n_filter AS (\n SELECT \n IDENTIFIER(CASE \n WHEN :top_n_dimension = 'Executed By' THEN 'executed_by'\n WHEN :top_n_dimension = 'Source Type' THEN 'query_source_type'\n WHEN :top_n_dimension = 'Object Id' THEN 'query_source_id'\n WHEN :top_n_dimension = 'Statement Id' THEN 'statement_id'\n ELSE 'statement_id'\n END) AS rank_key,\n ROW_NUMBER() OVER (ORDER BY SUM(query_attributed_dollars_estimation) DESC) AS cost_rank\n FROM root_table AS qq\n GROUP BY\n IDENTIFIER(CASE \n WHEN :top_n_dimension = 'Executed By' THEN 'executed_by'\n WHEN :top_n_dimension = 'Source Type' THEN 'query_source_type'\n WHEN :top_n_dimension = 'Object Id' THEN 'query_source_id'\n WHEN :top_n_dimension = 'Statement Id' THEN 'statement_id'\n ELSE 'statement_id'\n END)\n),\n\nmv_model AS (\n\n SELECT qq.*,\n CONCAT(w.warehouse_name, ' (id:', w.warehouse_id, ')') AS warehouse_name ,\n w.is_deleted AS is_warehouse_deleted,\n query_attributed_dollars_estimation * (1 - CAST(:dbsql_discount AS FLOAT)) AS query_attributed_dollars_with_discount,\n --ROW_NUMBER() OVER (PARTITION BY CASE WHEN :ORDER BY QueryAllocationDollars DESC) AS CostRank\n tn.cost_rank\n FROM root_table AS qq\n INNER JOIN warehouse_snapshot w ON qq.workspace_id = w.workspace_id AND qq.warehouse_id = w.warehouse_id\n LEFT JOIN top_n_filter AS tn ON IDENTIFIER(CASE \n WHEN :top_n_dimension = 'Executed By' THEN 'qq.executed_by'\n WHEN :top_n_dimension = 'Source Type' THEN 'qq.query_source_type'\n WHEN :top_n_dimension = 'Object Id' THEN 'qq.query_source_id'\n WHEN :top_n_dimension = 'Statement Id' THEN 'qq.statement_id'\n ELSE 'statement_id'\n END) = tn.rank_key\n)\n\nSELECT\n mv.*,\n CASE WHEN :group_key = 'Warehouse Id' THEN mv.warehouse_id\n WHEN :group_key = 'Warehouse Name' THEN mv.warehouse_name\n WHEN :group_key = 'User' THEN mv.executed_by\n WHEN :group_key = 'Source Type' THEN mv.query_source_type\n WHEN :group_key = 'Obect Id' THEN mv.query_source_id\n WHEN :group_key = 'Client' THEN mv.client_application\n WHEN :group_key = 'Workspace Id' THEN mv.workspace_id\n END AS group_key,\n CASE WHEN :date_agg_level = 'HOUR' THEN \n date_trunc(:date_agg_level, mv.start_time)::timestamp::string\n ELSE date_trunc(:date_agg_level, mv.start_time)::date::string\n END AS time_agg_key,\n -- Data formatting for visuals\n MAX(query_attributed_dollars_with_discount) OVER() AS fully_loaded_max_usage,\n MIN(query_attributed_dollars_with_discount) OVER() AS fully_loaded_min_usage,\n COALESCE(CONCAT(\n '
',\n '
',\n '$',\n FORMAT_NUMBER(query_attributed_dollars_with_discount, 2), \n '
'\n ), '--') AS allocated_dollars_usage_bar_html,\n-- Data formatting for visuals\n MAX(query_attributed_dbus_estimation) OVER() AS fully_loaded_max_usage_dbus,\n MIN(query_attributed_dbus_estimation) OVER() AS fully_loaded_min_usage_dbus,\n COALESCE(CONCAT(\n '
',\n '
',\n '$',\n FORMAT_NUMBER(query_attributed_dbus_estimation, 2), \n '
'\n ), '--') AS allocated_dbus_usage_bar_html\nFROM mv_model AS mv\nWHERE\n(lower(:top_n)::string = 'all' OR cost_rank <= :top_n::int) -- There can be ties, so we will also do a limit\nORDER BY cost_rank, query_attributed_dollars_with_discount DESC\n\n\n","parameters":[{"displayName":"statement_id","keyword":"statement_id","dataType":"STRING","complexType":"MULTI","defaultSelection":{"values":{"dataType":"STRING","values":[{"value":"all"}]}}},{"displayName":"workspace_id","keyword":"workspace_id","dataType":"STRING","complexType":"MULTI","defaultSelection":{"values":{"dataType":"STRING","values":[{"value":"all"}]}}},{"displayName":"warehouse_id","keyword":"warehouse_id","dataType":"STRING","complexType":"MULTI","defaultSelection":{"values":{"dataType":"STRING","values":[{"value":"all"}]}}},{"displayName":"warehouse_name","keyword":"warehouse_name","dataType":"STRING","complexType":"MULTI","defaultSelection":{"values":{"dataType":"STRING","values":[{"value":"all"}]}}},{"displayName":"top_n_dimension","keyword":"top_n_dimension","dataType":"STRING","defaultSelection":{"values":{"dataType":"STRING","values":[{"value":"Executed By"}]}}},{"displayName":"dbsql_discount","keyword":"dbsql_discount","dataType":"STRING","defaultSelection":{"values":{"dataType":"STRING","values":[{"value":"0.0"}]}}},{"displayName":"group_key","keyword":"group_key","dataType":"STRING","defaultSelection":{"values":{"dataType":"STRING","values":[{"value":"User"}]}}},{"displayName":"date_agg_level","keyword":"date_agg_level","dataType":"STRING","defaultSelection":{"values":{"dataType":"STRING","values":[{"value":"DAY"}]}}},{"displayName":"top_n","keyword":"top_n","dataType":"STRING","defaultSelection":{"values":{"dataType":"STRING","values":[{"value":"all"}]}}},{"displayName":"time_range","keyword":"time_range","dataType":"DATETIME","complexType":"RANGE","defaultSelection":{"range":{"dataType":"DATETIME","min":{"value":"now-7d/d"},"max":{"value":"now-1d/d"}}}}]},{"name":"b6c55fed","displayName":"workspace_with_all","query":" WITH billing AS (\n SELECT workspace_id, usage_metadata.warehouse_id AS warehouse_id\n FROM system.billing.usage u\n WHERE usage_start_time BETWEEN date_trunc('hour', :start_time) AND :end_time\n AND usage_metadata.warehouse_id IS NOT NULL\n GROUP BY 1,2\n )\n -- Get warehouse names (most recent change record) for warehouses with usage in selected period\n SELECT w.workspace_id, w.warehouse_id, CONCAT(w.warehouse_name, ' (id:', w.warehouse_id, ')') AS warehouse_name\n FROM billing AS b\n JOIN system.compute.warehouses w ON b.workspace_id = w.workspace_id AND w.warehouse_id = b.warehouse_id\n QUALIFY ROW_NUMBER() OVER(PARTITION BY w.workspace_id, w.warehouse_id ORDER BY w.change_time DESC) == 1","parameters":[{"displayName":"start_time","keyword":"start_time","dataType":"DATETIME","defaultSelection":{"values":{"dataType":"DATETIME","values":[{"value":"2024-12-04T15:45:12.000"}]}}},{"displayName":"end_time","keyword":"end_time","dataType":"DATETIME","defaultSelection":{"values":{"dataType":"DATETIME","values":[{"value":"now-1m/m"}]}}}]},{"name":"773aca07","displayName":"select_time_agg","query":"SELECT explode(array('YEAR', 'QUARTER', 'MONTH', 'WEEK', 'DAY', 'HOUR')) AS time_agg_toggle"},{"name":"706e050f","displayName":"select_dynamic_group_key_toggle","query":"SELECT explode(array('User', 'Warehouse Id', 'Warehouse Name', 'Object Id', 'Source Type', 'Workspace Id')) AS group_key\n"},{"name":"9dda0ef1","displayName":"select_top_n_dim","query":"SELECT explode(array('Executed By', 'Source Type', 'Object Id', 'Statement Id')) AS object_top_n_toggle"}],"pages":[{"name":"3972306b","displayName":"Query Cost Overview","layout":[{"widget":{"name":"1274573c","queries":[{"name":"parameter_dashboards/01efde5dd4c51fc89e1caf2a86c344d7/datasets/01efde5dd4c615cd98f5bc2e8fab18b5_time_range","query":{"datasetName":"3e6fd95c","parameters":[{"name":"time_range","keyword":"time_range"}],"disaggregated":false}}],"spec":{"version":2,"widgetType":"filter-date-range-picker","encodings":{"fields":[{"parameterName":"time_range","queryName":"parameter_dashboards/01efde5dd4c51fc89e1caf2a86c344d7/datasets/01efde5dd4c615cd98f5bc2e8fab18b5_time_range"}]},"frame":{"showTitle":true,"title":"Time Range"}}},"position":{"x":0,"y":6,"width":2,"height":2}},{"widget":{"name":"029aeeb6","queries":[{"name":"dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef015641455b4942decd4151ed3_workspace_id","query":{"datasetName":"b6c55fed","fields":[{"name":"workspace_id","expression":"`workspace_id`"},{"name":"workspace_id_associativity","expression":"COUNT_IF(`associative_filter_predicate_group`)"}],"disaggregated":false}},{"name":"parameter_dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef01564141b910a89950bda083e_workspace_id","query":{"datasetName":"3e6fd95c","parameters":[{"name":"workspace_id","keyword":"workspace_id"}],"disaggregated":false}}],"spec":{"version":2,"widgetType":"filter-multi-select","encodings":{"fields":[{"parameterName":"workspace_id","queryName":"parameter_dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef01564141b910a89950bda083e_workspace_id"},{"fieldName":"workspace_id","displayName":"workspace_id","queryName":"dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef015641455b4942decd4151ed3_workspace_id"}]},"frame":{"showTitle":true,"title":"Workspace Id"}}},"position":{"x":2,"y":6,"width":1,"height":2}},{"widget":{"name":"8ad3de2b","queries":[{"name":"main_query","query":{"datasetName":"3e6fd95c","fields":[{"name":"sum(query_attributed_dollars_with_discount)","expression":"SUM(`query_attributed_dollars_with_discount`)"},{"name":"sum(query_attributed_dbus_estimation)","expression":"SUM(`query_attributed_dbus_estimation`)"},{"name":"countdistinct(statement_id)","expression":"COUNT(DISTINCT `statement_id`)"},{"name":"executed_by","expression":"`executed_by`"}],"disaggregated":false}}],"spec":{"version":3,"widgetType":"bar","encodings":{"x":{"fieldName":"sum(query_attributed_dollars_with_discount)","scale":{"type":"quantitative","reverse":false},"format":{"type":"number-currency","currencyCode":"USD","abbreviation":"none","decimalPlaces":{"type":"max","places":2}},"displayName":"Attributed Usage ($)"},"y":{"fieldName":"executed_by","scale":{"type":"categorical","sort":{"by":"x-reversed"}},"axis":{"title":"User"},"displayName":"Group Key"},"color":{"fieldName":"sum(query_attributed_dollars_with_discount)","scale":{"type":"quantitative","colorRamp":{"mode":"scheme","scheme":"greenblue"}},"legend":{"hide":true},"displayName":"Attributed Usage ($)"},"label":{"show":true},"extra":[{"fieldName":"sum(query_attributed_dbus_estimation)","format":{"type":"number-plain","abbreviation":"none","decimalPlaces":{"type":"max","places":2}},"displayName":"Attributed Usage (DBUs)"},{"fieldName":"countdistinct(statement_id)","displayName":"Query Count"}]},"frame":{"showTitle":true,"title":"Cost By User"},"mark":{"colors":["#00A972","#FFAB00","#00A972","#FF3621","#8BCAE7","#AB4057","#99DDB4","#FCA4A1","#919191","#BF7080"]}}},"position":{"x":0,"y":13,"width":2,"height":8}},{"widget":{"name":"b034a298","queries":[{"name":"dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef01564141b910a89950bda083e_executed_by","query":{"datasetName":"3e6fd95c","fields":[{"name":"executed_by","expression":"`executed_by`"},{"name":"executed_by_associativity","expression":"COUNT_IF(`associative_filter_predicate_group`)"}],"disaggregated":false}}],"spec":{"version":2,"widgetType":"filter-multi-select","encodings":{"fields":[{"fieldName":"executed_by","displayName":"executed_by","queryName":"dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef01564141b910a89950bda083e_executed_by"}]},"frame":{"showTitle":true,"title":"User","showDescription":true,"description":"User or service principal running the statement"}}},"position":{"x":0,"y":8,"width":2,"height":2}},{"widget":{"name":"09a2a1f3","queries":[{"name":"dashboards/01efdcd2775e1c1a8a1866858634977b/datasets/01efdcd2775e1ed4903a87d29a6a6697_query_source_type","query":{"datasetName":"3e6fd95c","fields":[{"name":"query_source_type","expression":"`query_source_type`"},{"name":"query_source_type_associativity","expression":"COUNT_IF(`associative_filter_predicate_group`)"}],"disaggregated":false}}],"spec":{"version":2,"widgetType":"filter-multi-select","encodings":{"fields":[{"fieldName":"query_source_type","displayName":"query_source_type","queryName":"dashboards/01efdcd2775e1c1a8a1866858634977b/datasets/01efdcd2775e1ed4903a87d29a6a6697_query_source_type"}]},"frame":{"showTitle":true,"title":"Query Source Type","showDescription":true,"description":"Type of Object (i.e dashboard, SQL Query, JOB, notebook)"}}},"position":{"x":2,"y":8,"width":1,"height":2}},{"widget":{"name":"f80f81da","queries":[{"name":"dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef01564141b910a89950bda083e_query_source_id","query":{"datasetName":"3e6fd95c","fields":[{"name":"query_source_id","expression":"`query_source_id`"},{"name":"query_source_id_associativity","expression":"COUNT_IF(`associative_filter_predicate_group`)"}],"disaggregated":false}}],"spec":{"version":2,"widgetType":"filter-multi-select","encodings":{"fields":[{"fieldName":"query_source_id","displayName":"query_source_id","queryName":"dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef01564141b910a89950bda083e_query_source_id"}]},"frame":{"showTitle":true,"title":"Query Source Id","showDescription":true,"description":"Id of object such as a dashboard, SQL query, job, etc."}}},"position":{"x":3,"y":8,"width":2,"height":2}},{"widget":{"name":"8925bd62","textbox_spec":"## Charts\n----"},"position":{"x":0,"y":10,"width":6,"height":1}},{"widget":{"name":"af6d1285","textbox_spec":"## Statement Level Detail\n----"},"position":{"x":0,"y":29,"width":6,"height":1}},{"widget":{"name":"f1e3bb79","queries":[{"name":"main_query","query":{"datasetName":"3e6fd95c","fields":[{"name":"statement_id","expression":"`statement_id`"},{"name":"statement_text","expression":"`statement_text`"},{"name":"allocated_dollars_usage_bar_html","expression":"`allocated_dollars_usage_bar_html`"},{"name":"executed_by","expression":"`executed_by`"},{"name":"warehouse_name","expression":"`warehouse_name`"},{"name":"duration_seconds","expression":"`duration_seconds`"},{"name":"query_work_duration_seconds","expression":"`query_work_duration_seconds`"},{"name":"start_time","expression":"`start_time`"},{"name":"end_time","expression":"`end_time`"},{"name":"query_work_start_time","expression":"`query_work_start_time`"},{"name":"query_work_end_time","expression":"`query_work_end_time`"},{"name":"query_source_type","expression":"`query_source_type`"},{"name":"query_source_id","expression":"`query_source_id`"},{"name":"client_application","expression":"`client_application`"},{"name":"workspace_id","expression":"`workspace_id`"},{"name":"query_attributed_dollars_with_discount","expression":"`query_attributed_dollars_with_discount`"},{"name":"query_attributed_dbus_estimation","expression":"`query_attributed_dbus_estimation`"},{"name":"query_attributed_dollars_estimation","expression":"`query_attributed_dollars_estimation`"},{"name":"statement_hour_bucket_costs","expression":"`statement_hour_bucket_costs`"},{"name":"query_profile_url","expression":"`query_profile_url`"},{"name":"url_helper","expression":"`url_helper`"}],"disaggregated":true}}],"spec":{"version":1,"widgetType":"table","encodings":{"columns":[{"fieldName":"statement_id","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ query_profile_url }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"string","displayAs":"link","visible":true,"order":0,"title":"Statement Id (link to query profile)","allowSearch":true,"alignContent":"left","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"cellFormat":{"default":{"foregroundColor":"#077A9D"},"rules":[]},"displayName":"statement_id"},{"fieldName":"statement_text","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"string","displayAs":"string","visible":true,"order":1,"title":"Query Text","allowSearch":false,"alignContent":"left","allowHTML":true,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"defaultColumnWidth":300,"description":"Raw text of the statement query that was executed","displayName":"statement_text"},{"fieldName":"allocated_dollars_usage_bar_html","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"string","displayAs":"string","visible":true,"order":2,"title":"Attributed Usage ($)","allowSearch":false,"alignContent":"left","allowHTML":true,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"defaultColumnWidth":200,"description":"Allocated dollars for attributed query (this is an estimate based on query work)","displayName":"allocated_dollars_usage_bar_html"},{"fieldName":"executed_by","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"string","displayAs":"string","visible":true,"order":4,"title":"Executed by","allowSearch":false,"alignContent":"left","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"displayName":"executed_by"},{"fieldName":"warehouse_name","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"string","displayAs":"string","visible":true,"order":6,"title":"Warehouse","allowSearch":true,"alignContent":"left","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"description":"Current name of the warehouse it was run on (warehouse ids are permanent but names are not)","displayName":"warehouse_name"},{"fieldName":"duration_seconds","numberFormat":"0.00","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"float","displayAs":"number","visible":true,"order":7,"title":"Query Duration (s)","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"description":"Runtime of the query in seconds","cellFormat":{"default":{"foregroundColor":"#077A9D"},"rules":[]},"displayName":"duration_seconds"},{"fieldName":"query_work_duration_seconds","numberFormat":"0.00","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"float","displayAs":"number","visible":true,"order":8,"title":"Work Duration (s)","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"description":"Amount of seconds query spent doing work (execution + result fetch)","displayName":"query_work_duration_seconds"},{"fieldName":"start_time","dateTimeFormat":"YYYY-MM-DD HH:mm:ss.SSS","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"datetime","displayAs":"datetime","visible":true,"order":10,"title":"Start Time","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"displayName":"start_time"},{"fieldName":"end_time","dateTimeFormat":"YYYY-MM-DD HH:mm:ss.SSS","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"datetime","displayAs":"datetime","visible":true,"order":11,"title":"End Time","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"displayName":"end_time"},{"fieldName":"query_work_start_time","dateTimeFormat":"YYYY-MM-DD HH:mm:ss.SSS","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"datetime","displayAs":"datetime","visible":true,"order":12,"title":"Work Start Time","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"description":"Start time query began doing work (executing) - can be greater than start_time if it waits in the queue","displayName":"query_work_start_time"},{"fieldName":"query_work_end_time","dateTimeFormat":"YYYY-MM-DD HH:mm:ss.SSS","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"datetime","displayAs":"datetime","visible":true,"order":13,"title":"Work End Time","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"description":"Time when query finishes work. This can be greater than end_time because it includes time spent returning results. ","displayName":"query_work_end_time"},{"fieldName":"query_source_type","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"string","displayAs":"string","visible":true,"order":14,"title":"Query Source Type","allowSearch":false,"alignContent":"left","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"description":"Databricks internal asset source type (i.e. dashboard, notebook, job, etc.)","displayName":"query_source_type"},{"fieldName":"query_source_id","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ url_helper }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"string","displayAs":"link","visible":true,"order":15,"title":"Query Source Id","allowSearch":false,"alignContent":"left","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"description":"Id of the asset type (i.e. if source type = 'JOB' then this will be the job id that ran the query)","displayName":"query_source_id"},{"fieldName":"client_application","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"string","displayAs":"string","visible":true,"order":16,"title":"Client App","allowSearch":false,"alignContent":"left","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"description":"External registered client name (like DBSQL Dashboards, Power BI, Fivetran, etc.)","displayName":"client_application"},{"fieldName":"workspace_id","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"string","displayAs":"string","visible":true,"order":17,"title":"Workspace Id","allowSearch":false,"alignContent":"left","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"displayName":"workspace_id"},{"fieldName":"query_attributed_dollars_with_discount","numberFormat":"$ 0.00","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"float","displayAs":"number","visible":true,"order":18,"title":"Attributed Usage ($) - Discount","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"description":"Estimated query attributed costs with discount param included","cellFormat":{"default":{"foregroundColor":"#00A972"},"rules":[]},"displayName":"query_attributed_dollars_with_discount"},{"fieldName":"query_attributed_dbus_estimation","numberFormat":"0.00","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"float","displayAs":"number","visible":true,"order":19,"title":"Attributed Usage (DBUs)","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"description":"Estimated query attributed dbu usage","cellFormat":{"default":{"foregroundColor":"#077A9D"},"rules":[]},"displayName":"query_attributed_dbus_estimation"},{"fieldName":"query_attributed_dollars_estimation","numberFormat":"0.00","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"float","displayAs":"number","visible":true,"order":20,"title":"Attributed Usage ($) - List","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"description":"Estimated query attributed cost at list rate","displayName":"query_attributed_dollars_estimation"},{"fieldName":"statement_hour_bucket_costs","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"complex","displayAs":"json","visible":true,"order":31,"title":"Query Cost Hourly Breakdown","allowSearch":false,"alignContent":"left","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"description":"If queries span multiple hours, the costs are allocated on an hourly basis, so a total query costs can span multiple hours. This shows what % of the cost is allocated to which hour for that warehouse","displayName":"statement_hour_bucket_costs"}]},"invisibleColumns":[{"booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"allocated_dbus_usage_bar_html","type":"string","displayAs":"string","order":3,"title":"Allocated DBUs","allowSearch":false,"alignContent":"left","allowHTML":true,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"defaultColumnWidth":200},{"booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"warehouse_id","type":"string","displayAs":"string","order":5,"title":"Warehouse Id","allowSearch":false,"alignContent":"left","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false},{"numberFormat":"0.00","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"query_work_task_time_seconds","type":"float","displayAs":"number","order":9,"title":"Query Task Time (s)","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"description":"The total executor task time used by the query","cellFormat":{"default":{"foregroundColor":"#077A9D"},"rules":[]}},{"booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"url_helper","type":"string","displayAs":"string","order":21,"title":"url_helper","allowSearch":false,"alignContent":"left","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false},{"booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"query_profile_url","type":"string","displayAs":"string","order":22,"title":"query_profile_url","allowSearch":false,"alignContent":"left","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false},{"dateTimeFormat":"YYYY-MM-DD HH:mm:ss.SSS","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"most_recent_billing_hour","type":"datetime","displayAs":"datetime","order":23,"title":"most_recent_billing_hour","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false},{"booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"billing_record_check","type":"string","displayAs":"string","order":24,"title":"billing_record_check","allowSearch":false,"alignContent":"left","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false},{"numberFormat":"0.00","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"fully_loaded_max_usage","type":"float","displayAs":"number","order":25,"title":"fully_loaded_max_usage","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false},{"numberFormat":"0.00","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"fully_loaded_min_usage","type":"float","displayAs":"number","order":26,"title":"fully_loaded_min_usage","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false},{"numberFormat":"0.00","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"fully_loaded_max_usage_dbus","type":"float","displayAs":"number","order":27,"title":"fully_loaded_max_usage_dbus","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false},{"numberFormat":"0.00","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"fully_loaded_min_usage_dbus","type":"float","displayAs":"number","order":28,"title":"fully_loaded_min_usage_dbus","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false},{"booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"group_key","type":"string","displayAs":"string","order":29,"title":"group_key","allowSearch":false,"alignContent":"left","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false},{"dateTimeFormat":"YYYY-MM-DD HH:mm:ss.SSS","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"time_agg_key","type":"string","displayAs":"datetime","order":30,"title":"time_agg_key","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false},{"dateTimeFormat":"YYYY-MM-DD HH:mm:ss.SSS","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"query_start_hour","type":"datetime","displayAs":"datetime","order":32,"title":"query_start_hour","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false},{"booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"is_warehouse_deleted","type":"string","displayAs":"string","order":33,"title":"is_warehouse_deleted","allowSearch":false,"alignContent":"left","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false},{"numberFormat":"0","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"cost_rank","type":"integer","displayAs":"number","order":34,"title":"cost_rank","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false}],"allowHTMLByDefault":false,"itemsPerPage":25,"paginationSize":"default","condensed":true,"withRowNumber":true,"frame":{"showTitle":true,"title":"Query Statement Detail"}}},"position":{"x":0,"y":30,"width":6,"height":16}},{"widget":{"name":"3fd47cc4","queries":[{"name":"main_query","query":{"datasetName":"3e6fd95c","fields":[{"name":"countdistinct(statement_id)","expression":"COUNT(DISTINCT `statement_id`)"}],"disaggregated":false}}],"spec":{"version":2,"widgetType":"counter","encodings":{"value":{"fieldName":"countdistinct(statement_id)","format":{"type":"number-plain","abbreviation":"none","decimalPlaces":{"type":"max","places":2}},"displayName":"Count of Unique statement_id"}},"frame":{"showTitle":true,"title":"Query Statement Count"}}},"position":{"x":0,"y":11,"width":2,"height":2}},{"widget":{"name":"37fa2ea4","queries":[{"name":"parameter_dashboards/01efde5dd4c51fc89e1caf2a86c344d7/datasets/01efde5dd4c615cd98f5bc2e8fab18b5_top_n","query":{"datasetName":"3e6fd95c","parameters":[{"name":"top_n","keyword":"top_n"}],"disaggregated":false}}],"spec":{"version":2,"widgetType":"filter-single-select","encodings":{"fields":[{"parameterName":"top_n","queryName":"parameter_dashboards/01efde5dd4c51fc89e1caf2a86c344d7/datasets/01efde5dd4c615cd98f5bc2e8fab18b5_top_n"}]},"selection":{"defaultSelection":{"values":{"dataType":"STRING","values":[{"value":"all"}]}}},"frame":{"showTitle":true,"title":"Top N Number","showDescription":true,"description":"Optional filter ('all' or #)"}}},"position":{"x":5,"y":6,"width":1,"height":2}},{"widget":{"name":"5b94dd8d","queries":[{"name":"dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef015641455b4942decd4151ed3_warehouse_name","query":{"datasetName":"b6c55fed","fields":[{"name":"warehouse_name","expression":"`warehouse_name`"},{"name":"warehouse_name_associativity","expression":"COUNT_IF(`associative_filter_predicate_group`)"}],"disaggregated":false}},{"name":"parameter_dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef01564141b910a89950bda083e_warehouse_name","query":{"datasetName":"3e6fd95c","parameters":[{"name":"warehouse_name","keyword":"warehouse_name"}],"disaggregated":false}}],"spec":{"version":2,"widgetType":"filter-multi-select","encodings":{"fields":[{"fieldName":"warehouse_name","displayName":"warehouse_name","queryName":"dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef015641455b4942decd4151ed3_warehouse_name"},{"parameterName":"warehouse_name","queryName":"parameter_dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef01564141b910a89950bda083e_warehouse_name"}]},"frame":{"showTitle":true,"title":"Warehouse Name"}}},"position":{"x":3,"y":6,"width":1,"height":2}},{"widget":{"name":"e6de4fe7","queries":[{"name":"main_query","query":{"datasetName":"3e6fd95c","fields":[{"name":"sum(query_attributed_dollars_with_discount)","expression":"SUM(`query_attributed_dollars_with_discount`)"},{"name":"countdistinct(statement_id)","expression":"COUNT(DISTINCT `statement_id`)"},{"name":"sum(query_attributed_dbus_estimation)","expression":"SUM(`query_attributed_dbus_estimation`)"},{"name":"query_source_type","expression":"`query_source_type`"}],"disaggregated":false}}],"spec":{"version":3,"widgetType":"bar","encodings":{"x":{"fieldName":"sum(query_attributed_dollars_with_discount)","scale":{"type":"quantitative","reverse":false},"format":{"type":"number-currency","currencyCode":"USD","abbreviation":"compact","decimalPlaces":{"type":"max","places":2}},"displayName":"Attributed Usage ($)"},"y":{"fieldName":"query_source_type","scale":{"type":"categorical","sort":{"by":"x-reversed"}},"displayName":"Source Type"},"color":{"fieldName":"sum(query_attributed_dollars_with_discount)","scale":{"type":"quantitative","colorRamp":{"mode":"scheme","scheme":"greenblue"}},"legend":{"hide":true},"displayName":"Attributed Usage ($)"},"label":{"show":true},"extra":[{"fieldName":"countdistinct(statement_id)","displayName":"Query Count"},{"fieldName":"sum(query_attributed_dbus_estimation)","format":{"type":"number-plain","abbreviation":"compact","decimalPlaces":{"type":"max","places":2}},"displayName":"Attributed Usage (DBUs)"}]},"frame":{"showTitle":true,"title":"Cost By Source Type"},"mark":{"colors":["#00A972","#FFAB00","#00A972","#FF3621","#8BCAE7","#AB4057","#99DDB4","#FCA4A1","#919191","#BF7080"]}}},"position":{"x":2,"y":13,"width":2,"height":8}},{"widget":{"name":"e43bcbfd","queries":[{"name":"main_query","query":{"datasetName":"3e6fd95c","fields":[{"name":"sum(query_attributed_dollars_with_discount)","expression":"SUM(`query_attributed_dollars_with_discount`)"},{"name":"sum(query_attributed_dbus_estimation)","expression":"SUM(`query_attributed_dbus_estimation`)"},{"name":"count(statement_id)","expression":"COUNT(`statement_id`)"},{"name":"query_source_id","expression":"`query_source_id`"}],"disaggregated":false}}],"spec":{"version":3,"widgetType":"bar","encodings":{"x":{"fieldName":"sum(query_attributed_dollars_with_discount)","scale":{"type":"quantitative","reverse":false},"format":{"type":"number-currency","currencyCode":"USD","abbreviation":"none","decimalPlaces":{"type":"max","places":2}},"displayName":"Attributed Usage ($)"},"y":{"fieldName":"query_source_id","scale":{"type":"categorical","sort":{"by":"x-reversed"}},"axis":{"title":"Object Id"},"displayName":"Source Object Id"},"color":{"fieldName":"sum(query_attributed_dollars_with_discount)","scale":{"type":"quantitative","colorRamp":{"mode":"scheme","scheme":"greenblue"}},"legend":{"hide":true},"displayName":"Source Object Id"},"label":{"show":true},"extra":[{"fieldName":"sum(query_attributed_dbus_estimation)","format":{"type":"number-plain","abbreviation":"none","decimalPlaces":{"type":"max","places":2}},"displayName":"Attributed Usage (DBUs)"},{"fieldName":"count(statement_id)","displayName":"Query Count"}]},"frame":{"showTitle":true,"title":"Cost By Source Object Id"},"mark":{"colors":["#00A972","#FFAB00","#00A972","#FF3621","#8BCAE7","#AB4057","#99DDB4","#FCA4A1","#919191","#BF7080"]}}},"position":{"x":4,"y":13,"width":2,"height":8}},{"widget":{"name":"03009168","queries":[{"name":"dashboards/01efdcd2775e1c1a8a1866858634977b/datasets/01efdcd2775e1f47ba886d022f892e0b_object_top_n_toggle","query":{"datasetName":"9dda0ef1","fields":[{"name":"object_top_n_toggle","expression":"`object_top_n_toggle`"},{"name":"object_top_n_toggle_associativity","expression":"COUNT_IF(`associative_filter_predicate_group`)"}],"disaggregated":false}},{"name":"parameter_dashboards/01efdcd2775e1c1a8a1866858634977b/datasets/01efdcd2775e1ed4903a87d29a6a6697_top_n_dimension","query":{"datasetName":"3e6fd95c","parameters":[{"name":"top_n_dimension","keyword":"top_n_dimension"}],"disaggregated":false}}],"spec":{"version":2,"widgetType":"filter-single-select","encodings":{"fields":[{"parameterName":"top_n_dimension","queryName":"parameter_dashboards/01efdcd2775e1c1a8a1866858634977b/datasets/01efdcd2775e1ed4903a87d29a6a6697_top_n_dimension"},{"fieldName":"object_top_n_toggle","displayName":"object_top_n_toggle","queryName":"dashboards/01efdcd2775e1c1a8a1866858634977b/datasets/01efdcd2775e1f47ba886d022f892e0b_object_top_n_toggle"}]},"frame":{"showTitle":true,"title":"Top N Dimension","showDescription":true,"description":"i.e. (top 10 users, queries, objects)"}}},"position":{"x":4,"y":6,"width":1,"height":2}},{"widget":{"name":"8d88ad2d","queries":[{"name":"main_query","query":{"datasetName":"3e6fd95c","fields":[{"name":"countdistinct(executed_by)","expression":"COUNT(DISTINCT `executed_by`)"}],"disaggregated":false}}],"spec":{"version":2,"widgetType":"counter","encodings":{"value":{"fieldName":"countdistinct(executed_by)","format":{"type":"number-plain","abbreviation":"none","decimalPlaces":{"type":"max","places":2}},"displayName":"Count of Unique executed_by"}},"frame":{"showTitle":true,"title":"User Count\n"}}},"position":{"x":2,"y":11,"width":2,"height":2}},{"widget":{"name":"f11a0fd2","queries":[{"name":"main_query","query":{"datasetName":"3e6fd95c","fields":[{"name":"countdistinct(query_source_id)","expression":"COUNT(DISTINCT `query_source_id`)"}],"disaggregated":false}}],"spec":{"version":2,"widgetType":"counter","encodings":{"value":{"fieldName":"countdistinct(query_source_id)","format":{"type":"number-plain","abbreviation":"none","decimalPlaces":{"type":"max","places":2}},"displayName":"Count of Unique query_source_id"}},"frame":{"showTitle":true,"title":"Object Id Count"}}},"position":{"x":4,"y":11,"width":2,"height":2}},{"widget":{"name":"b62fe468","queries":[{"name":"main_query","query":{"datasetName":"3e6fd95c","fields":[{"name":"sum(query_attributed_dbus_estimation)","expression":"SUM(`query_attributed_dbus_estimation`)"},{"name":"count(statement_id)","expression":"COUNT(`statement_id`)"},{"name":"time_agg_key","expression":"`time_agg_key`"},{"name":"sum(query_attributed_dollars_with_discount)","expression":"SUM(`query_attributed_dollars_with_discount`)"}],"disaggregated":false}}],"spec":{"version":3,"widgetType":"bar","encodings":{"x":{"fieldName":"time_agg_key","scale":{"type":"categorical"},"displayName":"Attributed Usage ($)"},"y":{"fieldName":"sum(query_attributed_dollars_with_discount)","scale":{"type":"quantitative"},"format":{"type":"number-currency","currencyCode":"USD","abbreviation":"none","decimalPlaces":{"type":"max","places":0}},"displayName":"Attributed Usage ($)"},"label":{"show":true},"extra":[{"fieldName":"sum(query_attributed_dbus_estimation)","format":{"type":"number-plain","abbreviation":"none","decimalPlaces":{"type":"max","places":2}},"displayName":"Attributed Usage (DBUs)"},{"fieldName":"count(statement_id)","displayName":"Query Count"}]},"frame":{"showTitle":true,"title":"Attributed Usage Cost Over Time"},"mark":{"colors":["#077A9D","#FFAB00","#00A972","#FF3621","#8BCAE7","#AB4057","#99DDB4","#FCA4A1","#919191","#BF7080"]}}},"position":{"x":0,"y":23,"width":6,"height":6}},{"widget":{"name":"e88b2e4a","queries":[{"name":"dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef01564146dbc0703226f411071_time_agg_toggle","query":{"datasetName":"773aca07","fields":[{"name":"time_agg_toggle","expression":"`time_agg_toggle`"},{"name":"time_agg_toggle_associativity","expression":"COUNT_IF(`associative_filter_predicate_group`)"}],"disaggregated":false}},{"name":"parameter_dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef01564141b910a89950bda083e_date_agg_level","query":{"datasetName":"3e6fd95c","parameters":[{"name":"date_agg_level","keyword":"date_agg_level"}],"disaggregated":false}}],"spec":{"version":2,"widgetType":"filter-single-select","encodings":{"fields":[{"parameterName":"date_agg_level","queryName":"parameter_dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef01564141b910a89950bda083e_date_agg_level"},{"fieldName":"time_agg_toggle","displayName":"time_agg_toggle","queryName":"dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef01564146dbc0703226f411071_time_agg_toggle"}]},"frame":{"showTitle":true,"title":"Time Series Unit"}}},"position":{"x":3,"y":21,"width":3,"height":2}},{"widget":{"name":"31832403","textbox_spec":"##### Time series of Attributed Usage of filtered data. Use the dropdown on the right to change time series unit. \n(Time series unit selection will only affect this chart)"},"position":{"x":0,"y":21,"width":3,"height":2}},{"widget":{"name":"8556eee0","textbox_spec":"###### Dashboard v1 2025.01.31\nReachout to jooho.yeo@databricks.com for any questions"},"position":{"x":0,"y":46,"width":2,"height":1}},{"widget":{"name":"7d70446e","textbox_spec":"# DBSQL Cost Dashboard\n-----\n\n### Sections\n- **Inputs** - (Mandatory) Choose Start Time and End Time. (Optional) - Can select specific workspaces, warehouses, users, query source types, or object ids (supported for DBX objects). \n 1. If you want to limit the results of the dashboard to top 10 users, you can specify using the \"Top N Dimension\" and \"Top N Number\" filters.\n 2. Top level counts are shown for reference as you apply different filters. \n- **Charts** - Attributed costs by 1) user 2) source type 3) object ids. If the chart is crowded, click and zoom into the chart, or use the \"Top N\" filters. Click on a bar to cross-filter across the dashboard (to select multiple filters or options, you will need to back to the inputs at the top) 4) is a time series of attributed usage ($) for the filtered down dataset. Time unit is configurable (daily, weekly, etc). \n 1. Charts can also be downloaded into a CSV file by clicking on the option on the top right corner).\n- **Statement Level Detail** - Attributed usage ($) at the individual SQL run level. \n 1. You can click on the statement id or query source id (\"object id\") links to manage \n-----"},"position":{"x":0,"y":0,"width":6,"height":5}},{"widget":{"name":"8ab66f09","textbox_spec":"## Inputs\n----"},"position":{"x":0,"y":5,"width":6,"height":1}},{"widget":{"name":"867434c1","queries":[{"name":"parameter_dashboards/01efde5dd4c51fc89e1caf2a86c344d7/datasets/01efde5dd4c615cd98f5bc2e8fab18b5_dbsql_discount","query":{"datasetName":"3e6fd95c","parameters":[{"name":"dbsql_discount","keyword":"dbsql_discount"}],"disaggregated":false}}],"spec":{"version":2,"widgetType":"filter-single-select","encodings":{"fields":[{"parameterName":"dbsql_discount","queryName":"parameter_dashboards/01efde5dd4c51fc89e1caf2a86c344d7/datasets/01efde5dd4c615cd98f5bc2e8fab18b5_dbsql_discount"}]},"frame":{"showTitle":true,"title":"DBSQL Discount (%)","showDescription":true,"description":"(i.e. 0.1 == 10% discount)"}}},"position":{"x":5,"y":8,"width":1,"height":2}}]}]} \ No newline at end of file diff --git a/dbsql_cost_per_query/PrPr/DBSQL Cost Per Query MV (PrPr).sql b/dbsql_cost_per_query/PrPr/DBSQL Cost Per Query MV (PrPr).sql new file mode 100644 index 00000000..bde5be99 --- /dev/null +++ b/dbsql_cost_per_query/PrPr/DBSQL Cost Per Query MV (PrPr).sql @@ -0,0 +1,436 @@ + +CREATE OR REPLACE MATERIALIZED VIEW main.default.dbsql_cost_per_query +(statement_id string, +query_source_id string, +query_source_type string, +client_application string, +executed_by string, +warehouse_id string, +statement_text string, +workspace_id string, +statement_hour_bucket_costs array>, +start_time timestamp, +end_time timestamp, +query_work_start_time timestamp, +query_work_end_time timestamp, +duration_seconds double, +query_work_duration_seconds double, +query_work_task_time_seconds double, +query_attributed_dollars_estimation double, +query_attributed_dbus_estimation double, +url_helper string, +query_profile_url string, +most_recent_billing_hour timestamp, +billing_record_check string, +query_start_hour timestamp +) +SCHEDULE EVERY 1 HOUR +PARTITIONED BY (query_start_hour, workspace_id) +TBLPROPERTIES ('pipelines.autoOptimize.zOrderCols' = 'warehouse_id') +AS +( +WITH +-- Must make sure the time window the MV is built on has enough data from ALL 3 tables to generate accurate results (both starts and end time ranges) +table_boundaries AS ( +SELECT +(SELECT MAX(event_time) FROM system.compute.warehouse_events) AS max_events_ts, +(SELECT MAX(end_time) FROM system.query.history) AS max_query_end_ts, +(SELECT MAX(usage_end_time) FROM system.billing.usage) AS max_billing_ts, +(SELECT MIN(event_time) FROM system.compute.warehouse_events) AS min_event_ts, +(SELECT MIN(start_time) FROM system.query.history) AS min_query_start_ts, +(SELECT MIN(usage_end_time) FROM system.billing.usage) AS min_billing_ts, +date_trunc('HOUR', LEAST(max_events_ts, max_query_end_ts, max_billing_ts)) AS selected_end_time, +(date_trunc('HOUR', GREATEST(min_event_ts, min_query_start_ts, min_billing_ts)) + INTERVAL 1 HOUR)::timestamp AS selected_start_time +), + +----===== Warehouse Level Calculations =====----- +cpq_warehouse_usage AS ( + SELECT + usage_metadata.warehouse_id AS warehouse_id, + * + FROM + system.billing.usage AS u + WHERE + usage_metadata.warehouse_id IS NOT NULL + AND usage_start_time >= (SELECT MIN(selected_start_time) FROM table_boundaries) + AND usage_end_time <= (SELECT MAX(selected_end_time) FROM table_boundaries) +), + +prices AS ( + select coalesce(price_end_time, date_add(current_date, 1)) as coalesced_price_end_time, * + from system.billing.list_prices + where currency_code = 'USD' +), + +filtered_warehouse_usage AS ( + -- Warehouse usage is aggregated hourly, that will be the base assumption and grain of allocation moving forward. + -- Assume no duplicate records + SELECT + u.warehouse_id warehouse_id, + date_trunc('HOUR',u.usage_start_time) AS usage_start_hour, + date_trunc('HOUR',u.usage_end_time) AS usage_end_hour, + u.usage_quantity AS dbus, + ( + CAST(p.pricing.effective_list.default AS FLOAT) * dbus + ) AS usage_dollars + FROM + cpq_warehouse_usage AS u + left join prices as p + on u.sku_name=p.sku_name + and u.usage_unit=p.usage_unit + and (u.usage_end_time between p.price_start_time and p.coalesced_price_end_time) +), + +----===== Query Level Calculations =====----- +cpq_warehouse_query_history AS ( + SELECT + account_id, + workspace_id, + statement_id, + executed_by, + statement_text, + compute.warehouse_id AS warehouse_id, + execution_status, + COALESCE(client_application, 'Unknown') AS client_application, + (COALESCE(CAST(total_task_duration_ms AS FLOAT) / 1000, 0) + + COALESCE(CAST(result_fetch_duration_ms AS FLOAT) / 1000, 0) + + COALESCE(CAST(compilation_duration_ms AS FLOAT) / 1000, 0) + ) AS query_work_task_time, + start_time, + end_time, + timestampadd(MILLISECOND , waiting_at_capacity_duration_ms + waiting_for_compute_duration_ms + compilation_duration_ms, start_time) AS query_work_start_time, + timestampadd(MILLISECOND, result_fetch_duration_ms, end_time) AS query_work_end_time, + -- NEW - Query source + CASE + WHEN query_source.job_info.job_id IS NOT NULL THEN 'JOB' + WHEN query_source.legacy_dashboard_id IS NOT NULL THEN 'LEGACY DASHBOARD' + WHEN query_source.dashboard_id IS NOT NULL THEN 'AI/BI DASHBOARD' + WHEN query_source.alert_id IS NOT NULL THEN 'ALERT' + WHEN query_source.notebook_id IS NOT NULL THEN 'NOTEBOOK' + WHEN query_source.sql_query_id IS NOT NULL THEN 'SQL QUERY' + WHEN query_source.genie_space_id IS NOT NULL THEN 'GENIE SPACE' + WHEN client_application IS NOT NULL THEN client_application + ELSE 'UNKNOWN' + END AS query_source_type, + COALESCE( + query_source.job_info.job_id, + query_source.legacy_dashboard_id, + query_source.dashboard_id, + query_source.alert_id, + query_source.notebook_id, + query_source.sql_query_id, + query_source.genie_space_id, + 'UNKNOWN' + ) AS query_source_id + FROM + system.query.history AS h + WHERE + statement_type IS NOT NULL + -- If query touches the boundaries at all, we will divy it up + AND start_time < (SELECT MAX(selected_end_time) FROM table_boundaries) + AND end_time > (SELECT MIN(selected_start_time) FROM table_boundaries) + AND total_task_duration_ms > 0 --exclude metadata operations +), + +--- Warehouse + Query Level level allocation +window_events AS ( + SELECT + warehouse_id, + workspace_id, + event_type, + event_time, + cluster_count AS cluster_count, + CASE + WHEN cluster_count = 0 THEN 'OFF' + WHEN cluster_count > 0 THEN 'ON' + END AS warehouse_state + FROM system.compute.warehouse_events AS we + -- Only get window events for when we have query history, otherwise, not usable + WHERE EXISTS (SELECT warehouse_id FROM cpq_warehouse_query_history ws WHERE we.warehouse_id = ws.warehouse_id) + AND event_time BETWEEN (SELECT MIN(selected_start_time) FROM table_boundaries) AND (SELECT MAX(selected_end_time) FROM table_boundaries) +), + +-- Get the most recent state of the warehouse before the event window +pre_window_event AS ( + SELECT + warehouse_id, + workspace_id, + event_type, + event_time, + cluster_count AS cluster_count, + CASE + WHEN cluster_count = 0 THEN 'OFF' + WHEN cluster_count > 0 THEN 'ON' + END AS warehouse_state + FROM system.compute.warehouse_events pwe + WHERE + event_time < (SELECT MIN(selected_start_time) FROM table_boundaries) + AND event_time >= DATE_SUB((SELECT MIN(selected_start_time) FROM table_boundaries), 1) -- Make 1 day lookback window + AND EXISTS ( + SELECT 1 + FROM window_events we + WHERE we.warehouse_id = pwe.warehouse_id + AND we.workspace_id = pwe.workspace_id + ) -- Filter for only warehouses that have events in the selected period, very important for performance + QUALIFY ROW_NUMBER() OVER (PARTITION BY pwe.warehouse_id ORDER BY event_time DESC) = 1 +), + +-- Combine Pre-Window and Window Events +all_events AS ( + SELECT * FROM pre_window_event + UNION ALL + SELECT * FROM window_events +), + +-- Create Event Windows for Each Warehouse +event_windows AS ( + SELECT /*+ REPARTITION(128, event_window_start) */ + warehouse_id, + warehouse_state AS window_state, + event_time AS event_window_start, + LEAD(event_time, 1, (SELECT MAX(selected_end_time) FROM table_boundaries)) OVER ( + PARTITION BY warehouse_id + ORDER BY event_time + ) AS event_window_end + FROM all_events +), + +all_seconds AS ( + SELECT + e.warehouse_id, + e.window_state, + CAST(second_chunk AS TIMESTAMP) AS second_chunk + FROM event_windows e + LATERAL VIEW explode( + sequence( + CAST(UNIX_TIMESTAMP(e.event_window_start) AS BIGINT), + CAST(UNIX_TIMESTAMP(e.event_window_end) - 1 AS BIGINT), -- Subtract 1 to avoid off-by-one errors + 1 + ) + ) AS second_chunk + WHERE CAST(UNIX_TIMESTAMP(e.event_window_start) AS BIGINT) < CAST(UNIX_TIMESTAMP(e.event_window_end) AS BIGINT) +), + +-- Weave in Query History for Each Warehouse +raw_history AS ( + SELECT /*+ REPARTITION(128, query_second) */ + warehouse_id, + CAST(query_second AS TIMESTAMP) AS query_second, -- Convert back to TIMESTAMP + COUNT(0) AS queries_active + FROM ( + SELECT + warehouse_id, + start_seconds + seq_index AS query_second + FROM ( + SELECT + warehouse_id, + CAST(UNIX_TIMESTAMP(date_trunc('SECOND', query_work_start_time)) AS BIGINT) AS start_seconds, -- For Photon compatability + CAST(UNIX_TIMESTAMP(date_trunc('SECOND', query_work_end_time)) AS BIGINT) AS end_seconds, + end_seconds - start_seconds AS duration_seconds + FROM cpq_warehouse_query_history f + WHERE + EXISTS ( + SELECT warehouse_id + FROM window_events we + WHERE we.warehouse_id = f.warehouse_id + ) + ) base + LATERAL VIEW posexplode(sequence(0, duration_seconds)) AS seq_index, seq_value + ) expanded + GROUP BY warehouse_id, query_second +), + + +state_by_second AS ( + SELECT + s.warehouse_id, + s.second_chunk, + MAX(s.window_state) AS warehouse_state, + COALESCE(MAX(rh.queries_active), 0) AS query_load, -- queries_active will be null on this join because there were no queries for that warehouse active in the second + CASE + WHEN COALESCE(MAX(s.window_state), 'OFF') = 'OFF' THEN 'OFF' + WHEN query_load > 0 THEN 'UTILIZED' + WHEN query_load = 0 AND MAX(s.window_state) = 'ON' THEN 'ON_IDLE' -- queries_active will be null on this join because there were no queries for that warehouse active in the second + END AS utilization_flag + FROM all_seconds s + LEFT JOIN raw_history rh + ON s.warehouse_id = rh.warehouse_id + AND s.second_chunk = rh.query_second + WHERE s.second_chunk <= (SELECT MAX(selected_end_time) FROM table_boundaries) -- Make you only calculate utailization metrics up to the clean end-hour window + GROUP BY + s.warehouse_id, + s.second_chunk +), + +utilization_by_warehouse AS ( +SELECT + warehouse_id, + date_trunc('HOUR', second_chunk) AS warehouse_hour, + COUNT(CASE WHEN utilization_flag = 'UTILIZED' THEN second_chunk END) AS utilized_seconds, + COUNT(CASE WHEN utilization_flag = 'ON_IDLE' THEN second_chunk END) AS idle_seconds, + COUNT(*) AS total_seconds, + round( + CASE + WHEN COUNT(*) = 0 THEN 0 + ELSE COUNT(CASE WHEN utilization_flag = 'UTILIZED' THEN second_chunk END) / (COUNT(CASE WHEN utilization_flag = 'UTILIZED' THEN second_chunk END) + COUNT(CASE WHEN utilization_flag = 'ON_IDLE' THEN second_chunk END)) + END, + 2 + ) AS utilization_proportion +FROM state_by_second +GROUP BY warehouse_id, date_trunc('HOUR', second_chunk) +), + +cleaned_warehouse_info AS ( + SELECT + wu.warehouse_id, + wu.usage_start_hour AS hour_bucket, + wu.dbus, + wu.usage_dollars, + ut.utilized_seconds, + ut.idle_seconds, + ut.total_seconds, + ut.utilization_proportion + FROM filtered_warehouse_usage wu + LEFT JOIN utilization_by_warehouse AS ut ON wu.warehouse_id = ut.warehouse_id -- Join on calculation grain - warehouse/hour + AND wu.usage_start_hour = ut.warehouse_hour +), + +hour_intervals AS ( + -- Generate valid hourly buckets for each query + SELECT + statement_id, + warehouse_id, + query_work_start_time, + query_work_end_time, + query_work_task_time, + explode( + sequence( + 0, + floor((UNIX_TIMESTAMP(query_work_end_time) - UNIX_TIMESTAMP(date_trunc('hour', query_work_start_time))) / 3600) + ) + ) AS hours_interval, + timestampadd(hour, hours_interval, date_trunc('hour', query_work_start_time)) AS hour_bucket + FROM + cpq_warehouse_query_history +), + +statement_proportioned_work AS ( + SELECT * , + GREATEST(0, + UNIX_TIMESTAMP(LEAST(query_work_end_time, timestampadd(hour, 1, hour_bucket))) - + UNIX_TIMESTAMP(GREATEST(query_work_start_time, hour_bucket)) + ) AS overlap_duration, + query_work_task_time * (overlap_duration / (CAST(query_work_end_time AS DOUBLE) - CAST(query_work_start_time AS DOUBLE))) AS proportional_query_work + FROM hour_intervals +), + + +attributed_query_work_all AS ( + SELECT + statement_id, + hour_bucket, + warehouse_id, + SUM(proportional_query_work) AS attributed_query_work + FROM + statement_proportioned_work + GROUP BY + statement_id, + warehouse_id, + hour_bucket +), + +--- Cost Attribution +warehouse_time as ( + select + warehouse_id, + hour_bucket, + SUM(attributed_query_work) as total_work_done_on_warehouse + from + attributed_query_work_all + group by + warehouse_id, hour_bucket +), + +-- Create statement_id / hour bucket allocated combinations +history AS ( + SELECT + a.*, + b.total_work_done_on_warehouse, + CASE + WHEN attributed_query_work = 0 THEN NULL + ELSE attributed_query_work / total_work_done_on_warehouse + END AS proportion_of_warehouse_time_used_by_query + FROM attributed_query_work_all a + inner join warehouse_time b on a.warehouse_id = b.warehouse_id + AND a.hour_bucket = b.hour_bucket -- Will only run for completed hours from warehouse usage - nice clean boundary +), + +history_with_pricing AS ( + SELECT + h1.*, + wh.dbus AS total_warehouse_period_dbus, + wh.usage_dollars AS total_warehouse_period_dollars, + wh.utilization_proportion AS warehouse_utilization_proportion, + wh.hour_bucket AS warehouse_hour_bucket, + MAX(wh.hour_bucket) OVER() AS warehouse_max_hour_bucket + FROM + history AS h1 + LEFT JOIN cleaned_warehouse_info AS wh ON h1.warehouse_id = wh.warehouse_id AND h1.hour_bucket = wh.hour_bucket +), + +-- This is at the statement_id / hour grain (there will be duplicates for each statement for each hour bucket the query spans) +query_attribution AS ( + SELECT + a.*, + warehouse_max_hour_bucket AS most_recent_billing_hour, + CASE WHEN warehouse_hour_bucket IS NOT NULL THEN 'Has Billing Reocrd' ELSE 'No Billing Record for this hour and warehouse yet available' END AS billing_record_check, + CASE + WHEN total_work_done_on_warehouse = 0 THEN NULL + ELSE attributed_query_work / total_work_done_on_warehouse + END AS query_task_time_proportion, + + (warehouse_utilization_proportion * total_warehouse_period_dollars) * query_task_time_proportion AS query_attributed_dollars_estimation, + (warehouse_utilization_proportion * total_warehouse_period_dbus) * query_task_time_proportion AS query_attributed_dbus_estimation + FROM + history_with_pricing a +) + +-- Final Output +select + qq.statement_id, + FIRST(qq.query_source_id) AS query_source_id, + FIRST(qq.query_source_type) AS query_source_type, + FIRST(qq.client_application) AS client_application, + FIRST(qq.executed_by) AS executed_by, + FIRST(qq.warehouse_id) AS warehouse_id, + FIRST(qq.statement_text) AS statement_text, + FIRST(qq.workspace_id) AS workspace_id, + COLLECT_LIST(NAMED_STRUCT('hour_bucket', qa.hour_bucket, 'hour_attributed_cost', query_attributed_dollars_estimation, 'hour_attributed_dbus', query_attributed_dbus_estimation)) AS statement_hour_bucket_costs, + FIRST(qq.start_time) AS start_time, + FIRST(qq.end_time) AS end_time, + FIRST(qq.query_work_start_time) AS query_work_start_time, + FIRST(qq.query_work_end_time) AS query_work_end_time, + COALESCE(timestampdiff(MILLISECOND, FIRST(qq.start_time), FIRST(qq.end_time))/1000, 0) AS duration_seconds, + COALESCE(timestampdiff(MILLISECOND, FIRST(qq.query_work_start_time), FIRST(qq.query_work_end_time))/1000, 0) AS query_work_duration_seconds, + FIRST(query_work_task_time) AS query_work_task_time_seconds, + SUM(query_attributed_dollars_estimation) AS query_attributed_dollars_estimation, + SUM(query_attributed_dbus_estimation) AS query_attributed_dbus_estimation, + FIRST(CASE + WHEN query_source_type = 'JOB' THEN CONCAT('/jobs/', query_source_id) + WHEN query_source_type = 'SQL QUERY' THEN CONCAT('/sql/queries/', query_source_id) + WHEN query_source_type = 'AI/BI DASHBOARD' THEN CONCAT('/sql/dashboardsv3/', query_source_id) + WHEN query_source_type = 'LEGACY DASHBOARD' THEN CONCAT('/sql/dashboards/', query_source_id) + WHEN query_source_type = 'ALERTS' THEN CONCAT('/sql/alerts/', query_source_id) + WHEN query_source_type = 'GENIE SPACE' THEN CONCAT('/genie/rooms/', query_source_id) + WHEN query_source_type = 'NOTEBOOK' THEN CONCAT('/editor/notebooks/', query_source_id) + ELSE '' + END) as url_helper, + FIRST(CONCAT('/sql/history?uiQueryProfileVisible=true&queryId=', qq.statement_id)) AS query_profile_url, + FIRST(most_recent_billing_hour) AS most_recent_billing_hour, + FIRST(billing_record_check) AS billing_record_check, + date_trunc('HOUR', FIRST(qq.start_time)) AS query_start_hour + from query_attribution qa + LEFT JOIN cpq_warehouse_query_history AS qq ON qa.statement_id = qq.statement_id -- creating dups of the objects but just re-aggregating + AND qa.warehouse_id = qq.warehouse_id + GROUP BY qq.statement_id +) From 117de154bf48e018de4d84006d204bcdcc0cc64d Mon Sep 17 00:00:00 2001 From: Cody Austin Davis Date: Tue, 4 Feb 2025 12:46:47 -0800 Subject: [PATCH 2/4] Fix ANSI SQL compliance --- .../PrPr/DBSQL Cost Dashboard (PrPr).lvdash.json | 2 +- .../PrPr/DBSQL Cost Per Query MV (PrPr).sql | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/dbsql_cost_per_query/PrPr/DBSQL Cost Dashboard (PrPr).lvdash.json b/dbsql_cost_per_query/PrPr/DBSQL Cost Dashboard (PrPr).lvdash.json index 32702712..d6542261 100644 --- a/dbsql_cost_per_query/PrPr/DBSQL Cost Dashboard (PrPr).lvdash.json +++ b/dbsql_cost_per_query/PrPr/DBSQL Cost Dashboard (PrPr).lvdash.json @@ -1 +1 @@ -{"datasets":[{"name":"8d75d358","displayName":"binary_options","query":"SELECT option\nFROM (VALUES ('Yes'), ('No')) AS options(option)"},{"name":"3e6fd95c","displayName":"statement_level_allocation","query":"WITH warehouse_snapshot AS (\n SELECT warehouse_id,\n warehouse_name,\n workspace_id,\n account_id\n change_time,\n delete_time,\n CASE WHEN delete_time IS NOT NULL THEN 'Deleted' ELSE 'Active' END AS is_deleted\n FROM system.compute.warehouses w\n WHERE\n -- workspace filter\n (array_contains(:workspace_id,w.workspace_id) OR array_contains(:workspace_id,'all'))\n -- warehouse filter\n AND (array_contains(:warehouse_name, CONCAT(w.warehouse_name, ' (id:', w.warehouse_id, ')')) OR array_contains(:warehouse_name,'all'))\n QUALIFY ROW_NUMBER() OVER (PARTITION BY workspace_id, warehouse_id ORDER BY change_time DESC) == 1 -- Get more recent snapshot\n),\n\nroot_table AS (\n SELECT * \n FROM main.default.dbsql_cost_per_query AS qq\n WHERE\n query_attributed_dollars_estimation IS NOT NULL\n -- workspace filter\n AND (array_contains(:workspace_id,qq.workspace_id) OR array_contains(:workspace_id,'all'))\n -- warehouse filter\n AND (array_contains(:warehouse_id,qq.warehouse_id) OR array_contains(:warehouse_id,'all'))\n -- time filter (based on query start time)\n AND query_start_hour BETWEEN CAST(:time_range.min AS TIMESTAMP) AND CAST(:time_range.max AS TIMESTAMP) -- for good pruning\n -- statement_id filter - optional\n AND (array_contains(:statement_id,qq.statement_id) OR array_contains(:statement_id,'all')) -- optional statement id filter\n),\n\ntop_n_filter AS (\n SELECT \n IDENTIFIER(CASE \n WHEN :top_n_dimension = 'Executed By' THEN 'executed_by'\n WHEN :top_n_dimension = 'Source Type' THEN 'query_source_type'\n WHEN :top_n_dimension = 'Object Id' THEN 'query_source_id'\n WHEN :top_n_dimension = 'Statement Id' THEN 'statement_id'\n ELSE 'statement_id'\n END) AS rank_key,\n ROW_NUMBER() OVER (ORDER BY SUM(query_attributed_dollars_estimation) DESC) AS cost_rank\n FROM root_table AS qq\n GROUP BY\n IDENTIFIER(CASE \n WHEN :top_n_dimension = 'Executed By' THEN 'executed_by'\n WHEN :top_n_dimension = 'Source Type' THEN 'query_source_type'\n WHEN :top_n_dimension = 'Object Id' THEN 'query_source_id'\n WHEN :top_n_dimension = 'Statement Id' THEN 'statement_id'\n ELSE 'statement_id'\n END)\n),\n\nmv_model AS (\n\n SELECT qq.*,\n CONCAT(w.warehouse_name, ' (id:', w.warehouse_id, ')') AS warehouse_name ,\n w.is_deleted AS is_warehouse_deleted,\n query_attributed_dollars_estimation * (1 - CAST(:dbsql_discount AS FLOAT)) AS query_attributed_dollars_with_discount,\n --ROW_NUMBER() OVER (PARTITION BY CASE WHEN :ORDER BY QueryAllocationDollars DESC) AS CostRank\n tn.cost_rank\n FROM root_table AS qq\n INNER JOIN warehouse_snapshot w ON qq.workspace_id = w.workspace_id AND qq.warehouse_id = w.warehouse_id\n LEFT JOIN top_n_filter AS tn ON IDENTIFIER(CASE \n WHEN :top_n_dimension = 'Executed By' THEN 'qq.executed_by'\n WHEN :top_n_dimension = 'Source Type' THEN 'qq.query_source_type'\n WHEN :top_n_dimension = 'Object Id' THEN 'qq.query_source_id'\n WHEN :top_n_dimension = 'Statement Id' THEN 'qq.statement_id'\n ELSE 'statement_id'\n END) = tn.rank_key\n)\n\nSELECT\n mv.*,\n CASE WHEN :group_key = 'Warehouse Id' THEN mv.warehouse_id\n WHEN :group_key = 'Warehouse Name' THEN mv.warehouse_name\n WHEN :group_key = 'User' THEN mv.executed_by\n WHEN :group_key = 'Source Type' THEN mv.query_source_type\n WHEN :group_key = 'Obect Id' THEN mv.query_source_id\n WHEN :group_key = 'Client' THEN mv.client_application\n WHEN :group_key = 'Workspace Id' THEN mv.workspace_id\n END AS group_key,\n CASE WHEN :date_agg_level = 'HOUR' THEN \n date_trunc(:date_agg_level, mv.start_time)::timestamp::string\n ELSE date_trunc(:date_agg_level, mv.start_time)::date::string\n END AS time_agg_key,\n -- Data formatting for visuals\n MAX(query_attributed_dollars_with_discount) OVER() AS fully_loaded_max_usage,\n MIN(query_attributed_dollars_with_discount) OVER() AS fully_loaded_min_usage,\n COALESCE(CONCAT(\n '
',\n '
',\n '$',\n FORMAT_NUMBER(query_attributed_dollars_with_discount, 2), \n '
'\n ), '--') AS allocated_dollars_usage_bar_html,\n-- Data formatting for visuals\n MAX(query_attributed_dbus_estimation) OVER() AS fully_loaded_max_usage_dbus,\n MIN(query_attributed_dbus_estimation) OVER() AS fully_loaded_min_usage_dbus,\n COALESCE(CONCAT(\n '
',\n '
',\n '$',\n FORMAT_NUMBER(query_attributed_dbus_estimation, 2), \n '
'\n ), '--') AS allocated_dbus_usage_bar_html\nFROM mv_model AS mv\nWHERE\n(lower(:top_n)::string = 'all' OR cost_rank <= :top_n::int) -- There can be ties, so we will also do a limit\nORDER BY cost_rank, query_attributed_dollars_with_discount DESC\n\n\n","parameters":[{"displayName":"statement_id","keyword":"statement_id","dataType":"STRING","complexType":"MULTI","defaultSelection":{"values":{"dataType":"STRING","values":[{"value":"all"}]}}},{"displayName":"workspace_id","keyword":"workspace_id","dataType":"STRING","complexType":"MULTI","defaultSelection":{"values":{"dataType":"STRING","values":[{"value":"all"}]}}},{"displayName":"warehouse_id","keyword":"warehouse_id","dataType":"STRING","complexType":"MULTI","defaultSelection":{"values":{"dataType":"STRING","values":[{"value":"all"}]}}},{"displayName":"warehouse_name","keyword":"warehouse_name","dataType":"STRING","complexType":"MULTI","defaultSelection":{"values":{"dataType":"STRING","values":[{"value":"all"}]}}},{"displayName":"top_n_dimension","keyword":"top_n_dimension","dataType":"STRING","defaultSelection":{"values":{"dataType":"STRING","values":[{"value":"Executed By"}]}}},{"displayName":"dbsql_discount","keyword":"dbsql_discount","dataType":"STRING","defaultSelection":{"values":{"dataType":"STRING","values":[{"value":"0.0"}]}}},{"displayName":"group_key","keyword":"group_key","dataType":"STRING","defaultSelection":{"values":{"dataType":"STRING","values":[{"value":"User"}]}}},{"displayName":"date_agg_level","keyword":"date_agg_level","dataType":"STRING","defaultSelection":{"values":{"dataType":"STRING","values":[{"value":"DAY"}]}}},{"displayName":"top_n","keyword":"top_n","dataType":"STRING","defaultSelection":{"values":{"dataType":"STRING","values":[{"value":"all"}]}}},{"displayName":"time_range","keyword":"time_range","dataType":"DATETIME","complexType":"RANGE","defaultSelection":{"range":{"dataType":"DATETIME","min":{"value":"now-7d/d"},"max":{"value":"now-1d/d"}}}}]},{"name":"b6c55fed","displayName":"workspace_with_all","query":" WITH billing AS (\n SELECT workspace_id, usage_metadata.warehouse_id AS warehouse_id\n FROM system.billing.usage u\n WHERE usage_start_time BETWEEN date_trunc('hour', :start_time) AND :end_time\n AND usage_metadata.warehouse_id IS NOT NULL\n GROUP BY 1,2\n )\n -- Get warehouse names (most recent change record) for warehouses with usage in selected period\n SELECT w.workspace_id, w.warehouse_id, CONCAT(w.warehouse_name, ' (id:', w.warehouse_id, ')') AS warehouse_name\n FROM billing AS b\n JOIN system.compute.warehouses w ON b.workspace_id = w.workspace_id AND w.warehouse_id = b.warehouse_id\n QUALIFY ROW_NUMBER() OVER(PARTITION BY w.workspace_id, w.warehouse_id ORDER BY w.change_time DESC) == 1","parameters":[{"displayName":"start_time","keyword":"start_time","dataType":"DATETIME","defaultSelection":{"values":{"dataType":"DATETIME","values":[{"value":"2024-12-04T15:45:12.000"}]}}},{"displayName":"end_time","keyword":"end_time","dataType":"DATETIME","defaultSelection":{"values":{"dataType":"DATETIME","values":[{"value":"now-1m/m"}]}}}]},{"name":"773aca07","displayName":"select_time_agg","query":"SELECT explode(array('YEAR', 'QUARTER', 'MONTH', 'WEEK', 'DAY', 'HOUR')) AS time_agg_toggle"},{"name":"706e050f","displayName":"select_dynamic_group_key_toggle","query":"SELECT explode(array('User', 'Warehouse Id', 'Warehouse Name', 'Object Id', 'Source Type', 'Workspace Id')) AS group_key\n"},{"name":"9dda0ef1","displayName":"select_top_n_dim","query":"SELECT explode(array('Executed By', 'Source Type', 'Object Id', 'Statement Id')) AS object_top_n_toggle"}],"pages":[{"name":"3972306b","displayName":"Query Cost Overview","layout":[{"widget":{"name":"1274573c","queries":[{"name":"parameter_dashboards/01efde5dd4c51fc89e1caf2a86c344d7/datasets/01efde5dd4c615cd98f5bc2e8fab18b5_time_range","query":{"datasetName":"3e6fd95c","parameters":[{"name":"time_range","keyword":"time_range"}],"disaggregated":false}}],"spec":{"version":2,"widgetType":"filter-date-range-picker","encodings":{"fields":[{"parameterName":"time_range","queryName":"parameter_dashboards/01efde5dd4c51fc89e1caf2a86c344d7/datasets/01efde5dd4c615cd98f5bc2e8fab18b5_time_range"}]},"frame":{"showTitle":true,"title":"Time Range"}}},"position":{"x":0,"y":6,"width":2,"height":2}},{"widget":{"name":"029aeeb6","queries":[{"name":"dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef015641455b4942decd4151ed3_workspace_id","query":{"datasetName":"b6c55fed","fields":[{"name":"workspace_id","expression":"`workspace_id`"},{"name":"workspace_id_associativity","expression":"COUNT_IF(`associative_filter_predicate_group`)"}],"disaggregated":false}},{"name":"parameter_dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef01564141b910a89950bda083e_workspace_id","query":{"datasetName":"3e6fd95c","parameters":[{"name":"workspace_id","keyword":"workspace_id"}],"disaggregated":false}}],"spec":{"version":2,"widgetType":"filter-multi-select","encodings":{"fields":[{"parameterName":"workspace_id","queryName":"parameter_dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef01564141b910a89950bda083e_workspace_id"},{"fieldName":"workspace_id","displayName":"workspace_id","queryName":"dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef015641455b4942decd4151ed3_workspace_id"}]},"frame":{"showTitle":true,"title":"Workspace Id"}}},"position":{"x":2,"y":6,"width":1,"height":2}},{"widget":{"name":"8ad3de2b","queries":[{"name":"main_query","query":{"datasetName":"3e6fd95c","fields":[{"name":"sum(query_attributed_dollars_with_discount)","expression":"SUM(`query_attributed_dollars_with_discount`)"},{"name":"sum(query_attributed_dbus_estimation)","expression":"SUM(`query_attributed_dbus_estimation`)"},{"name":"countdistinct(statement_id)","expression":"COUNT(DISTINCT `statement_id`)"},{"name":"executed_by","expression":"`executed_by`"}],"disaggregated":false}}],"spec":{"version":3,"widgetType":"bar","encodings":{"x":{"fieldName":"sum(query_attributed_dollars_with_discount)","scale":{"type":"quantitative","reverse":false},"format":{"type":"number-currency","currencyCode":"USD","abbreviation":"none","decimalPlaces":{"type":"max","places":2}},"displayName":"Attributed Usage ($)"},"y":{"fieldName":"executed_by","scale":{"type":"categorical","sort":{"by":"x-reversed"}},"axis":{"title":"User"},"displayName":"Group Key"},"color":{"fieldName":"sum(query_attributed_dollars_with_discount)","scale":{"type":"quantitative","colorRamp":{"mode":"scheme","scheme":"greenblue"}},"legend":{"hide":true},"displayName":"Attributed Usage ($)"},"label":{"show":true},"extra":[{"fieldName":"sum(query_attributed_dbus_estimation)","format":{"type":"number-plain","abbreviation":"none","decimalPlaces":{"type":"max","places":2}},"displayName":"Attributed Usage (DBUs)"},{"fieldName":"countdistinct(statement_id)","displayName":"Query Count"}]},"frame":{"showTitle":true,"title":"Cost By User"},"mark":{"colors":["#00A972","#FFAB00","#00A972","#FF3621","#8BCAE7","#AB4057","#99DDB4","#FCA4A1","#919191","#BF7080"]}}},"position":{"x":0,"y":13,"width":2,"height":8}},{"widget":{"name":"b034a298","queries":[{"name":"dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef01564141b910a89950bda083e_executed_by","query":{"datasetName":"3e6fd95c","fields":[{"name":"executed_by","expression":"`executed_by`"},{"name":"executed_by_associativity","expression":"COUNT_IF(`associative_filter_predicate_group`)"}],"disaggregated":false}}],"spec":{"version":2,"widgetType":"filter-multi-select","encodings":{"fields":[{"fieldName":"executed_by","displayName":"executed_by","queryName":"dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef01564141b910a89950bda083e_executed_by"}]},"frame":{"showTitle":true,"title":"User","showDescription":true,"description":"User or service principal running the statement"}}},"position":{"x":0,"y":8,"width":2,"height":2}},{"widget":{"name":"09a2a1f3","queries":[{"name":"dashboards/01efdcd2775e1c1a8a1866858634977b/datasets/01efdcd2775e1ed4903a87d29a6a6697_query_source_type","query":{"datasetName":"3e6fd95c","fields":[{"name":"query_source_type","expression":"`query_source_type`"},{"name":"query_source_type_associativity","expression":"COUNT_IF(`associative_filter_predicate_group`)"}],"disaggregated":false}}],"spec":{"version":2,"widgetType":"filter-multi-select","encodings":{"fields":[{"fieldName":"query_source_type","displayName":"query_source_type","queryName":"dashboards/01efdcd2775e1c1a8a1866858634977b/datasets/01efdcd2775e1ed4903a87d29a6a6697_query_source_type"}]},"frame":{"showTitle":true,"title":"Query Source Type","showDescription":true,"description":"Type of Object (i.e dashboard, SQL Query, JOB, notebook)"}}},"position":{"x":2,"y":8,"width":1,"height":2}},{"widget":{"name":"f80f81da","queries":[{"name":"dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef01564141b910a89950bda083e_query_source_id","query":{"datasetName":"3e6fd95c","fields":[{"name":"query_source_id","expression":"`query_source_id`"},{"name":"query_source_id_associativity","expression":"COUNT_IF(`associative_filter_predicate_group`)"}],"disaggregated":false}}],"spec":{"version":2,"widgetType":"filter-multi-select","encodings":{"fields":[{"fieldName":"query_source_id","displayName":"query_source_id","queryName":"dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef01564141b910a89950bda083e_query_source_id"}]},"frame":{"showTitle":true,"title":"Query Source Id","showDescription":true,"description":"Id of object such as a dashboard, SQL query, job, etc."}}},"position":{"x":3,"y":8,"width":2,"height":2}},{"widget":{"name":"8925bd62","textbox_spec":"## Charts\n----"},"position":{"x":0,"y":10,"width":6,"height":1}},{"widget":{"name":"af6d1285","textbox_spec":"## Statement Level Detail\n----"},"position":{"x":0,"y":29,"width":6,"height":1}},{"widget":{"name":"f1e3bb79","queries":[{"name":"main_query","query":{"datasetName":"3e6fd95c","fields":[{"name":"statement_id","expression":"`statement_id`"},{"name":"statement_text","expression":"`statement_text`"},{"name":"allocated_dollars_usage_bar_html","expression":"`allocated_dollars_usage_bar_html`"},{"name":"executed_by","expression":"`executed_by`"},{"name":"warehouse_name","expression":"`warehouse_name`"},{"name":"duration_seconds","expression":"`duration_seconds`"},{"name":"query_work_duration_seconds","expression":"`query_work_duration_seconds`"},{"name":"start_time","expression":"`start_time`"},{"name":"end_time","expression":"`end_time`"},{"name":"query_work_start_time","expression":"`query_work_start_time`"},{"name":"query_work_end_time","expression":"`query_work_end_time`"},{"name":"query_source_type","expression":"`query_source_type`"},{"name":"query_source_id","expression":"`query_source_id`"},{"name":"client_application","expression":"`client_application`"},{"name":"workspace_id","expression":"`workspace_id`"},{"name":"query_attributed_dollars_with_discount","expression":"`query_attributed_dollars_with_discount`"},{"name":"query_attributed_dbus_estimation","expression":"`query_attributed_dbus_estimation`"},{"name":"query_attributed_dollars_estimation","expression":"`query_attributed_dollars_estimation`"},{"name":"statement_hour_bucket_costs","expression":"`statement_hour_bucket_costs`"},{"name":"query_profile_url","expression":"`query_profile_url`"},{"name":"url_helper","expression":"`url_helper`"}],"disaggregated":true}}],"spec":{"version":1,"widgetType":"table","encodings":{"columns":[{"fieldName":"statement_id","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ query_profile_url }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"string","displayAs":"link","visible":true,"order":0,"title":"Statement Id (link to query profile)","allowSearch":true,"alignContent":"left","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"cellFormat":{"default":{"foregroundColor":"#077A9D"},"rules":[]},"displayName":"statement_id"},{"fieldName":"statement_text","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"string","displayAs":"string","visible":true,"order":1,"title":"Query Text","allowSearch":false,"alignContent":"left","allowHTML":true,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"defaultColumnWidth":300,"description":"Raw text of the statement query that was executed","displayName":"statement_text"},{"fieldName":"allocated_dollars_usage_bar_html","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"string","displayAs":"string","visible":true,"order":2,"title":"Attributed Usage ($)","allowSearch":false,"alignContent":"left","allowHTML":true,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"defaultColumnWidth":200,"description":"Allocated dollars for attributed query (this is an estimate based on query work)","displayName":"allocated_dollars_usage_bar_html"},{"fieldName":"executed_by","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"string","displayAs":"string","visible":true,"order":4,"title":"Executed by","allowSearch":false,"alignContent":"left","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"displayName":"executed_by"},{"fieldName":"warehouse_name","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"string","displayAs":"string","visible":true,"order":6,"title":"Warehouse","allowSearch":true,"alignContent":"left","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"description":"Current name of the warehouse it was run on (warehouse ids are permanent but names are not)","displayName":"warehouse_name"},{"fieldName":"duration_seconds","numberFormat":"0.00","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"float","displayAs":"number","visible":true,"order":7,"title":"Query Duration (s)","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"description":"Runtime of the query in seconds","cellFormat":{"default":{"foregroundColor":"#077A9D"},"rules":[]},"displayName":"duration_seconds"},{"fieldName":"query_work_duration_seconds","numberFormat":"0.00","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"float","displayAs":"number","visible":true,"order":8,"title":"Work Duration (s)","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"description":"Amount of seconds query spent doing work (execution + result fetch)","displayName":"query_work_duration_seconds"},{"fieldName":"start_time","dateTimeFormat":"YYYY-MM-DD HH:mm:ss.SSS","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"datetime","displayAs":"datetime","visible":true,"order":10,"title":"Start Time","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"displayName":"start_time"},{"fieldName":"end_time","dateTimeFormat":"YYYY-MM-DD HH:mm:ss.SSS","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"datetime","displayAs":"datetime","visible":true,"order":11,"title":"End Time","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"displayName":"end_time"},{"fieldName":"query_work_start_time","dateTimeFormat":"YYYY-MM-DD HH:mm:ss.SSS","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"datetime","displayAs":"datetime","visible":true,"order":12,"title":"Work Start Time","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"description":"Start time query began doing work (executing) - can be greater than start_time if it waits in the queue","displayName":"query_work_start_time"},{"fieldName":"query_work_end_time","dateTimeFormat":"YYYY-MM-DD HH:mm:ss.SSS","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"datetime","displayAs":"datetime","visible":true,"order":13,"title":"Work End Time","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"description":"Time when query finishes work. This can be greater than end_time because it includes time spent returning results. ","displayName":"query_work_end_time"},{"fieldName":"query_source_type","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"string","displayAs":"string","visible":true,"order":14,"title":"Query Source Type","allowSearch":false,"alignContent":"left","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"description":"Databricks internal asset source type (i.e. dashboard, notebook, job, etc.)","displayName":"query_source_type"},{"fieldName":"query_source_id","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ url_helper }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"string","displayAs":"link","visible":true,"order":15,"title":"Query Source Id","allowSearch":false,"alignContent":"left","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"description":"Id of the asset type (i.e. if source type = 'JOB' then this will be the job id that ran the query)","displayName":"query_source_id"},{"fieldName":"client_application","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"string","displayAs":"string","visible":true,"order":16,"title":"Client App","allowSearch":false,"alignContent":"left","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"description":"External registered client name (like DBSQL Dashboards, Power BI, Fivetran, etc.)","displayName":"client_application"},{"fieldName":"workspace_id","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"string","displayAs":"string","visible":true,"order":17,"title":"Workspace Id","allowSearch":false,"alignContent":"left","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"displayName":"workspace_id"},{"fieldName":"query_attributed_dollars_with_discount","numberFormat":"$ 0.00","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"float","displayAs":"number","visible":true,"order":18,"title":"Attributed Usage ($) - Discount","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"description":"Estimated query attributed costs with discount param included","cellFormat":{"default":{"foregroundColor":"#00A972"},"rules":[]},"displayName":"query_attributed_dollars_with_discount"},{"fieldName":"query_attributed_dbus_estimation","numberFormat":"0.00","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"float","displayAs":"number","visible":true,"order":19,"title":"Attributed Usage (DBUs)","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"description":"Estimated query attributed dbu usage","cellFormat":{"default":{"foregroundColor":"#077A9D"},"rules":[]},"displayName":"query_attributed_dbus_estimation"},{"fieldName":"query_attributed_dollars_estimation","numberFormat":"0.00","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"float","displayAs":"number","visible":true,"order":20,"title":"Attributed Usage ($) - List","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"description":"Estimated query attributed cost at list rate","displayName":"query_attributed_dollars_estimation"},{"fieldName":"statement_hour_bucket_costs","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"complex","displayAs":"json","visible":true,"order":31,"title":"Query Cost Hourly Breakdown","allowSearch":false,"alignContent":"left","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"description":"If queries span multiple hours, the costs are allocated on an hourly basis, so a total query costs can span multiple hours. This shows what % of the cost is allocated to which hour for that warehouse","displayName":"statement_hour_bucket_costs"}]},"invisibleColumns":[{"booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"allocated_dbus_usage_bar_html","type":"string","displayAs":"string","order":3,"title":"Allocated DBUs","allowSearch":false,"alignContent":"left","allowHTML":true,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"defaultColumnWidth":200},{"booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"warehouse_id","type":"string","displayAs":"string","order":5,"title":"Warehouse Id","allowSearch":false,"alignContent":"left","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false},{"numberFormat":"0.00","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"query_work_task_time_seconds","type":"float","displayAs":"number","order":9,"title":"Query Task Time (s)","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"description":"The total executor task time used by the query","cellFormat":{"default":{"foregroundColor":"#077A9D"},"rules":[]}},{"booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"url_helper","type":"string","displayAs":"string","order":21,"title":"url_helper","allowSearch":false,"alignContent":"left","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false},{"booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"query_profile_url","type":"string","displayAs":"string","order":22,"title":"query_profile_url","allowSearch":false,"alignContent":"left","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false},{"dateTimeFormat":"YYYY-MM-DD HH:mm:ss.SSS","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"most_recent_billing_hour","type":"datetime","displayAs":"datetime","order":23,"title":"most_recent_billing_hour","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false},{"booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"billing_record_check","type":"string","displayAs":"string","order":24,"title":"billing_record_check","allowSearch":false,"alignContent":"left","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false},{"numberFormat":"0.00","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"fully_loaded_max_usage","type":"float","displayAs":"number","order":25,"title":"fully_loaded_max_usage","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false},{"numberFormat":"0.00","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"fully_loaded_min_usage","type":"float","displayAs":"number","order":26,"title":"fully_loaded_min_usage","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false},{"numberFormat":"0.00","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"fully_loaded_max_usage_dbus","type":"float","displayAs":"number","order":27,"title":"fully_loaded_max_usage_dbus","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false},{"numberFormat":"0.00","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"fully_loaded_min_usage_dbus","type":"float","displayAs":"number","order":28,"title":"fully_loaded_min_usage_dbus","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false},{"booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"group_key","type":"string","displayAs":"string","order":29,"title":"group_key","allowSearch":false,"alignContent":"left","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false},{"dateTimeFormat":"YYYY-MM-DD HH:mm:ss.SSS","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"time_agg_key","type":"string","displayAs":"datetime","order":30,"title":"time_agg_key","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false},{"dateTimeFormat":"YYYY-MM-DD HH:mm:ss.SSS","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"query_start_hour","type":"datetime","displayAs":"datetime","order":32,"title":"query_start_hour","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false},{"booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"is_warehouse_deleted","type":"string","displayAs":"string","order":33,"title":"is_warehouse_deleted","allowSearch":false,"alignContent":"left","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false},{"numberFormat":"0","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"cost_rank","type":"integer","displayAs":"number","order":34,"title":"cost_rank","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false}],"allowHTMLByDefault":false,"itemsPerPage":25,"paginationSize":"default","condensed":true,"withRowNumber":true,"frame":{"showTitle":true,"title":"Query Statement Detail"}}},"position":{"x":0,"y":30,"width":6,"height":16}},{"widget":{"name":"3fd47cc4","queries":[{"name":"main_query","query":{"datasetName":"3e6fd95c","fields":[{"name":"countdistinct(statement_id)","expression":"COUNT(DISTINCT `statement_id`)"}],"disaggregated":false}}],"spec":{"version":2,"widgetType":"counter","encodings":{"value":{"fieldName":"countdistinct(statement_id)","format":{"type":"number-plain","abbreviation":"none","decimalPlaces":{"type":"max","places":2}},"displayName":"Count of Unique statement_id"}},"frame":{"showTitle":true,"title":"Query Statement Count"}}},"position":{"x":0,"y":11,"width":2,"height":2}},{"widget":{"name":"37fa2ea4","queries":[{"name":"parameter_dashboards/01efde5dd4c51fc89e1caf2a86c344d7/datasets/01efde5dd4c615cd98f5bc2e8fab18b5_top_n","query":{"datasetName":"3e6fd95c","parameters":[{"name":"top_n","keyword":"top_n"}],"disaggregated":false}}],"spec":{"version":2,"widgetType":"filter-single-select","encodings":{"fields":[{"parameterName":"top_n","queryName":"parameter_dashboards/01efde5dd4c51fc89e1caf2a86c344d7/datasets/01efde5dd4c615cd98f5bc2e8fab18b5_top_n"}]},"selection":{"defaultSelection":{"values":{"dataType":"STRING","values":[{"value":"all"}]}}},"frame":{"showTitle":true,"title":"Top N Number","showDescription":true,"description":"Optional filter ('all' or #)"}}},"position":{"x":5,"y":6,"width":1,"height":2}},{"widget":{"name":"5b94dd8d","queries":[{"name":"dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef015641455b4942decd4151ed3_warehouse_name","query":{"datasetName":"b6c55fed","fields":[{"name":"warehouse_name","expression":"`warehouse_name`"},{"name":"warehouse_name_associativity","expression":"COUNT_IF(`associative_filter_predicate_group`)"}],"disaggregated":false}},{"name":"parameter_dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef01564141b910a89950bda083e_warehouse_name","query":{"datasetName":"3e6fd95c","parameters":[{"name":"warehouse_name","keyword":"warehouse_name"}],"disaggregated":false}}],"spec":{"version":2,"widgetType":"filter-multi-select","encodings":{"fields":[{"fieldName":"warehouse_name","displayName":"warehouse_name","queryName":"dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef015641455b4942decd4151ed3_warehouse_name"},{"parameterName":"warehouse_name","queryName":"parameter_dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef01564141b910a89950bda083e_warehouse_name"}]},"frame":{"showTitle":true,"title":"Warehouse Name"}}},"position":{"x":3,"y":6,"width":1,"height":2}},{"widget":{"name":"e6de4fe7","queries":[{"name":"main_query","query":{"datasetName":"3e6fd95c","fields":[{"name":"sum(query_attributed_dollars_with_discount)","expression":"SUM(`query_attributed_dollars_with_discount`)"},{"name":"countdistinct(statement_id)","expression":"COUNT(DISTINCT `statement_id`)"},{"name":"sum(query_attributed_dbus_estimation)","expression":"SUM(`query_attributed_dbus_estimation`)"},{"name":"query_source_type","expression":"`query_source_type`"}],"disaggregated":false}}],"spec":{"version":3,"widgetType":"bar","encodings":{"x":{"fieldName":"sum(query_attributed_dollars_with_discount)","scale":{"type":"quantitative","reverse":false},"format":{"type":"number-currency","currencyCode":"USD","abbreviation":"compact","decimalPlaces":{"type":"max","places":2}},"displayName":"Attributed Usage ($)"},"y":{"fieldName":"query_source_type","scale":{"type":"categorical","sort":{"by":"x-reversed"}},"displayName":"Source Type"},"color":{"fieldName":"sum(query_attributed_dollars_with_discount)","scale":{"type":"quantitative","colorRamp":{"mode":"scheme","scheme":"greenblue"}},"legend":{"hide":true},"displayName":"Attributed Usage ($)"},"label":{"show":true},"extra":[{"fieldName":"countdistinct(statement_id)","displayName":"Query Count"},{"fieldName":"sum(query_attributed_dbus_estimation)","format":{"type":"number-plain","abbreviation":"compact","decimalPlaces":{"type":"max","places":2}},"displayName":"Attributed Usage (DBUs)"}]},"frame":{"showTitle":true,"title":"Cost By Source Type"},"mark":{"colors":["#00A972","#FFAB00","#00A972","#FF3621","#8BCAE7","#AB4057","#99DDB4","#FCA4A1","#919191","#BF7080"]}}},"position":{"x":2,"y":13,"width":2,"height":8}},{"widget":{"name":"e43bcbfd","queries":[{"name":"main_query","query":{"datasetName":"3e6fd95c","fields":[{"name":"sum(query_attributed_dollars_with_discount)","expression":"SUM(`query_attributed_dollars_with_discount`)"},{"name":"sum(query_attributed_dbus_estimation)","expression":"SUM(`query_attributed_dbus_estimation`)"},{"name":"count(statement_id)","expression":"COUNT(`statement_id`)"},{"name":"query_source_id","expression":"`query_source_id`"}],"disaggregated":false}}],"spec":{"version":3,"widgetType":"bar","encodings":{"x":{"fieldName":"sum(query_attributed_dollars_with_discount)","scale":{"type":"quantitative","reverse":false},"format":{"type":"number-currency","currencyCode":"USD","abbreviation":"none","decimalPlaces":{"type":"max","places":2}},"displayName":"Attributed Usage ($)"},"y":{"fieldName":"query_source_id","scale":{"type":"categorical","sort":{"by":"x-reversed"}},"axis":{"title":"Object Id"},"displayName":"Source Object Id"},"color":{"fieldName":"sum(query_attributed_dollars_with_discount)","scale":{"type":"quantitative","colorRamp":{"mode":"scheme","scheme":"greenblue"}},"legend":{"hide":true},"displayName":"Source Object Id"},"label":{"show":true},"extra":[{"fieldName":"sum(query_attributed_dbus_estimation)","format":{"type":"number-plain","abbreviation":"none","decimalPlaces":{"type":"max","places":2}},"displayName":"Attributed Usage (DBUs)"},{"fieldName":"count(statement_id)","displayName":"Query Count"}]},"frame":{"showTitle":true,"title":"Cost By Source Object Id"},"mark":{"colors":["#00A972","#FFAB00","#00A972","#FF3621","#8BCAE7","#AB4057","#99DDB4","#FCA4A1","#919191","#BF7080"]}}},"position":{"x":4,"y":13,"width":2,"height":8}},{"widget":{"name":"03009168","queries":[{"name":"dashboards/01efdcd2775e1c1a8a1866858634977b/datasets/01efdcd2775e1f47ba886d022f892e0b_object_top_n_toggle","query":{"datasetName":"9dda0ef1","fields":[{"name":"object_top_n_toggle","expression":"`object_top_n_toggle`"},{"name":"object_top_n_toggle_associativity","expression":"COUNT_IF(`associative_filter_predicate_group`)"}],"disaggregated":false}},{"name":"parameter_dashboards/01efdcd2775e1c1a8a1866858634977b/datasets/01efdcd2775e1ed4903a87d29a6a6697_top_n_dimension","query":{"datasetName":"3e6fd95c","parameters":[{"name":"top_n_dimension","keyword":"top_n_dimension"}],"disaggregated":false}}],"spec":{"version":2,"widgetType":"filter-single-select","encodings":{"fields":[{"parameterName":"top_n_dimension","queryName":"parameter_dashboards/01efdcd2775e1c1a8a1866858634977b/datasets/01efdcd2775e1ed4903a87d29a6a6697_top_n_dimension"},{"fieldName":"object_top_n_toggle","displayName":"object_top_n_toggle","queryName":"dashboards/01efdcd2775e1c1a8a1866858634977b/datasets/01efdcd2775e1f47ba886d022f892e0b_object_top_n_toggle"}]},"frame":{"showTitle":true,"title":"Top N Dimension","showDescription":true,"description":"i.e. (top 10 users, queries, objects)"}}},"position":{"x":4,"y":6,"width":1,"height":2}},{"widget":{"name":"8d88ad2d","queries":[{"name":"main_query","query":{"datasetName":"3e6fd95c","fields":[{"name":"countdistinct(executed_by)","expression":"COUNT(DISTINCT `executed_by`)"}],"disaggregated":false}}],"spec":{"version":2,"widgetType":"counter","encodings":{"value":{"fieldName":"countdistinct(executed_by)","format":{"type":"number-plain","abbreviation":"none","decimalPlaces":{"type":"max","places":2}},"displayName":"Count of Unique executed_by"}},"frame":{"showTitle":true,"title":"User Count\n"}}},"position":{"x":2,"y":11,"width":2,"height":2}},{"widget":{"name":"f11a0fd2","queries":[{"name":"main_query","query":{"datasetName":"3e6fd95c","fields":[{"name":"countdistinct(query_source_id)","expression":"COUNT(DISTINCT `query_source_id`)"}],"disaggregated":false}}],"spec":{"version":2,"widgetType":"counter","encodings":{"value":{"fieldName":"countdistinct(query_source_id)","format":{"type":"number-plain","abbreviation":"none","decimalPlaces":{"type":"max","places":2}},"displayName":"Count of Unique query_source_id"}},"frame":{"showTitle":true,"title":"Object Id Count"}}},"position":{"x":4,"y":11,"width":2,"height":2}},{"widget":{"name":"b62fe468","queries":[{"name":"main_query","query":{"datasetName":"3e6fd95c","fields":[{"name":"sum(query_attributed_dbus_estimation)","expression":"SUM(`query_attributed_dbus_estimation`)"},{"name":"count(statement_id)","expression":"COUNT(`statement_id`)"},{"name":"time_agg_key","expression":"`time_agg_key`"},{"name":"sum(query_attributed_dollars_with_discount)","expression":"SUM(`query_attributed_dollars_with_discount`)"}],"disaggregated":false}}],"spec":{"version":3,"widgetType":"bar","encodings":{"x":{"fieldName":"time_agg_key","scale":{"type":"categorical"},"displayName":"Attributed Usage ($)"},"y":{"fieldName":"sum(query_attributed_dollars_with_discount)","scale":{"type":"quantitative"},"format":{"type":"number-currency","currencyCode":"USD","abbreviation":"none","decimalPlaces":{"type":"max","places":0}},"displayName":"Attributed Usage ($)"},"label":{"show":true},"extra":[{"fieldName":"sum(query_attributed_dbus_estimation)","format":{"type":"number-plain","abbreviation":"none","decimalPlaces":{"type":"max","places":2}},"displayName":"Attributed Usage (DBUs)"},{"fieldName":"count(statement_id)","displayName":"Query Count"}]},"frame":{"showTitle":true,"title":"Attributed Usage Cost Over Time"},"mark":{"colors":["#077A9D","#FFAB00","#00A972","#FF3621","#8BCAE7","#AB4057","#99DDB4","#FCA4A1","#919191","#BF7080"]}}},"position":{"x":0,"y":23,"width":6,"height":6}},{"widget":{"name":"e88b2e4a","queries":[{"name":"dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef01564146dbc0703226f411071_time_agg_toggle","query":{"datasetName":"773aca07","fields":[{"name":"time_agg_toggle","expression":"`time_agg_toggle`"},{"name":"time_agg_toggle_associativity","expression":"COUNT_IF(`associative_filter_predicate_group`)"}],"disaggregated":false}},{"name":"parameter_dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef01564141b910a89950bda083e_date_agg_level","query":{"datasetName":"3e6fd95c","parameters":[{"name":"date_agg_level","keyword":"date_agg_level"}],"disaggregated":false}}],"spec":{"version":2,"widgetType":"filter-single-select","encodings":{"fields":[{"parameterName":"date_agg_level","queryName":"parameter_dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef01564141b910a89950bda083e_date_agg_level"},{"fieldName":"time_agg_toggle","displayName":"time_agg_toggle","queryName":"dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef01564146dbc0703226f411071_time_agg_toggle"}]},"frame":{"showTitle":true,"title":"Time Series Unit"}}},"position":{"x":3,"y":21,"width":3,"height":2}},{"widget":{"name":"31832403","textbox_spec":"##### Time series of Attributed Usage of filtered data. Use the dropdown on the right to change time series unit. \n(Time series unit selection will only affect this chart)"},"position":{"x":0,"y":21,"width":3,"height":2}},{"widget":{"name":"8556eee0","textbox_spec":"###### Dashboard v1 2025.01.31\nReachout to jooho.yeo@databricks.com for any questions"},"position":{"x":0,"y":46,"width":2,"height":1}},{"widget":{"name":"7d70446e","textbox_spec":"# DBSQL Cost Dashboard\n-----\n\n### Sections\n- **Inputs** - (Mandatory) Choose Start Time and End Time. (Optional) - Can select specific workspaces, warehouses, users, query source types, or object ids (supported for DBX objects). \n 1. If you want to limit the results of the dashboard to top 10 users, you can specify using the \"Top N Dimension\" and \"Top N Number\" filters.\n 2. Top level counts are shown for reference as you apply different filters. \n- **Charts** - Attributed costs by 1) user 2) source type 3) object ids. If the chart is crowded, click and zoom into the chart, or use the \"Top N\" filters. Click on a bar to cross-filter across the dashboard (to select multiple filters or options, you will need to back to the inputs at the top) 4) is a time series of attributed usage ($) for the filtered down dataset. Time unit is configurable (daily, weekly, etc). \n 1. Charts can also be downloaded into a CSV file by clicking on the option on the top right corner).\n- **Statement Level Detail** - Attributed usage ($) at the individual SQL run level. \n 1. You can click on the statement id or query source id (\"object id\") links to manage \n-----"},"position":{"x":0,"y":0,"width":6,"height":5}},{"widget":{"name":"8ab66f09","textbox_spec":"## Inputs\n----"},"position":{"x":0,"y":5,"width":6,"height":1}},{"widget":{"name":"867434c1","queries":[{"name":"parameter_dashboards/01efde5dd4c51fc89e1caf2a86c344d7/datasets/01efde5dd4c615cd98f5bc2e8fab18b5_dbsql_discount","query":{"datasetName":"3e6fd95c","parameters":[{"name":"dbsql_discount","keyword":"dbsql_discount"}],"disaggregated":false}}],"spec":{"version":2,"widgetType":"filter-single-select","encodings":{"fields":[{"parameterName":"dbsql_discount","queryName":"parameter_dashboards/01efde5dd4c51fc89e1caf2a86c344d7/datasets/01efde5dd4c615cd98f5bc2e8fab18b5_dbsql_discount"}]},"frame":{"showTitle":true,"title":"DBSQL Discount (%)","showDescription":true,"description":"(i.e. 0.1 == 10% discount)"}}},"position":{"x":5,"y":8,"width":1,"height":2}}]}]} \ No newline at end of file +{"datasets":[{"name":"8d75d358","displayName":"binary_options","query":"SELECT option\nFROM (VALUES ('Yes'), ('No')) AS options(option)"},{"name":"3e6fd95c","displayName":"statement_level_allocation","query":"WITH warehouse_snapshot AS (\n SELECT warehouse_id,\n warehouse_name,\n workspace_id,\n account_id,\n change_time,\n delete_time,\n CASE WHEN delete_time IS NOT NULL THEN 'Deleted' ELSE 'Active' END AS is_deleted\n FROM system.compute.warehouses w\n WHERE\n -- workspace filter\n (array_contains(:workspace_id,w.workspace_id) OR array_contains(:workspace_id,'all'))\n -- warehouse filter\n AND (array_contains(:warehouse_name, CONCAT(w.warehouse_name, ' (id:', w.warehouse_id, ')')) OR array_contains(:warehouse_name,'all'))\n QUALIFY ROW_NUMBER() OVER (PARTITION BY workspace_id, warehouse_id ORDER BY change_time DESC) == 1 -- Get more recent snapshot\n),\n\nroot_table AS (\n SELECT * \n FROM main.default.dbsql_cost_per_query AS qq\n WHERE\n query_attributed_dollars_estimation IS NOT NULL\n -- workspace filter\n AND (array_contains(:workspace_id,qq.workspace_id) OR array_contains(:workspace_id,'all'))\n -- warehouse filter\n AND (array_contains(:warehouse_id,qq.warehouse_id) OR array_contains(:warehouse_id,'all'))\n -- time filter (based on query start time)\n AND query_start_hour BETWEEN CAST(:time_range.min AS TIMESTAMP) AND CAST(:time_range.max AS TIMESTAMP) -- for good pruning\n -- statement_id filter - optional\n AND (array_contains(:statement_id,qq.statement_id) OR array_contains(:statement_id,'all')) -- optional statement id filter\n),\n\ntop_n_filter AS (\n SELECT \n IDENTIFIER(CASE \n WHEN :top_n_dimension = 'Executed By' THEN 'executed_by'\n WHEN :top_n_dimension = 'Source Type' THEN 'query_source_type'\n WHEN :top_n_dimension = 'Object Id' THEN 'query_source_id'\n WHEN :top_n_dimension = 'Statement Id' THEN 'statement_id'\n ELSE 'statement_id'\n END) AS rank_key,\n ROW_NUMBER() OVER (ORDER BY SUM(query_attributed_dollars_estimation) DESC) AS cost_rank\n FROM root_table AS qq\n GROUP BY\n IDENTIFIER(CASE \n WHEN :top_n_dimension = 'Executed By' THEN 'executed_by'\n WHEN :top_n_dimension = 'Source Type' THEN 'query_source_type'\n WHEN :top_n_dimension = 'Object Id' THEN 'query_source_id'\n WHEN :top_n_dimension = 'Statement Id' THEN 'statement_id'\n ELSE 'statement_id'\n END)\n),\n\nmv_model AS (\n\n SELECT qq.*,\n CONCAT(w.warehouse_name, ' (id:', w.warehouse_id, ')') AS warehouse_name ,\n w.is_deleted AS is_warehouse_deleted,\n query_attributed_dollars_estimation * (1 - CAST(:dbsql_discount AS FLOAT)) AS query_attributed_dollars_with_discount,\n --ROW_NUMBER() OVER (PARTITION BY CASE WHEN :ORDER BY QueryAllocationDollars DESC) AS CostRank\n tn.cost_rank\n FROM root_table AS qq\n INNER JOIN warehouse_snapshot w ON qq.workspace_id = w.workspace_id AND qq.warehouse_id = w.warehouse_id\n LEFT JOIN top_n_filter AS tn ON IDENTIFIER(CASE \n WHEN :top_n_dimension = 'Executed By' THEN 'qq.executed_by'\n WHEN :top_n_dimension = 'Source Type' THEN 'qq.query_source_type'\n WHEN :top_n_dimension = 'Object Id' THEN 'qq.query_source_id'\n WHEN :top_n_dimension = 'Statement Id' THEN 'qq.statement_id'\n ELSE 'statement_id'\n END) = tn.rank_key\n)\n\nSELECT\n mv.*,\n CASE WHEN :group_key = 'Warehouse Id' THEN mv.warehouse_id\n WHEN :group_key = 'Warehouse Name' THEN mv.warehouse_name\n WHEN :group_key = 'User' THEN mv.executed_by\n WHEN :group_key = 'Source Type' THEN mv.query_source_type\n WHEN :group_key = 'Obect Id' THEN mv.query_source_id\n WHEN :group_key = 'Client' THEN mv.client_application\n WHEN :group_key = 'Workspace Id' THEN mv.workspace_id\n END AS group_key,\n CASE WHEN :date_agg_level = 'HOUR' THEN \n date_trunc(:date_agg_level, mv.start_time)::timestamp::string\n ELSE date_trunc(:date_agg_level, mv.start_time)::date::string\n END AS time_agg_key,\n -- Data formatting for visuals\n MAX(query_attributed_dollars_with_discount) OVER() AS fully_loaded_max_usage,\n MIN(query_attributed_dollars_with_discount) OVER() AS fully_loaded_min_usage,\n COALESCE(CONCAT(\n '
',\n '
',\n '$',\n FORMAT_NUMBER(query_attributed_dollars_with_discount, 2), \n '
'\n ), '--') AS allocated_dollars_usage_bar_html,\n-- Data formatting for visuals\n MAX(query_attributed_dbus_estimation) OVER() AS fully_loaded_max_usage_dbus,\n MIN(query_attributed_dbus_estimation) OVER() AS fully_loaded_min_usage_dbus,\n COALESCE(CONCAT(\n '
',\n '
',\n '$',\n FORMAT_NUMBER(query_attributed_dbus_estimation, 2), \n '
'\n ), '--') AS allocated_dbus_usage_bar_html\nFROM mv_model AS mv\nWHERE\n(lower(:top_n)::string = 'all' OR cost_rank <= try_cast(:top_n AS int)) -- There can be ties, so we will also do a limit\nORDER BY cost_rank, query_attributed_dollars_with_discount DESC","parameters":[{"displayName":"statement_id","keyword":"statement_id","dataType":"STRING","complexType":"MULTI","defaultSelection":{"values":{"dataType":"STRING","values":[{"value":"all"}]}}},{"displayName":"workspace_id","keyword":"workspace_id","dataType":"STRING","complexType":"MULTI","defaultSelection":{"values":{"dataType":"STRING","values":[{"value":"all"}]}}},{"displayName":"warehouse_id","keyword":"warehouse_id","dataType":"STRING","complexType":"MULTI","defaultSelection":{"values":{"dataType":"STRING","values":[{"value":"all"}]}}},{"displayName":"warehouse_name","keyword":"warehouse_name","dataType":"STRING","complexType":"MULTI","defaultSelection":{"values":{"dataType":"STRING","values":[{"value":"all"}]}}},{"displayName":"top_n_dimension","keyword":"top_n_dimension","dataType":"STRING","defaultSelection":{"values":{"dataType":"STRING","values":[{"value":"Executed By"}]}}},{"displayName":"dbsql_discount","keyword":"dbsql_discount","dataType":"STRING","defaultSelection":{"values":{"dataType":"STRING","values":[{"value":"0.0"}]}}},{"displayName":"group_key","keyword":"group_key","dataType":"STRING","defaultSelection":{"values":{"dataType":"STRING","values":[{"value":"User"}]}}},{"displayName":"date_agg_level","keyword":"date_agg_level","dataType":"STRING","defaultSelection":{"values":{"dataType":"STRING","values":[{"value":"DAY"}]}}},{"displayName":"top_n","keyword":"top_n","dataType":"STRING","defaultSelection":{"values":{"dataType":"STRING","values":[{"value":"all"}]}}},{"displayName":"time_range","keyword":"time_range","dataType":"DATETIME","complexType":"RANGE","defaultSelection":{"range":{"dataType":"DATETIME","min":{"value":"now-7d/d"},"max":{"value":"now-1d/d"}}}}]},{"name":"b6c55fed","displayName":"workspace_with_all","query":" WITH billing AS (\n SELECT workspace_id, usage_metadata.warehouse_id AS warehouse_id\n FROM system.billing.usage u\n WHERE usage_start_time BETWEEN date_trunc('hour', :start_time) AND :end_time\n AND usage_metadata.warehouse_id IS NOT NULL\n GROUP BY 1,2\n )\n -- Get warehouse names (most recent change record) for warehouses with usage in selected period\n SELECT w.workspace_id, w.warehouse_id, CONCAT(w.warehouse_name, ' (id:', w.warehouse_id, ')') AS warehouse_name\n FROM billing AS b\n JOIN system.compute.warehouses w ON b.workspace_id = w.workspace_id AND w.warehouse_id = b.warehouse_id\n QUALIFY ROW_NUMBER() OVER(PARTITION BY w.workspace_id, w.warehouse_id ORDER BY w.change_time DESC) == 1","parameters":[{"displayName":"start_time","keyword":"start_time","dataType":"DATETIME","defaultSelection":{"values":{"dataType":"DATETIME","values":[{"value":"2024-12-04T15:45:12.000"}]}}},{"displayName":"end_time","keyword":"end_time","dataType":"DATETIME","defaultSelection":{"values":{"dataType":"DATETIME","values":[{"value":"now-1m/m"}]}}}]},{"name":"773aca07","displayName":"select_time_agg","query":"SELECT explode(array('YEAR', 'QUARTER', 'MONTH', 'WEEK', 'DAY', 'HOUR')) AS time_agg_toggle"},{"name":"706e050f","displayName":"select_dynamic_group_key_toggle","query":"SELECT explode(array('User', 'Warehouse Id', 'Warehouse Name', 'Object Id', 'Source Type', 'Workspace Id')) AS group_key\n"},{"name":"9dda0ef1","displayName":"select_top_n_dim","query":"SELECT explode(array('Executed By', 'Source Type', 'Object Id', 'Statement Id')) AS object_top_n_toggle"}],"pages":[{"name":"3972306b","displayName":"Query Cost Overview","layout":[{"widget":{"name":"1274573c","queries":[{"name":"parameter_dashboards/01efe31383761e08922514c212352d5f/datasets/01efe313837718f795a9ec18ab63ad3c_time_range","query":{"datasetName":"3e6fd95c","parameters":[{"name":"time_range","keyword":"time_range"}],"disaggregated":false}}],"spec":{"version":2,"widgetType":"filter-date-range-picker","encodings":{"fields":[{"parameterName":"time_range","queryName":"parameter_dashboards/01efe31383761e08922514c212352d5f/datasets/01efe313837718f795a9ec18ab63ad3c_time_range"}]},"frame":{"showTitle":true,"title":"Time Range"}}},"position":{"x":0,"y":6,"width":2,"height":2}},{"widget":{"name":"029aeeb6","queries":[{"name":"dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef015641455b4942decd4151ed3_workspace_id","query":{"datasetName":"b6c55fed","fields":[{"name":"workspace_id","expression":"`workspace_id`"},{"name":"workspace_id_associativity","expression":"COUNT_IF(`associative_filter_predicate_group`)"}],"disaggregated":false}},{"name":"parameter_dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef01564141b910a89950bda083e_workspace_id","query":{"datasetName":"3e6fd95c","parameters":[{"name":"workspace_id","keyword":"workspace_id"}],"disaggregated":false}}],"spec":{"version":2,"widgetType":"filter-multi-select","encodings":{"fields":[{"parameterName":"workspace_id","queryName":"parameter_dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef01564141b910a89950bda083e_workspace_id"},{"fieldName":"workspace_id","displayName":"workspace_id","queryName":"dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef015641455b4942decd4151ed3_workspace_id"}]},"frame":{"showTitle":true,"title":"Workspace Id"}}},"position":{"x":2,"y":6,"width":1,"height":2}},{"widget":{"name":"8ad3de2b","queries":[{"name":"main_query","query":{"datasetName":"3e6fd95c","fields":[{"name":"sum(query_attributed_dollars_with_discount)","expression":"SUM(`query_attributed_dollars_with_discount`)"},{"name":"sum(query_attributed_dbus_estimation)","expression":"SUM(`query_attributed_dbus_estimation`)"},{"name":"countdistinct(statement_id)","expression":"COUNT(DISTINCT `statement_id`)"},{"name":"executed_by","expression":"`executed_by`"}],"disaggregated":false}}],"spec":{"version":3,"widgetType":"bar","encodings":{"x":{"fieldName":"sum(query_attributed_dollars_with_discount)","scale":{"type":"quantitative","reverse":false},"format":{"type":"number-currency","currencyCode":"USD","abbreviation":"none","decimalPlaces":{"type":"max","places":2}},"displayName":"Attributed Usage ($)"},"y":{"fieldName":"executed_by","scale":{"type":"categorical","sort":{"by":"x-reversed"}},"axis":{"title":"User"},"displayName":"Group Key"},"color":{"fieldName":"sum(query_attributed_dollars_with_discount)","scale":{"type":"quantitative","colorRamp":{"mode":"scheme","scheme":"greenblue"}},"legend":{"hide":true},"displayName":"Attributed Usage ($)"},"label":{"show":true},"extra":[{"fieldName":"sum(query_attributed_dbus_estimation)","format":{"type":"number-plain","abbreviation":"none","decimalPlaces":{"type":"max","places":2}},"displayName":"Attributed Usage (DBUs)"},{"fieldName":"countdistinct(statement_id)","displayName":"Query Count"}]},"frame":{"showTitle":true,"title":"Cost By User"},"mark":{"colors":["#00A972","#FFAB00","#00A972","#FF3621","#8BCAE7","#AB4057","#99DDB4","#FCA4A1","#919191","#BF7080"]}}},"position":{"x":0,"y":13,"width":2,"height":8}},{"widget":{"name":"b034a298","queries":[{"name":"dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef01564141b910a89950bda083e_executed_by","query":{"datasetName":"3e6fd95c","fields":[{"name":"executed_by","expression":"`executed_by`"},{"name":"executed_by_associativity","expression":"COUNT_IF(`associative_filter_predicate_group`)"}],"disaggregated":false}}],"spec":{"version":2,"widgetType":"filter-multi-select","encodings":{"fields":[{"fieldName":"executed_by","displayName":"executed_by","queryName":"dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef01564141b910a89950bda083e_executed_by"}]},"frame":{"showTitle":true,"title":"User","showDescription":true,"description":"User or service principal running the statement"}}},"position":{"x":0,"y":8,"width":2,"height":2}},{"widget":{"name":"09a2a1f3","queries":[{"name":"dashboards/01efdcd2775e1c1a8a1866858634977b/datasets/01efdcd2775e1ed4903a87d29a6a6697_query_source_type","query":{"datasetName":"3e6fd95c","fields":[{"name":"query_source_type","expression":"`query_source_type`"},{"name":"query_source_type_associativity","expression":"COUNT_IF(`associative_filter_predicate_group`)"}],"disaggregated":false}}],"spec":{"version":2,"widgetType":"filter-multi-select","encodings":{"fields":[{"fieldName":"query_source_type","displayName":"query_source_type","queryName":"dashboards/01efdcd2775e1c1a8a1866858634977b/datasets/01efdcd2775e1ed4903a87d29a6a6697_query_source_type"}]},"frame":{"showTitle":true,"title":"Query Source Type","showDescription":true,"description":"Type of Object (i.e dashboard, SQL Query, JOB, notebook)"}}},"position":{"x":2,"y":8,"width":1,"height":2}},{"widget":{"name":"f80f81da","queries":[{"name":"dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef01564141b910a89950bda083e_query_source_id","query":{"datasetName":"3e6fd95c","fields":[{"name":"query_source_id","expression":"`query_source_id`"},{"name":"query_source_id_associativity","expression":"COUNT_IF(`associative_filter_predicate_group`)"}],"disaggregated":false}}],"spec":{"version":2,"widgetType":"filter-multi-select","encodings":{"fields":[{"fieldName":"query_source_id","displayName":"query_source_id","queryName":"dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef01564141b910a89950bda083e_query_source_id"}]},"frame":{"showTitle":true,"title":"Query Source Id","showDescription":true,"description":"Id of object such as a dashboard, SQL query, job, etc."}}},"position":{"x":3,"y":8,"width":2,"height":2}},{"widget":{"name":"8925bd62","textbox_spec":"## Charts\n----"},"position":{"x":0,"y":10,"width":6,"height":1}},{"widget":{"name":"af6d1285","textbox_spec":"## Statement Level Detail\n----"},"position":{"x":0,"y":29,"width":6,"height":1}},{"widget":{"name":"f1e3bb79","queries":[{"name":"main_query","query":{"datasetName":"3e6fd95c","fields":[{"name":"statement_id","expression":"`statement_id`"},{"name":"statement_text","expression":"`statement_text`"},{"name":"allocated_dollars_usage_bar_html","expression":"`allocated_dollars_usage_bar_html`"},{"name":"executed_by","expression":"`executed_by`"},{"name":"warehouse_name","expression":"`warehouse_name`"},{"name":"duration_seconds","expression":"`duration_seconds`"},{"name":"query_work_duration_seconds","expression":"`query_work_duration_seconds`"},{"name":"start_time","expression":"`start_time`"},{"name":"end_time","expression":"`end_time`"},{"name":"query_work_start_time","expression":"`query_work_start_time`"},{"name":"query_work_end_time","expression":"`query_work_end_time`"},{"name":"query_source_type","expression":"`query_source_type`"},{"name":"query_source_id","expression":"`query_source_id`"},{"name":"client_application","expression":"`client_application`"},{"name":"workspace_id","expression":"`workspace_id`"},{"name":"query_attributed_dollars_with_discount","expression":"`query_attributed_dollars_with_discount`"},{"name":"query_attributed_dbus_estimation","expression":"`query_attributed_dbus_estimation`"},{"name":"query_attributed_dollars_estimation","expression":"`query_attributed_dollars_estimation`"},{"name":"statement_hour_bucket_costs","expression":"`statement_hour_bucket_costs`"},{"name":"query_profile_url","expression":"`query_profile_url`"},{"name":"url_helper","expression":"`url_helper`"}],"disaggregated":true}}],"spec":{"version":1,"widgetType":"table","encodings":{"columns":[{"fieldName":"statement_id","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ query_profile_url }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"string","displayAs":"link","visible":true,"order":0,"title":"Statement Id (link to query profile)","allowSearch":true,"alignContent":"left","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"cellFormat":{"default":{"foregroundColor":"#077A9D"},"rules":[]},"displayName":"statement_id"},{"fieldName":"statement_text","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"string","displayAs":"string","visible":true,"order":1,"title":"Query Text","allowSearch":false,"alignContent":"left","allowHTML":true,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"defaultColumnWidth":300,"description":"Raw text of the statement query that was executed","displayName":"statement_text"},{"fieldName":"allocated_dollars_usage_bar_html","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"string","displayAs":"string","visible":true,"order":2,"title":"Attributed Usage ($)","allowSearch":false,"alignContent":"left","allowHTML":true,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"defaultColumnWidth":200,"description":"Allocated dollars for attributed query (this is an estimate based on query work)","displayName":"allocated_dollars_usage_bar_html"},{"fieldName":"executed_by","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"string","displayAs":"string","visible":true,"order":4,"title":"Executed by","allowSearch":false,"alignContent":"left","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"displayName":"executed_by"},{"fieldName":"warehouse_name","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"string","displayAs":"string","visible":true,"order":6,"title":"Warehouse","allowSearch":true,"alignContent":"left","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"description":"Current name of the warehouse it was run on (warehouse ids are permanent but names are not)","displayName":"warehouse_name"},{"fieldName":"duration_seconds","numberFormat":"0.00","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"float","displayAs":"number","visible":true,"order":7,"title":"Query Duration (s)","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"description":"Runtime of the query in seconds","cellFormat":{"default":{"foregroundColor":"#077A9D"},"rules":[]},"displayName":"duration_seconds"},{"fieldName":"query_work_duration_seconds","numberFormat":"0.00","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"float","displayAs":"number","visible":true,"order":8,"title":"Work Duration (s)","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"description":"Amount of seconds query spent doing work (execution + result fetch)","displayName":"query_work_duration_seconds"},{"fieldName":"start_time","dateTimeFormat":"YYYY-MM-DD HH:mm:ss.SSS","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"datetime","displayAs":"datetime","visible":true,"order":10,"title":"Start Time","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"displayName":"start_time"},{"fieldName":"end_time","dateTimeFormat":"YYYY-MM-DD HH:mm:ss.SSS","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"datetime","displayAs":"datetime","visible":true,"order":11,"title":"End Time","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"displayName":"end_time"},{"fieldName":"query_work_start_time","dateTimeFormat":"YYYY-MM-DD HH:mm:ss.SSS","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"datetime","displayAs":"datetime","visible":true,"order":12,"title":"Work Start Time","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"description":"Start time query began doing work (executing) - can be greater than start_time if it waits in the queue","displayName":"query_work_start_time"},{"fieldName":"query_work_end_time","dateTimeFormat":"YYYY-MM-DD HH:mm:ss.SSS","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"datetime","displayAs":"datetime","visible":true,"order":13,"title":"Work End Time","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"description":"Time when query finishes work. This can be greater than end_time because it includes time spent returning results. ","displayName":"query_work_end_time"},{"fieldName":"query_source_type","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"string","displayAs":"string","visible":true,"order":14,"title":"Query Source Type","allowSearch":false,"alignContent":"left","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"description":"Databricks internal asset source type (i.e. dashboard, notebook, job, etc.)","displayName":"query_source_type"},{"fieldName":"query_source_id","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ url_helper }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"string","displayAs":"link","visible":true,"order":15,"title":"Query Source Id","allowSearch":false,"alignContent":"left","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"description":"Id of the asset type (i.e. if source type = 'JOB' then this will be the job id that ran the query)","displayName":"query_source_id"},{"fieldName":"client_application","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"string","displayAs":"string","visible":true,"order":16,"title":"Client App","allowSearch":false,"alignContent":"left","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"description":"External registered client name (like DBSQL Dashboards, Power BI, Fivetran, etc.)","displayName":"client_application"},{"fieldName":"workspace_id","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"string","displayAs":"string","visible":true,"order":17,"title":"Workspace Id","allowSearch":false,"alignContent":"left","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"displayName":"workspace_id"},{"fieldName":"query_attributed_dollars_with_discount","numberFormat":"$ 0.00","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"float","displayAs":"number","visible":true,"order":18,"title":"Attributed Usage ($) - Discount","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"description":"Estimated query attributed costs with discount param included","cellFormat":{"default":{"foregroundColor":"#00A972"},"rules":[]},"displayName":"query_attributed_dollars_with_discount"},{"fieldName":"query_attributed_dbus_estimation","numberFormat":"0.00","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"float","displayAs":"number","visible":true,"order":19,"title":"Attributed Usage (DBUs)","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"description":"Estimated query attributed dbu usage","cellFormat":{"default":{"foregroundColor":"#077A9D"},"rules":[]},"displayName":"query_attributed_dbus_estimation"},{"fieldName":"query_attributed_dollars_estimation","numberFormat":"0.00","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"float","displayAs":"number","visible":true,"order":20,"title":"Attributed Usage ($) - List","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"description":"Estimated query attributed cost at list rate","displayName":"query_attributed_dollars_estimation"},{"fieldName":"statement_hour_bucket_costs","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"type":"complex","displayAs":"json","visible":true,"order":31,"title":"Query Cost Hourly Breakdown","allowSearch":false,"alignContent":"left","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"description":"If queries span multiple hours, the costs are allocated on an hourly basis, so a total query costs can span multiple hours. This shows what % of the cost is allocated to which hour for that warehouse","displayName":"statement_hour_bucket_costs"}]},"invisibleColumns":[{"booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"allocated_dbus_usage_bar_html","type":"string","displayAs":"string","order":3,"title":"Allocated DBUs","allowSearch":false,"alignContent":"left","allowHTML":true,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"defaultColumnWidth":200},{"booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"warehouse_id","type":"string","displayAs":"string","order":5,"title":"Warehouse Id","allowSearch":false,"alignContent":"left","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false},{"numberFormat":"0.00","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"query_work_task_time_seconds","type":"float","displayAs":"number","order":9,"title":"Query Task Time (s)","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false,"description":"The total executor task time used by the query","cellFormat":{"default":{"foregroundColor":"#077A9D"},"rules":[]}},{"booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"url_helper","type":"string","displayAs":"string","order":21,"title":"url_helper","allowSearch":false,"alignContent":"left","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false},{"booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"query_profile_url","type":"string","displayAs":"string","order":22,"title":"query_profile_url","allowSearch":false,"alignContent":"left","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false},{"dateTimeFormat":"YYYY-MM-DD HH:mm:ss.SSS","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"most_recent_billing_hour","type":"datetime","displayAs":"datetime","order":23,"title":"most_recent_billing_hour","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false},{"booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"billing_record_check","type":"string","displayAs":"string","order":24,"title":"billing_record_check","allowSearch":false,"alignContent":"left","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false},{"numberFormat":"0.00","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"fully_loaded_max_usage","type":"float","displayAs":"number","order":25,"title":"fully_loaded_max_usage","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false},{"numberFormat":"0.00","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"fully_loaded_min_usage","type":"float","displayAs":"number","order":26,"title":"fully_loaded_min_usage","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false},{"numberFormat":"0.00","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"fully_loaded_max_usage_dbus","type":"float","displayAs":"number","order":27,"title":"fully_loaded_max_usage_dbus","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false},{"numberFormat":"0.00","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"fully_loaded_min_usage_dbus","type":"float","displayAs":"number","order":28,"title":"fully_loaded_min_usage_dbus","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false},{"booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"group_key","type":"string","displayAs":"string","order":29,"title":"group_key","allowSearch":false,"alignContent":"left","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false},{"dateTimeFormat":"YYYY-MM-DD HH:mm:ss.SSS","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"time_agg_key","type":"string","displayAs":"datetime","order":30,"title":"time_agg_key","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false},{"dateTimeFormat":"YYYY-MM-DD HH:mm:ss.SSS","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"query_start_hour","type":"datetime","displayAs":"datetime","order":32,"title":"query_start_hour","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false},{"booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"is_warehouse_deleted","type":"string","displayAs":"string","order":33,"title":"is_warehouse_deleted","allowSearch":false,"alignContent":"left","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false},{"numberFormat":"0","booleanValues":["false","true"],"imageUrlTemplate":"{{ @ }}","imageTitleTemplate":"{{ @ }}","imageWidth":"","imageHeight":"","linkUrlTemplate":"{{ @ }}","linkTextTemplate":"{{ @ }}","linkTitleTemplate":"{{ @ }}","linkOpenInNewTab":true,"name":"cost_rank","type":"integer","displayAs":"number","order":34,"title":"cost_rank","allowSearch":false,"alignContent":"right","allowHTML":false,"highlightLinks":false,"useMonospaceFont":false,"preserveWhitespace":false}],"allowHTMLByDefault":false,"itemsPerPage":25,"paginationSize":"default","condensed":true,"withRowNumber":true,"frame":{"showTitle":true,"title":"Query Statement Detail"}}},"position":{"x":0,"y":30,"width":6,"height":16}},{"widget":{"name":"3fd47cc4","queries":[{"name":"main_query","query":{"datasetName":"3e6fd95c","fields":[{"name":"countdistinct(statement_id)","expression":"COUNT(DISTINCT `statement_id`)"}],"disaggregated":false}}],"spec":{"version":2,"widgetType":"counter","encodings":{"value":{"fieldName":"countdistinct(statement_id)","format":{"type":"number-plain","abbreviation":"none","decimalPlaces":{"type":"max","places":2}},"displayName":"Count of Unique statement_id"}},"frame":{"showTitle":true,"title":"Query Statement Count"}}},"position":{"x":0,"y":11,"width":2,"height":2}},{"widget":{"name":"37fa2ea4","queries":[{"name":"parameter_dashboards/01efde5dd4c51fc89e1caf2a86c344d7/datasets/01efde5dd4c615cd98f5bc2e8fab18b5_top_n","query":{"datasetName":"3e6fd95c","parameters":[{"name":"top_n","keyword":"top_n"}],"disaggregated":false}}],"spec":{"version":2,"widgetType":"filter-single-select","encodings":{"fields":[{"parameterName":"top_n","queryName":"parameter_dashboards/01efde5dd4c51fc89e1caf2a86c344d7/datasets/01efde5dd4c615cd98f5bc2e8fab18b5_top_n"}]},"selection":{"defaultSelection":{"values":{"dataType":"STRING","values":[{"value":"all"}]}}},"frame":{"showTitle":true,"title":"Top N Number","showDescription":true,"description":"Optional filter ('all' or #)"}}},"position":{"x":5,"y":6,"width":1,"height":2}},{"widget":{"name":"5b94dd8d","queries":[{"name":"dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef015641455b4942decd4151ed3_warehouse_name","query":{"datasetName":"b6c55fed","fields":[{"name":"warehouse_name","expression":"`warehouse_name`"},{"name":"warehouse_name_associativity","expression":"COUNT_IF(`associative_filter_predicate_group`)"}],"disaggregated":false}},{"name":"parameter_dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef01564141b910a89950bda083e_warehouse_name","query":{"datasetName":"3e6fd95c","parameters":[{"name":"warehouse_name","keyword":"warehouse_name"}],"disaggregated":false}}],"spec":{"version":2,"widgetType":"filter-multi-select","encodings":{"fields":[{"fieldName":"warehouse_name","displayName":"warehouse_name","queryName":"dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef015641455b4942decd4151ed3_warehouse_name"},{"parameterName":"warehouse_name","queryName":"parameter_dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef01564141b910a89950bda083e_warehouse_name"}]},"frame":{"showTitle":true,"title":"Warehouse Name"}}},"position":{"x":3,"y":6,"width":1,"height":2}},{"widget":{"name":"e6de4fe7","queries":[{"name":"main_query","query":{"datasetName":"3e6fd95c","fields":[{"name":"sum(query_attributed_dollars_with_discount)","expression":"SUM(`query_attributed_dollars_with_discount`)"},{"name":"countdistinct(statement_id)","expression":"COUNT(DISTINCT `statement_id`)"},{"name":"sum(query_attributed_dbus_estimation)","expression":"SUM(`query_attributed_dbus_estimation`)"},{"name":"query_source_type","expression":"`query_source_type`"}],"disaggregated":false}}],"spec":{"version":3,"widgetType":"bar","encodings":{"x":{"fieldName":"sum(query_attributed_dollars_with_discount)","scale":{"type":"quantitative","reverse":false},"format":{"type":"number-currency","currencyCode":"USD","abbreviation":"compact","decimalPlaces":{"type":"max","places":2}},"displayName":"Attributed Usage ($)"},"y":{"fieldName":"query_source_type","scale":{"type":"categorical","sort":{"by":"x-reversed"}},"displayName":"Source Type"},"color":{"fieldName":"sum(query_attributed_dollars_with_discount)","scale":{"type":"quantitative","colorRamp":{"mode":"scheme","scheme":"greenblue"}},"legend":{"hide":true},"displayName":"Attributed Usage ($)"},"label":{"show":true},"extra":[{"fieldName":"countdistinct(statement_id)","displayName":"Query Count"},{"fieldName":"sum(query_attributed_dbus_estimation)","format":{"type":"number-plain","abbreviation":"compact","decimalPlaces":{"type":"max","places":2}},"displayName":"Attributed Usage (DBUs)"}]},"frame":{"showTitle":true,"title":"Cost By Source Type"},"mark":{"colors":["#00A972","#FFAB00","#00A972","#FF3621","#8BCAE7","#AB4057","#99DDB4","#FCA4A1","#919191","#BF7080"]}}},"position":{"x":2,"y":13,"width":2,"height":8}},{"widget":{"name":"e43bcbfd","queries":[{"name":"main_query","query":{"datasetName":"3e6fd95c","fields":[{"name":"sum(query_attributed_dollars_with_discount)","expression":"SUM(`query_attributed_dollars_with_discount`)"},{"name":"sum(query_attributed_dbus_estimation)","expression":"SUM(`query_attributed_dbus_estimation`)"},{"name":"count(statement_id)","expression":"COUNT(`statement_id`)"},{"name":"query_source_id","expression":"`query_source_id`"}],"disaggregated":false}}],"spec":{"version":3,"widgetType":"bar","encodings":{"x":{"fieldName":"sum(query_attributed_dollars_with_discount)","scale":{"type":"quantitative","reverse":false},"format":{"type":"number-currency","currencyCode":"USD","abbreviation":"none","decimalPlaces":{"type":"max","places":2}},"displayName":"Attributed Usage ($)"},"y":{"fieldName":"query_source_id","scale":{"type":"categorical","sort":{"by":"x-reversed"}},"axis":{"title":"Object Id"},"displayName":"Source Object Id"},"color":{"fieldName":"sum(query_attributed_dollars_with_discount)","scale":{"type":"quantitative","colorRamp":{"mode":"scheme","scheme":"greenblue"}},"legend":{"hide":true},"displayName":"Source Object Id"},"label":{"show":true},"extra":[{"fieldName":"sum(query_attributed_dbus_estimation)","format":{"type":"number-plain","abbreviation":"none","decimalPlaces":{"type":"max","places":2}},"displayName":"Attributed Usage (DBUs)"},{"fieldName":"count(statement_id)","displayName":"Query Count"}]},"frame":{"showTitle":true,"title":"Cost By Source Object Id"},"mark":{"colors":["#00A972","#FFAB00","#00A972","#FF3621","#8BCAE7","#AB4057","#99DDB4","#FCA4A1","#919191","#BF7080"]}}},"position":{"x":4,"y":13,"width":2,"height":8}},{"widget":{"name":"03009168","queries":[{"name":"dashboards/01efdcd2775e1c1a8a1866858634977b/datasets/01efdcd2775e1f47ba886d022f892e0b_object_top_n_toggle","query":{"datasetName":"9dda0ef1","fields":[{"name":"object_top_n_toggle","expression":"`object_top_n_toggle`"},{"name":"object_top_n_toggle_associativity","expression":"COUNT_IF(`associative_filter_predicate_group`)"}],"disaggregated":false}},{"name":"parameter_dashboards/01efdcd2775e1c1a8a1866858634977b/datasets/01efdcd2775e1ed4903a87d29a6a6697_top_n_dimension","query":{"datasetName":"3e6fd95c","parameters":[{"name":"top_n_dimension","keyword":"top_n_dimension"}],"disaggregated":false}}],"spec":{"version":2,"widgetType":"filter-single-select","encodings":{"fields":[{"parameterName":"top_n_dimension","queryName":"parameter_dashboards/01efdcd2775e1c1a8a1866858634977b/datasets/01efdcd2775e1ed4903a87d29a6a6697_top_n_dimension"},{"fieldName":"object_top_n_toggle","displayName":"object_top_n_toggle","queryName":"dashboards/01efdcd2775e1c1a8a1866858634977b/datasets/01efdcd2775e1f47ba886d022f892e0b_object_top_n_toggle"}]},"frame":{"showTitle":true,"title":"Top N Dimension","showDescription":true,"description":"i.e. (top 10 users, queries, objects)"}}},"position":{"x":4,"y":6,"width":1,"height":2}},{"widget":{"name":"8d88ad2d","queries":[{"name":"main_query","query":{"datasetName":"3e6fd95c","fields":[{"name":"countdistinct(executed_by)","expression":"COUNT(DISTINCT `executed_by`)"}],"disaggregated":false}}],"spec":{"version":2,"widgetType":"counter","encodings":{"value":{"fieldName":"countdistinct(executed_by)","format":{"type":"number-plain","abbreviation":"none","decimalPlaces":{"type":"max","places":2}},"displayName":"Count of Unique executed_by"}},"frame":{"showTitle":true,"title":"User Count\n"}}},"position":{"x":2,"y":11,"width":2,"height":2}},{"widget":{"name":"f11a0fd2","queries":[{"name":"main_query","query":{"datasetName":"3e6fd95c","fields":[{"name":"countdistinct(query_source_id)","expression":"COUNT(DISTINCT `query_source_id`)"}],"disaggregated":false}}],"spec":{"version":2,"widgetType":"counter","encodings":{"value":{"fieldName":"countdistinct(query_source_id)","format":{"type":"number-plain","abbreviation":"none","decimalPlaces":{"type":"max","places":2}},"displayName":"Count of Unique query_source_id"}},"frame":{"showTitle":true,"title":"Object Id Count"}}},"position":{"x":4,"y":11,"width":2,"height":2}},{"widget":{"name":"b62fe468","queries":[{"name":"main_query","query":{"datasetName":"3e6fd95c","fields":[{"name":"sum(query_attributed_dbus_estimation)","expression":"SUM(`query_attributed_dbus_estimation`)"},{"name":"count(statement_id)","expression":"COUNT(`statement_id`)"},{"name":"time_agg_key","expression":"`time_agg_key`"},{"name":"sum(query_attributed_dollars_with_discount)","expression":"SUM(`query_attributed_dollars_with_discount`)"}],"disaggregated":false}}],"spec":{"version":3,"widgetType":"bar","encodings":{"x":{"fieldName":"time_agg_key","scale":{"type":"categorical"},"displayName":"Attributed Usage ($)"},"y":{"fieldName":"sum(query_attributed_dollars_with_discount)","scale":{"type":"quantitative"},"format":{"type":"number-currency","currencyCode":"USD","abbreviation":"none","decimalPlaces":{"type":"max","places":0}},"displayName":"Attributed Usage ($)"},"label":{"show":true},"extra":[{"fieldName":"sum(query_attributed_dbus_estimation)","format":{"type":"number-plain","abbreviation":"none","decimalPlaces":{"type":"max","places":2}},"displayName":"Attributed Usage (DBUs)"},{"fieldName":"count(statement_id)","displayName":"Query Count"}]},"frame":{"showTitle":true,"title":"Attributed Usage Cost Over Time"},"mark":{"colors":["#077A9D","#FFAB00","#00A972","#FF3621","#8BCAE7","#AB4057","#99DDB4","#FCA4A1","#919191","#BF7080"]}}},"position":{"x":0,"y":23,"width":6,"height":6}},{"widget":{"name":"e88b2e4a","queries":[{"name":"dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef01564146dbc0703226f411071_time_agg_toggle","query":{"datasetName":"773aca07","fields":[{"name":"time_agg_toggle","expression":"`time_agg_toggle`"},{"name":"time_agg_toggle_associativity","expression":"COUNT_IF(`associative_filter_predicate_group`)"}],"disaggregated":false}},{"name":"parameter_dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef01564141b910a89950bda083e_date_agg_level","query":{"datasetName":"3e6fd95c","parameters":[{"name":"date_agg_level","keyword":"date_agg_level"}],"disaggregated":false}}],"spec":{"version":2,"widgetType":"filter-single-select","encodings":{"fields":[{"parameterName":"date_agg_level","queryName":"parameter_dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef01564141b910a89950bda083e_date_agg_level"},{"fieldName":"time_agg_toggle","displayName":"time_agg_toggle","queryName":"dashboards/01efcef015641095b3b32a6af3499355/datasets/01efcef01564146dbc0703226f411071_time_agg_toggle"}]},"frame":{"showTitle":true,"title":"Time Series Unit"}}},"position":{"x":3,"y":21,"width":3,"height":2}},{"widget":{"name":"31832403","textbox_spec":"##### Time series of Attributed Usage of filtered data. Use the dropdown on the right to change time series unit. \n(Time series unit selection will only affect this chart)"},"position":{"x":0,"y":21,"width":3,"height":2}},{"widget":{"name":"8556eee0","textbox_spec":"###### Dashboard v1 2025.01.31\nReachout to jooho.yeo@databricks.com for any questions"},"position":{"x":0,"y":46,"width":2,"height":1}},{"widget":{"name":"7d70446e","textbox_spec":"# DBSQL Cost Dashboard\n-----\n\n### Sections\n- **Inputs** - (Mandatory) Choose Start Time and End Time. (Optional) - Can select specific workspaces, warehouses, users, query source types, or object ids (supported for DBX objects). \n 1. If you want to limit the results of the dashboard to top 10 users, you can specify using the \"Top N Dimension\" and \"Top N Number\" filters.\n 2. Top level counts are shown for reference as you apply different filters. \n- **Charts** - Attributed costs by 1) user 2) source type 3) object ids. If the chart is crowded, click and zoom into the chart, or use the \"Top N\" filters. Click on a bar to cross-filter across the dashboard (to select multiple filters or options, you will need to back to the inputs at the top) 4) is a time series of attributed usage ($) for the filtered down dataset. Time unit is configurable (daily, weekly, etc). \n 1. Charts can also be downloaded into a CSV file by clicking on the option on the top right corner).\n- **Statement Level Detail** - Attributed usage ($) at the individual SQL run level. \n 1. You can click on the statement id or query source id (\"object id\") links to manage \n-----"},"position":{"x":0,"y":0,"width":6,"height":5}},{"widget":{"name":"8ab66f09","textbox_spec":"## Inputs\n----"},"position":{"x":0,"y":5,"width":6,"height":1}},{"widget":{"name":"867434c1","queries":[{"name":"parameter_dashboards/01efde5dd4c51fc89e1caf2a86c344d7/datasets/01efde5dd4c615cd98f5bc2e8fab18b5_dbsql_discount","query":{"datasetName":"3e6fd95c","parameters":[{"name":"dbsql_discount","keyword":"dbsql_discount"}],"disaggregated":false}}],"spec":{"version":2,"widgetType":"filter-single-select","encodings":{"fields":[{"parameterName":"dbsql_discount","queryName":"parameter_dashboards/01efde5dd4c51fc89e1caf2a86c344d7/datasets/01efde5dd4c615cd98f5bc2e8fab18b5_dbsql_discount"}]},"frame":{"showTitle":true,"title":"DBSQL Discount (%)","showDescription":true,"description":"(i.e. 0.1 == 10% discount)"}}},"position":{"x":5,"y":8,"width":1,"height":2}}]}]} \ No newline at end of file diff --git a/dbsql_cost_per_query/PrPr/DBSQL Cost Per Query MV (PrPr).sql b/dbsql_cost_per_query/PrPr/DBSQL Cost Per Query MV (PrPr).sql index bde5be99..20348572 100644 --- a/dbsql_cost_per_query/PrPr/DBSQL Cost Per Query MV (PrPr).sql +++ b/dbsql_cost_per_query/PrPr/DBSQL Cost Per Query MV (PrPr).sql @@ -1,4 +1,3 @@ - CREATE OR REPLACE MATERIALIZED VIEW main.default.dbsql_cost_per_query (statement_id string, query_source_id string, @@ -270,10 +269,10 @@ SELECT COUNT(CASE WHEN utilization_flag = 'ON_IDLE' THEN second_chunk END) AS idle_seconds, COUNT(*) AS total_seconds, round( - CASE - WHEN COUNT(*) = 0 THEN 0 - ELSE COUNT(CASE WHEN utilization_flag = 'UTILIZED' THEN second_chunk END) / (COUNT(CASE WHEN utilization_flag = 'UTILIZED' THEN second_chunk END) + COUNT(CASE WHEN utilization_flag = 'ON_IDLE' THEN second_chunk END)) - END, + try_divide( + COUNT(CASE WHEN utilization_flag = 'UTILIZED' THEN second_chunk END), + (COUNT(CASE WHEN utilization_flag = 'UTILIZED' THEN second_chunk END) + COUNT(CASE WHEN utilization_flag = 'ON_IDLE' THEN second_chunk END)) + ), 2 ) AS utilization_proportion FROM state_by_second @@ -433,4 +432,4 @@ select LEFT JOIN cpq_warehouse_query_history AS qq ON qa.statement_id = qq.statement_id -- creating dups of the objects but just re-aggregating AND qa.warehouse_id = qq.warehouse_id GROUP BY qq.statement_id -) +) \ No newline at end of file From 1feb841738ed8f8f1e818a40e59c1649bfd2da32 Mon Sep 17 00:00:00 2001 From: Cody Austin Davis Date: Mon, 10 Feb 2025 09:35:42 -0800 Subject: [PATCH 3/4] PrPr Initial Commit --- .../cost_per_query}/PrPr/DBSQL Cost Dashboard (PrPr).lvdash.json | 0 .../cost_per_query}/PrPr/DBSQL Cost Per Query MV (PrPr).sql | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename {dbsql_cost_per_query => dbsql/cost_per_query}/PrPr/DBSQL Cost Dashboard (PrPr).lvdash.json (100%) rename {dbsql_cost_per_query => dbsql/cost_per_query}/PrPr/DBSQL Cost Per Query MV (PrPr).sql (100%) diff --git a/dbsql_cost_per_query/PrPr/DBSQL Cost Dashboard (PrPr).lvdash.json b/dbsql/cost_per_query/PrPr/DBSQL Cost Dashboard (PrPr).lvdash.json similarity index 100% rename from dbsql_cost_per_query/PrPr/DBSQL Cost Dashboard (PrPr).lvdash.json rename to dbsql/cost_per_query/PrPr/DBSQL Cost Dashboard (PrPr).lvdash.json diff --git a/dbsql_cost_per_query/PrPr/DBSQL Cost Per Query MV (PrPr).sql b/dbsql/cost_per_query/PrPr/DBSQL Cost Per Query MV (PrPr).sql similarity index 100% rename from dbsql_cost_per_query/PrPr/DBSQL Cost Per Query MV (PrPr).sql rename to dbsql/cost_per_query/PrPr/DBSQL Cost Per Query MV (PrPr).sql From 62381af11e8fc928764b15b01fbe63566807e62f Mon Sep 17 00:00:00 2001 From: Cody Austin Davis Date: Wed, 12 Feb 2025 13:09:15 -0800 Subject: [PATCH 4/4] Typo Fix in MV Initial PrPr commit --- .../cost_per_query/PrPr/DBSQL Cost Per Query MV (PrPr).sql | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dbsql/cost_per_query/PrPr/DBSQL Cost Per Query MV (PrPr).sql b/dbsql/cost_per_query/PrPr/DBSQL Cost Per Query MV (PrPr).sql index 20348572..96963cd0 100644 --- a/dbsql/cost_per_query/PrPr/DBSQL Cost Per Query MV (PrPr).sql +++ b/dbsql/cost_per_query/PrPr/DBSQL Cost Per Query MV (PrPr).sql @@ -319,7 +319,10 @@ statement_proportioned_work AS ( UNIX_TIMESTAMP(LEAST(query_work_end_time, timestampadd(hour, 1, hour_bucket))) - UNIX_TIMESTAMP(GREATEST(query_work_start_time, hour_bucket)) ) AS overlap_duration, - query_work_task_time * (overlap_duration / (CAST(query_work_end_time AS DOUBLE) - CAST(query_work_start_time AS DOUBLE))) AS proportional_query_work + CASE WHEN CAST(query_work_end_time AS DOUBLE) - CAST(query_work_start_time AS DOUBLE) = 0 + THEN 0 + ELSE query_work_task_time * (overlap_duration / (CAST(query_work_end_time AS DOUBLE) - CAST(query_work_start_time AS DOUBLE))) + END AS proportional_query_work FROM hour_intervals ), @@ -382,7 +385,7 @@ query_attribution AS ( SELECT a.*, warehouse_max_hour_bucket AS most_recent_billing_hour, - CASE WHEN warehouse_hour_bucket IS NOT NULL THEN 'Has Billing Reocrd' ELSE 'No Billing Record for this hour and warehouse yet available' END AS billing_record_check, + CASE WHEN warehouse_hour_bucket IS NOT NULL THEN 'Has Billing Record' ELSE 'No Billing Record for this hour and warehouse yet available' END AS billing_record_check, CASE WHEN total_work_done_on_warehouse = 0 THEN NULL ELSE attributed_query_work / total_work_done_on_warehouse