Skip to content

Commit

Permalink
Merge pull request #451 from simmartynas/feat/add-hyphen-detection
Browse files Browse the repository at this point in the history
Detect hyphen in hard coded reference
  • Loading branch information
dave-connors-3 authored May 9, 2024
2 parents 54f4689 + 19fca6d commit fcb464c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 19 deletions.
6 changes: 5 additions & 1 deletion integration_tests/models/marts/fct_model_6.sql
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ select 1 as id
union all
select
4 as id
from 'raw_relation_4'
from 'raw_relation_4'
union all
select
4 as id
from `project-name.dataset_name.table_name`
union all
select
4 as id
Expand Down
Original file line number Diff line number Diff line change
@@ -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`, `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') }}"
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') }}"
34 changes: 17 additions & 17 deletions macros/find_all_hard_coded_references.sql
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
# third matching group
# at least 1 word character
(\w+)
(\w+-?\w+)
# fouth matching group
# 1 or 0 of (closing bracket, backtick, or quotation mark)
Expand All @@ -150,7 +150,7 @@
# seventh matching group
# at least 1 word character
(\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
Expand All @@ -164,48 +164,48 @@
(?<!distinct\s)
# first matching group
# from or join followed by at least 1 whitespace character
# from or join followed by at least 1 whitespace character
(from|join)\s+
# second matching group
# 1 or 0 of (opening bracket, backtick, or quotation mark)
# 1 or 0 of (opening bracket, backtick, or quotation mark)
([\[`\"\']?)
# third matching group
# at least 1 word character
(\w+)
(\w+-?\w+)
# fouth matching group
# 1 or 0 of (closing bracket, backtick, or quotation mark)
# 1 or 0 of (closing bracket, backtick, or quotation mark)
([\]`\"\']?)
# fifth matching group
# a period
# a period
(\.)
# sixth matching group
# 1 or 0 of (opening bracket, backtick, or quotation mark)
([\[`\"\']?)
# seventh matching group
# at least 1 word character
(\w+)
# at least 1 word character
(\w+-?\w+)
# eighth matching group
# 1 or 0 of (closing bracket, backtick, or quotation mark)
# 1 or 0 of (closing bracket, backtick, or quotation mark)
([\]`\"\']?)
# ninth matching group
# a period
# a period
(\.)
# tenth matching group
# 1 or 0 of (closing bracket, backtick, or quotation mark)
# 1 or 0 of (closing bracket, backtick, or quotation mark)
([\[`\"\']?)
# eleventh matching group
# at least 1 word character
(\w+)
# at least 1 word character
(\w+-?\w+)
# twelfth matching group
# 1 or 0 of (closing bracket, backtick, or quotation mark) followed by a whitespace character or end of string
Expand All @@ -219,16 +219,16 @@
(?<!distinct\s)
# first matching group
# from or join followed by at least 1 whitespace character
# from or join followed by at least 1 whitespace character
(from|join)\s+
# second matching group
# 1 of (opening bracket, backtick, or quotation mark)
# 1 of (opening bracket, backtick, or quotation mark)
([\[`\"\'])
# third matching group
# at least 1 word character
(\w+)
(\w+-?\w+)
# fourth matching group
# 1 of (closing bracket, backtick, or quotation mark) folowed by a whitespace character or end of string
Expand Down

0 comments on commit fcb464c

Please sign in to comment.