From 707e78ba5040278f2c5fc36997cb0974662a5d83 Mon Sep 17 00:00:00 2001 From: Niall Woodward Date: Mon, 6 Nov 2023 14:39:21 +0000 Subject: [PATCH 1/2] Remove regex UDF --- macros/create_regexp_replace_udf.sql | 14 -------------- models/query_history_enriched.sql | 4 ++-- 2 files changed, 2 insertions(+), 16 deletions(-) delete mode 100644 macros/create_regexp_replace_udf.sql diff --git a/macros/create_regexp_replace_udf.sql b/macros/create_regexp_replace_udf.sql deleted file mode 100644 index 579248e..0000000 --- a/macros/create_regexp_replace_udf.sql +++ /dev/null @@ -1,14 +0,0 @@ -{% macro create_regexp_replace_udf(relation) %} - -create or replace function {{ relation.database }}.{{ relation.schema }}.dbt_snowflake_monitoring_regexp_replace(subject text, pattern text, replacement text) -returns string -language javascript -comment = 'Created by dbt-snowflake-monitoring dbt package.' -as -$$ - const p = SUBJECT; - let regex = new RegExp(PATTERN, 'g') - return p.replace(regex, REPLACEMENT); -$$ - -{% endmacro %} diff --git a/models/query_history_enriched.sql b/models/query_history_enriched.sql index 0fe47c1..306edb1 100644 --- a/models/query_history_enriched.sql +++ b/models/query_history_enriched.sql @@ -1,7 +1,7 @@ {{ config( materialized='incremental', unique_key=['query_id', 'start_time'], - pre_hook=["{{ create_regexp_replace_udf(this) }}", "{{ create_merge_objects_udf(this) }}"] + pre_hook=["{{ create_merge_objects_udf(this) }}"] ) }} with @@ -10,7 +10,7 @@ query_history as ( *, -- this removes comments enclosed by /* */ and single line comments starting with -- and either ending with a new line or end of string - {{ this.database }}.{{ this.schema }}.dbt_snowflake_monitoring_regexp_replace(query_text, $$(/\*(.|\n|\r)*?\*/)|(--.*$)|(--.*(\n|\r))$$, '') as query_text_no_comments, + regexp_replace(query_text, $$(\/\*(.|\n|\r)*?\*\/)|(--.*$)|(--.*(\n|\r))|;$$, '') as query_text_no_comments, try_parse_json(regexp_substr(query_text, '/\\*\\s({"app":\\s"dbt".*})\\s\\*/', 1, 1, 'ie')) as _dbt_json_comment_meta, case From 174f68df2342c494a48d09e69ad275f4d9b82cff Mon Sep 17 00:00:00 2001 From: Niall Woodward Date: Mon, 6 Nov 2023 14:40:43 +0000 Subject: [PATCH 2/2] Release --- .changes/4.5.3.md | 7 +++++++ CHANGELOG.md | 8 ++++++++ dbt_project.yml | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 .changes/4.5.3.md diff --git a/.changes/4.5.3.md b/.changes/4.5.3.md new file mode 100644 index 0000000..7ae92e5 --- /dev/null +++ b/.changes/4.5.3.md @@ -0,0 +1,7 @@ +## dbt-snowflake-monitoring 4.5.3 - November 06, 2023 + +### Features + +- Remove regex UDF to avoid timeout ([#135](https://github.com/get-select/dbt-snowflake-monitoring/pull/135)) + + diff --git a/CHANGELOG.md b/CHANGELOG.md index e2187ab..77e4463 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html), and is generated by [Changie](https://github.com/miniscruff/changie). +## dbt-snowflake-monitoring 4.5.3 - November 06, 2023 + +### Features + +- Remove regex UDF to avoid timeout ([#135](https://github.com/get-select/dbt-snowflake-monitoring/pull/135)) + + + ## dbt-snowflake-monitoring 4.5.2 - October 30, 2023 ### Fixes diff --git a/dbt_project.yml b/dbt_project.yml index bdf6469..faf7e89 100644 --- a/dbt_project.yml +++ b/dbt_project.yml @@ -1,5 +1,5 @@ name: 'dbt_snowflake_monitoring' -version: '4.5.2' +version: '4.5.3' config-version: 2 profile: dbt_snowflake_monitoring