Skip to content

Commit

Permalink
Add query_hash & query_parameterized_hash columns (#137)
Browse files Browse the repository at this point in the history
Co-authored-by: Sidharth Pallerla <[email protected]>
  • Loading branch information
sidhreddy and Sidharth Pallerla authored Nov 10, 2023
1 parent 4b00b5b commit 23e1cb0
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
4 changes: 4 additions & 0 deletions models/query_history_enriched.sql
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ select
query_history.query_acceleration_bytes_scanned,
query_history.query_acceleration_partitions_scanned,
query_history.query_acceleration_upper_limit_scale_factor,
query_history.query_hash,
query_history.query_hash_version,
query_history.query_parameterized_hash,
query_history.query_parameterized_hash_version,

-- Rename some existing columns for clarity
query_history.total_elapsed_time as total_elapsed_time_ms,
Expand Down
10 changes: 10 additions & 0 deletions models/query_history_enriched.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,16 @@ models:
- name: query_acceleration_upper_limit_scale_factor
description: Upper limit scale factor that a query would have benefited from.

# Snowflake's Query Hash & Parameterized Query Hash columns
- name: query_hash
description: The hash value computed based on the canonicalized SQL text.
- name: query_hash_version
description: The version of the logic used to compute QUERY_HASH.
- name: query_parameterized_hash
description: The hash value computed based on the parameterized query.
- name: query_parameterized_hash_version
description: The version of the logic used to compute QUERY_PARAMETERIZED_HASH.

# Renamed existing columns
- name: total_elapsed_time_ms
description: Elapsed time (in milliseconds).
Expand Down
6 changes: 5 additions & 1 deletion models/staging/stg_query_history.sql
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ select
is_client_generated_statement,
query_acceleration_bytes_scanned,
query_acceleration_partitions_scanned,
query_acceleration_upper_limit_scale_factor
query_acceleration_upper_limit_scale_factor,
query_hash,
query_hash_version,
query_parameterized_hash,
query_parameterized_hash_version
from {{ source('snowflake_account_usage', 'query_history') }}

{% if is_incremental() %}
Expand Down
8 changes: 8 additions & 0 deletions models/staging/stg_query_history.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,11 @@ models:
description: Number of partitions scanned by the query acceleration service.
- name: query_acceleration_upper_limit_scale_factor
description: Upper limit scale factor that a query would have benefited from.
- name: query_hash
description: The hash value computed based on the canonicalized SQL text.
- name: query_hash_version
description: The version of the logic used to compute QUERY_HASH.
- name: query_parameterized_hash
description: The hash value computed based on the parameterized query.
- name: query_parameterized_hash_version
description: The version of the logic used to compute QUERY_PARAMETERIZED_HASH.

0 comments on commit 23e1cb0

Please sign in to comment.