【问题标题】:how to use python regex functions in dbt-jinja?如何在 dbt-jinja 中使用 python 正则表达式函数?
【发布时间】:2021-09-17 19:09:09
【问题描述】:

this PR 将所有re 模块功能添加到dbt-jinja,但是如何使用呢?我尝试了以下两个,但没有成功。

{% set matcher = re.match('^C', 'Cat') %}
're' is undefined. This can happen when calling a macro that does not exist. Check for typos and/or install package dependencies with "dbt deps".
{% set matcher = match('^C', 'Cat') %}
> 'match' is undefined. This can happen when calling a macro that does not exist. Check for typos and/or install package dependencies with "dbt deps".

【问题讨论】:

    标签: jinja2 dbt


    【解决方案1】:

    正如 PR 中的评论所指出的,a doc page 详细说明了要使用 re 模块,您可以在其用法前加上 modules.

    {% set matcher = modules.re.match('^C', 'Cat') %}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-05
      • 1970-01-01
      • 2015-10-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-19
      • 1970-01-01
      相关资源
      最近更新 更多