diff --git a/models/query_history_enriched.sql b/models/query_history_enriched.sql index 913eefd..29fea14 100644 --- a/models/query_history_enriched.sql +++ b/models/query_history_enriched.sql @@ -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, diff --git a/models/query_history_enriched.yml b/models/query_history_enriched.yml index 3483f23..8783fee 100644 --- a/models/query_history_enriched.yml +++ b/models/query_history_enriched.yml @@ -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). diff --git a/models/staging/stg_query_history.sql b/models/staging/stg_query_history.sql index 465b744..c3f95f8 100644 --- a/models/staging/stg_query_history.sql +++ b/models/staging/stg_query_history.sql @@ -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() %} diff --git a/models/staging/stg_query_history.yml b/models/staging/stg_query_history.yml index bab0994..32e150a 100644 --- a/models/staging/stg_query_history.yml +++ b/models/staging/stg_query_history.yml @@ -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.