首页 > 其他分享 >dbt debug macro 简单说明

dbt debug macro 简单说明

时间:2024-04-05 09:02:53浏览次数:32  
标签:set macro frame ipdb debug dbt

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

标签:set,macro,frame,ipdb,debug,dbt
From: https://www.cnblogs.com/rongfengliang/p/18098156

相关文章

  • Macros --The Magic Wand of Rust
    HelloandwelcometothewonderfulworldofRustmacros!Today,wewillembarkonanexcitingadventuretogethertoexplorethemagicalpowersofRustmacros.Areyouready?Bringyourcuriosityandlet'sgo!InRust,macrosarelikewizardsofprogr......
  • dbt statement macro 简单说明
    statementblocks实际上就是一个标准的jinja2macro调用包装,提供了方便的sql执行能力,因为需要进行查询结果的存储,dbt提供了一个store_result的macro,内部数据的处理基于了agate这个方便的python数据处理包为了查询使用提供了load_resultmacro以下只说明关于stateme......
  • (译) 理解 Elixir 中的宏 Macro, 第四部分:深入化
    ElixirMacros系列文章译文[1](译)UnderstandingElixirMacros,Part1Basics[2](译)UnderstandingElixirMacros,Part2-MacroTheory[3](译)UnderstandingElixirMacros,Part3-GettingintotheAST[4](译)UnderstandingElixirMacros,Part4-Div......
  • (译) 理解 Elixir 中的宏 Macro, 第三部分:深入理解 AST
    ElixirMacros系列文章译文[1](译)UnderstandingElixirMacros,Part1Basics[2](译)UnderstandingElixirMacros,Part2-MacroTheory[3](译)UnderstandingElixirMacros,Part3-GettingintotheAST[4](译)UnderstandingElixirMacros,Part4-Div......
  • 使用 Debugger 断点 如果打开了断点调试 就会跳转空白页面
    <!DOCTYPEhtml><html><header><title>test</title></header><body><h1>test</h1></body><script>setInterval(function(){varsta......
  • Advanced .Net Debugging 6:程序集加载器
    一、简介这是我的《Advanced.NetDebugging》这个系列的第六篇文章。这篇文章的内容是原书的第二部分的【调试实战】的第四章。这章主要讲的是程序集加载器,比如:CLR加载器简介、简单的程序集加载故障、加载上下文故障、互用性与DllNotFoundException和轻量级代码生成的......
  • (译) 理解 Elixir 中的宏 Macro, 第二部分:宏理论
    ElixirMacros系列文章译文[1](译)UnderstandingElixirMacros,Part1Basics[2](译)UnderstandingElixirMacros,Part2-MicroTheory[3](译)UnderstandingElixirMacros,Part3-GettingintotheAST[4](译)UnderstandingElixirMacros,Part4-Div......
  • dbt macro 的执行简单说明
    BaseAdapter中包含了一个adapter实际运行依赖的转换,链接处理,当然也包含了macro的执行,具体方法有直接的execute_macroModelRunner中的materialization_macro(run命令)还有run-operation中RunOperationTask的_run_unsafe方法ModelRunnercall_macro处理参考调用......
  • dbt this macro 处理简单说明
    dbtthismacro提供了一种方便的对于当前模型展现的方法,可以使用在增量模型以及pre&posthooks中this实际是就类似ref('<the_current_model>')是一个relation包含了database,schema以及模型标识使用示例一个增量处理的,基于this可以方便的引用模型{{config(mater......
  • PHP debug_backtrace() 函数
    定义和用法debug_backtrace()函数生成backtrace。该函数显示由debug_backtrace()函数代码生成的数据。返回一个关联数组。下面是可能返回的元素:名称类型描述functionstring当前的函数名。lineinteger当前的行号。filestring当前的文件名。classstring当......