1

According to DBT's docs on modules to use within jinja functions - https://docs.getdbt.com/reference/dbt-jinja-functions/modules - modules.re should be available. However, there is this macro I am working with:

{% macro camel_to_snake_case(camel_case_string) -%}

{{ modules.re.sub('([A-Z][a-z]|[A-Z]*[0-9]+)', '_\\1', modules.re.sub('([A-Z]+[A-Z]([a-z]|$))', '_\\1', camel_case_string)) | trim('_') | lower() }}

{%- endmacro %}

and whenever a script is run that uses this macro, i receive the error:

Running with dbt=0.17.0
Encountered an error:
Compilation Error in model model_using_macro (models/model_using_macro.sql)
  'dict object' has no attribute 're'

Do I need to install something in order to access the modules.re function? Maybe the base dbt I have installed doesn't have this modules at all? Perhaps there is a way I can check the output for modules to see why re is missing, and what else might be available / missing? I'm not sure why else this error could be happening?

Fiori
  • 181
  • 1
  • 12

1 Answers1

3

Try upgrading dbt, re was added in 0.19.0 (source)

Josh D.
  • 1,068
  • 9
  • 18
  • Getting a similar error , but for datediff or datesprint macros in dbt utils 09:41:17 'dict object' has no attribute 'datediff'. This can happen when calling a macro that does not exist. Check for typos and/or install package dependencies with "dbt deps". Tried upgrading dbt to v1.4 , but in vain -- testing out different ideas, but any help is appreciated as datediff, datespine both still do exist as macros – Pravin Feb 21 '23 at 11:45
  • @pravin While it may seem similar, this is a distinct question, I encourage you to ask it separately to try and get an answer. – Josh D. Feb 22 '23 at 03:56
  • Yup agreed, done - https://stackoverflow.com/questions/75528600/dbt-datediff-dict-object-compilation-errors – Pravin Feb 22 '23 at 05:29