Modify generate_model_import_ctes.sql to use the verbose mode (adding x to the i flag) for re, allowing to split regexes between different lines and providing the ability to add comments to those.
Additional context
Here is an example of regex without verbose (all in 1 line):
{% set re = modules.re %}
{% set my_string = <my_sql_code> %}
{% set re_pattern = '(?i)(from|join)\s+({{\s*ref\s*\(\s*[\'\"]?)([^)\'\"]+)([\'\"]?\s*)(\)\s*}})'
%}
{% set is_match = re.findall(re_pattern, my_string) %}
and with verbose:
{% set re = modules.re %}
{% set my_string = <my_sql_code> %}
{% set re_pattern = "(?ix)
# first matching group
(from|join)\s+ # from or join followed by at least a sep character
# second matching group
(
{{ # opening {{
\s*ref\s*\( # the word ref followed by a (
\s*[\'\"]?
)
([^)\'\"]+)([\'\"]?\s*)(
\)\s* # closing ) for ref
}} # closing {{
)"
%}
{% set is_match = re.findall(re_pattern, my_string) %}
Who will this benefit?
People wanting to understand/enhance regexes to find tables in models.
Describe the feature
Modify
generate_model_import_ctes.sql
to use the verbose mode (addingx
to thei
flag) forre
, allowing to split regexes between different lines and providing the ability to add comments to those.Additional context
Here is an example of regex without verbose (all in 1 line):
and with verbose:
Who will this benefit?
People wanting to understand/enhance regexes to find tables in models.
Are you interested in contributing this feature?
Why not but keen to let someone else look at it