dbt model 对象简单说明
dbt model 属于graph 对象,实际上就是一个node 节点,包含了当前模型的一些信息
主要场景
- 访问config 设置
- 访问模型的路径
参考使用
- 查看模型内容
可以通过log macro
{{ log(model, info=True) }}
内部实现
实际上就是context 属性信息
@contextproperty("model")
def ctx_model(self) -> Dict[str, Any]:
model_dct = self.model.to_dict(omit_none=True)
# Maintain direct use of compiled_sql
# TODO add depreciation logic[CT-934]
if "compiled_code" in model_dct:
model_dct["compiled_sql"] = model_dct["compiled_code"]
if (
hasattr(self.model, "contract")
and self.model.contract.alias_types is True
and "columns" in model_dct
):
for column in model_dct["columns"].values():
if "data_type" in column:
orig_data_type = column["data_type"]
# translate data_type to value in Column.TYPE_LABELS
new_data_type = self.adapter.Column.translate_type(orig_data_type)
column["data_type"] = new_data_type
return model_dct
说明
再一些场景中我们可能需要访问model 的一些信息,比如物化处理上,获取配置信息的,了解一些功能还是很有用的
参考资料
core/dbt/context/providers.py
https://docs.getdbt.com/reference/dbt-jinja-functions/model
https://docs.getdbt.com/docs/build/incremental-models
https://schemas.getdbt.com/dbt/manifest/v11/index.html#tab-pane_nodes_additionalProperties_anyOf_i3
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
2022-05-17 nginx ngx_http_realip 的功能以及使用
2020-05-17 promcat.io 由sysdig 托管的企业级prometheus监控网站
2020-05-17 c 语言使用lttng
2020-05-17 lttng简单试用
2020-05-17 dotnetcore 性能分析一些文章
2019-05-17 edgedb-js 来自官方的js 驱动
2019-05-17 edgedb 开发环境运行