DBT:使用' this'功能在编译/预览中具有不同的结果
使用DBT Web IDE时,我在{{this}}}
函数中看到不同的行为时,当我使用预览或编译时,而不是使用dbt Run
构建模型。当我使用预览或编译时,模型名称始终为request
,但是当我使用dbt Run
构建模型时,它会正确解析模型名称。
例如,在my_model.sql
中:
{{ this.database }}
{{ this.schema }}
{{ this.name }}
dev_db
public
request
如果我运行dbt run -s my_model
,在运行的详细信息中:
dev_db
public
my_model
我的问题是我如何获得我的行为预览/编译以匹配dbt Run
的编译?我希望{{{this.name}}
正确解析为my_model
。
When using the DBT web IDE, I'm seeing different behavior in the {{ this }}
function when I use preview or compile as opposed to building the model with dbt run
. When I use preview or compile, the model name is always request
, but when I build the model with dbt run
, it correctly resolves the model name.
For example, in my_model.sql
:
{{ this.database }}
{{ this.schema }}
{{ this.name }}
dev_db
public
request
If I run dbt run -s my_model
, in the details of the run I see:
dev_db
public
my_model
My question is how can I get the behavior of preview/compile to match that of dbt run
? I would like {{ this.name }}
to correctly resolve to my_model
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为,当您在IDE中击中“编译”或“运行”时,它只会将编辑器窗口的内容拿走,然后编译或编译或运行它,而与文件本身无关。在某些情况下,这是有道理的,例如,我可以启动一个新的选项卡并“运行”它而无需保存作为文件。
因此,似乎正在获取临时名称
请求
而不是模型的名称。我不知道DBT Labs是否会认为这是一个错误,可能是设计出来的,但是对他们的支持可能是您最好的下一步。
I think when you hit 'compile' or 'run' in the IDE, it just takes the contents of your editor window and compiles or compiles/runs it, independent of the file itself. In some cases this makes sense, eg I can start a new tab and 'run' it without saving it as a file.
Because of this, it seems like it's getting the temporary name
request
rather than the name of the model.I don't know if dbt Labs would consider this a bug, likely more it's by design, but speaking to their support is probably your best next step.