dbt debug macro 简单说明

dbt 支持debug macro 可以用来进行调试

使用

{% macro my_macro() %}
 
  {% set something_complex = my_complicated_macro() %}
 
  {{ debug() }}
 
{% endmacro %}

参考实现

实际上就是通过环境变量开启了一个debug 上下文变量

if os.environ.get("DBT_MACRO_DEBUGGING"):
 
    @contextmember()
    @staticmethod
    def debug():
        """Enter a debugger at this line in the compiled jinja code."""
        import sys
        import ipdb  # type: ignore
 
        frame = sys._getframe(3)
        ipdb.set_trace(frame)
        return ""

参考资料

https://docs.getdbt.com/reference/dbt-jinja-functions/debug-method
https://github.com/gotcha/ipdb

posted on   荣锋亮  阅读(15)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2023-04-05 neondatabase 开源的k8s postgres autoscaling 工具
2023-04-05 使用sealos 快速部署生产可用的k8s环境
2022-04-05 hammerdb 数据库负载以及性能测试工具
2022-04-05 简单nginx module 学习
2022-04-05 通过火焰图学习nginx upstream 模块的处理
2021-04-05 haproxy 支持fix 协议
2021-04-05 dremio arp connector 开发

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示