Skip to content

Commit

Permalink
Add documentation to a dbt model
Browse files Browse the repository at this point in the history
  • Loading branch information
fernandobrito committed Jun 14, 2024
1 parent 7da5aae commit 295c99b
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
8 changes: 7 additions & 1 deletion models/cost_per_serverless_task_run.sql
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ serverless_runs as (
task_history.schema_name as task_schema_name,
name as task_name,
concat(task_database_name, '.', task_schema_name, '.', task_name) as task_fqn_name,
start_time as execution_start_time
timeadd(
'millisecond',
queued_overload_time + compilation_time
+ queued_provisioning_time + queued_repair_time
+ list_external_files_time,
start_time
) as execution_start_time,

from {{ ref('stg_task_history') }} as task_history

Expand Down
37 changes: 37 additions & 0 deletions models/cost_per_serverless_task_run.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
version: 2

models:
- name: cost_per_serverless_task_run
description: |
A model that splits the hourly cost per serverless task from stg_serverless_task_history back to the queries
triggered by individual tasks runs, taking into account the fraction of time that each run took in the hour.
The logic and code are heavily inspired by what the cost_per_query model does for compute cost.
columns:
- name: query_id
description: Primary key. Internal/system-generated identifier for the SQL statement.
tests:
- unique
- not_null
- name: start_time
description: Query statement start time (in the UTC time zone). The table is naturally clustered on this column, meaning your queries will run much faster if you filter records using this column.
- name: end_time
description: Query statement end time (in the UTC time zone).
- name: task_database_id
description: Internal/system-generated identifier for the database that contains the task.
- name: task_database_name
description: Name of the database that contains the task.
- name: task_schema_id
description: Internal/system-generated identifier for the schema that contains the task.
- name: task_schema_name
description: Name of the schema that contains the task.
- name: task_name
description: Name of the task.
- name: execution_start_time
description: When the query began executing on the warehouse (in the UTC time zone). This will always be after the start_time.
- name: serverless_task_cost
description: Total serverless task cost associated with the query.
- name: serverless_task_credits
description: Total serverless task credits associated with the query.
- name: currency
description: Spend currency, retrieved from Snowflake's daily rate sheet

0 comments on commit 295c99b

Please sign in to comment.