The problem I’m having
I am creating customer tests and which will run in Anomalo.
{% test my_test(model, column_name) %}
{%- set model_node = graph.nodes.get("model.common_resources.my_graph_source_key") -%}
{%- set raw_code = model_node["raw_code"] -%}
{%- set compiled_code = model_node["compiled_code"] -%}
with cte AS (
{{compiled_code}}
)
SELECT * FROM cte
WHERE ...
{% endtest %}
I can get model_node
, raw_code
, but I cannot get compiled_code
while run dbt compile.
May I ask how can I get the compiled sql from models in dbt tests?
The context of why I’m trying to do this
We want to have a unified test for platform without considering about the product sql query.