为什么我会得到“意外”' &quot当我尝试运行DBT Jinja型号时,错误?
我已经在DBT中创建了一个模型,以与雪花抗衡。我正在使用一些Jinja通过表名称列表进行迭代,并为每个表构建一些SQL。
以下脚本应遍历每个表,生成一些SQL脚本并在每个脚本之间插入一个联合语句,除了最后一次迭代。
我遇到以下错误,但是我看不到任何流浪括号
11:44:23 001003(42000):SQL汇编错误
11:44:23语法错误14在位置6出乎意料的第14号')'。
我的脚本是
{{
config(
query_tag = 'DBT: Staging_History'
)
}}
{% set table_names_query %}
select table_name
from information_schema.tables
where table_type = 'BASE TABLE' and TABLE_CATALOG = 'PROD_SOURCE' and TABLE_SCHEMA =
'DIS_STG'
{% endset %}
{% set results = run_query(table_names_query) %}
{% if execute %}
{% set results_list = results.columns[0].values() %}
{% else %}
{% set results_list = [] %}
{% endif %}
{% for table_name in results_list %}
SELECT * FROM TABLE(INFORMATION_SCHEMA.copy_history(table_name=>'PROD_SOURCE.DIS_STG.DBO_ORGANIZATION', start_time=>dateadd(DAY, -90, current_timestamp)))
{% if not loop.last %} UNION {% endif %}
{% endfor %}
I have created a model in DBT to run against Snowflake. I am using some jinja to iterate through a list of table names, and build some sql for each table.
The following script should loop through each table, generate some SQL script and insert a UNION statement between each piece of script except for the last iteration.
I am getting the following error however I can not see any stray parenthesis
11:44:23 001003 (42000): SQL compilation error
11:44:23 syntax error line 14 at position 6 unexpected ')'.
My script is
{{
config(
query_tag = 'DBT: Staging_History'
)
}}
{% set table_names_query %}
select table_name
from information_schema.tables
where table_type = 'BASE TABLE' and TABLE_CATALOG = 'PROD_SOURCE' and TABLE_SCHEMA =
'DIS_STG'
{% endset %}
{% set results = run_query(table_names_query) %}
{% if execute %}
{% set results_list = results.columns[0].values() %}
{% else %}
{% set results_list = [] %}
{% endif %}
{% for table_name in results_list %}
SELECT * FROM TABLE(INFORMATION_SCHEMA.copy_history(table_name=>'PROD_SOURCE.DIS_STG.DBO_ORGANIZATION', start_time=>dateadd(DAY, -90, current_timestamp)))
{% if not loop.last %} UNION {% endif %}
{% endfor %}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果要使用
因此以太更改为
或
If you are going to use the macro of CURRENT_TIMESTAMP (aka without the parens) it must be in upper case.
So ether change to
or