From bee93938db67c800559d8989889dbc8b34577324 Mon Sep 17 00:00:00 2001 From: Dave Connors Date: Fri, 25 Oct 2024 10:19:58 -0500 Subject: [PATCH] make sure we catch single character dbs and schemas --- integration_tests/models/marts/fct_model_6.sql | 9 ++++++++- .../seeds/dag/test_fct_hard_coded_references.csv | 2 +- macros/find_all_hard_coded_references.sql | 10 +++++----- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/integration_tests/models/marts/fct_model_6.sql b/integration_tests/models/marts/fct_model_6.sql index e57e48af..d79c10c3 100644 --- a/integration_tests/models/marts/fct_model_6.sql +++ b/integration_tests/models/marts/fct_model_6.sql @@ -92,6 +92,13 @@ select 1 as id select 5 as id from {{ var('my_table_reference', 'table_d') }} - + union all + select + 5 as id + from a.b.c + union all + select + 5 as id + from a.b #} \ No newline at end of file diff --git a/integration_tests/seeds/dag/test_fct_hard_coded_references.csv b/integration_tests/seeds/dag/test_fct_hard_coded_references.csv index 345266e1..2f57bcc0 100644 --- a/integration_tests/seeds/dag/test_fct_hard_coded_references.csv +++ b/integration_tests/seeds/dag/test_fct_hard_coded_references.csv @@ -1,2 +1,2 @@ model,hard_coded_references -fct_model_6,"""my_db"".""my_schema"".""my_table"", ""my_schema"".""raw_relation_5"", ""raw_relation_2"", 'my_db'.'my_schema'.'my_table', 'my_schema'.'raw_relation_5', 'raw_relation_4', [my_db].[my_schema].[my_table], [my_schema].[raw_relation_5], [raw_relation_3], `my_db`.`my_schema`.`my_table`, `my_schema`.`raw_relation_5`, `project-name.dataset_name.table_name`, `raw_relation_1`, my_db.my_schema.my_table, my_schema.raw_relation_5, {{ var(""my_table_reference"") }}, {{ var(""my_table_reference"", ""table_d"") }}, {{ var('my_table_reference') }}, {{ var('my_table_reference', 'table_d') }}" \ No newline at end of file +fct_model_6,"""my_db"".""my_schema"".""my_table"", ""my_schema"".""raw_relation_5"", ""raw_relation_2"", 'my_db'.'my_schema'.'my_table', 'my_schema'.'raw_relation_5', 'raw_relation_4', [my_db].[my_schema].[my_table], [my_schema].[raw_relation_5], [raw_relation_3], `my_db`.`my_schema`.`my_table`, `my_schema`.`raw_relation_5`, `project-name.dataset_name.table_name`, `raw_relation_1`, a.b, a.b.c, my_db.my_schema.my_table, my_schema.raw_relation_5, {{ var(""my_table_reference"") }}, {{ var(""my_table_reference"", ""table_d"") }}, {{ var('my_table_reference') }}, {{ var('my_table_reference', 'table_d') }}" \ No newline at end of file diff --git a/macros/find_all_hard_coded_references.sql b/macros/find_all_hard_coded_references.sql index 18b5f512..58f6475c 100644 --- a/macros/find_all_hard_coded_references.sql +++ b/macros/find_all_hard_coded_references.sql @@ -134,7 +134,7 @@ # third matching group # at least 1 word character - (\w+-?\w+) + (\w+-?\w*) # fouth matching group # 1 or 0 of (closing bracket, backtick, or quotation mark) @@ -150,7 +150,7 @@ # seventh matching group # at least 1 word character - (\w+-?\w+) + (\w+-?\w*) # eighth matching group # 1 or 0 of (closing bracket, backtick, or quotation mark) folowed by a whitespace character or end of string @@ -173,7 +173,7 @@ # third matching group # at least 1 word character - (\w+-?\w+) + (\w+-?\w*) # fouth matching group # 1 or 0 of (closing bracket, backtick, or quotation mark) @@ -189,7 +189,7 @@ # seventh matching group # at least 1 word character - (\w+-?\w+) + (\w+-?\w*) # eighth matching group # 1 or 0 of (closing bracket, backtick, or quotation mark) @@ -205,7 +205,7 @@ # eleventh matching group # at least 1 word character - (\w+-?\w+) + (\w+-?\w*) # twelfth matching group # 1 or 0 of (closing bracket, backtick, or quotation mark) followed by a whitespace character or end of string