【发布时间】:2023-02-18 01:47:31
【问题描述】:
我的表名为 rw_ghi_abc。 我想从表名中删除 rw_,为此我使用宏 generate_alias_name 作为:
{% macro generate_alias_name(re,custom_alias_name=none, node=none) -%}
{%- if custom_alias_name is none -%}
{{ re.search('g\w+',node.name) }}
{%- else -%}
{{ custom_alias_name | trim }}
{%- endif -%}
{%- endmacro %}
我正在使用 re.search 以便我可以从名称中跳过 rw_,在 dbt 运行后它会给出如下错误:
Database Error in model rw_ghi_abc(models/RAW/abc/rw_ghi_abc.sql)
001003 (42000): SQL compilation error:
syntax error line 1 at position 77 unexpected '='.
syntax error line 1 at position 102 unexpected '='.
syntax error line 1 at position 113 unexpected '='.
syntax error line 1 at position 131 unexpected ''RAW''.
syntax error line 1 at position 140 unexpected ''abc''.
syntax error line 1 at position 152 unexpected ''rw_ghi_abc''.
syntax error line 1 at position 184 unexpected '='.
syntax error line 1 at position 234 unexpected '='.
syntax error line 1 at position 631 unexpected '='.
syntax error line 1 at position 672 unexpected '='.
syntax error line 1 at position 698 unexpected '='.
syntax error line 1 at position 771 unexpected '='.
syntax error line 1 at position 831 unexpected '='.
syntax error line 1 at position 884 unexpected '='.
syntax error line 1 at position 920 unexpected '='.
syntax error line 1 at position 953 unexpected '='.
syntax error line 1 at position 984 unexpected '='.
syntax error line 1 at position 1,017 unexpected '='.
syntax error line 1 at position 1,085 unexpected ','.
compiled Code at target/run/data/models/RAW/abc/rw_ghi_abc.sql
有人可以帮我弄这个吗。
【问题讨论】:
-
您可能想查看已编译的 SQL 并从那里获取它
-
您可以发布
rw_ghi_abc.sql的原始代码和编译代码吗?
标签: dbt