Describe the bug
Tested with dbt-meshify==0.5.3 as 0.5.4 seems to be broken, at least on my machine.
Running dbt-meshify split reference_data --select "group:xyz" -r returns the error Exception: Unable to find a macro block with the name abcdef. when the macro abcdef is actually in the file
Steps to reproduce
Use case 1
Create a macro with the following code
{% macro abcdef (
param1 = '',
param2 = [],
param3 = {}
) %}
-- nothing to seee
{% endmacro %}
The regex here doesn't "find" the macro.
Use case 2
Create a generic test like this
{% test my_test(model,) %}
-- nothing interesting
{% endtest %}
The same piece of code searches the file forblock_type = "macro" and name = "test_my_test", so it raises an Exception as well.
Suggestion
Here, replace
for match in re.finditer(
r"{%-?\s*" + block_type + r"\s*" + name + r"\s*([(a-zA-Z0-9=,_ \'\")]*)\s*-?%}",
file_content,
re.MULTILINE,
):
by
if block_type == "macro":
block_type_new = "(macro|test)"
name_new = f"({name}|{name[5:]})"
else:
block_type_new = block_type
name_new = name
pattern = r"{%-?[\s\n]+" + block_type_new + r"[\s\n]+" + name_new + r"([(a-zA-Z0-9=,_ \[\]{}'\s\n)]*)[\s\n]*-?%}"
for match in re.finditer(
pattern,
file_content,
re.MULTILINE,
):
The handling of test/macro is ugly and should be done better, but at least, on the dbt project I am testing, it works!
Describe the bug
Tested with dbt-meshify==0.5.3 as 0.5.4 seems to be broken, at least on my machine.
Running
dbt-meshify split reference_data --select "group:xyz" -rreturns the errorException: Unable to find a macro block with the name abcdef.when the macro abcdef is actually in the fileSteps to reproduce
Use case 1
Create a macro with the following code
The regex here doesn't "find" the macro.
Use case 2
Create a generic test like this
The same piece of code searches the file for
block_type = "macro"andname = "test_my_test", so it raises an Exception as well.Suggestion
Here, replace
by
The handling of test/macro is ugly and should be done better, but at least, on the dbt project I am testing, it works!