Skip to content

generate_model_import_ctes returns --placeholder-- on dbt Fusion #268

Description

@colin-thornburg

Describe the bug

On dbt Fusion, the dbt-labs/codegen macro generate_model_import_ctes returns --placeholder-- instead of generated SQL. This occurs both when compiling an analysis file and when invoking the macro via dbt run-operation

Steps to reproduce

Given a normal model like dim_offices.sql:

with source as (
select * from {{ ref('stg_offices') }}
)

select
office_id,
office_name,
city,
state,
region,
opened_date,
office_type,
is_active,
date_diff(current_date(), opened_date, year) as office_age_years
from source

Create an analysis file:
{{ codegen.generate_model_import_ctes(
model_name = 'dim_offices'
) }}

Then run either of these:

dbt compile --select path:analyses/test_codegen.sql
or

dbt run-operation codegen.generate_model_import_ctes --args '{"model_name": "dim_offices"}'
Actual result
Both commands return:

--placeholder--

Expected results

The macro should return generated SQL with upstream refs/sources pulled into import CTE

Actual results

-- placeholder --

Screenshots and log output

System information

packages:

  • package: dbt-labs/dbt_utils
    version: [">=1.0.0", "<2.0.0"]
  • package: dbt-labs/codegen
    version: 0.14.0

Which database are you using dbt with?

  • bigquery
  • snowflake

The output of dbt --version:

dbt-fusion 2.0.0-preview.175

The operating system you're using:

dbt Cloud IDE (Studio)

Additional context

Reproduced against an existing model with valid SQL
Reproduced both in analyses/ and via run-operation
This appears to be a compatibility issue between Fusion and dbt-labs/codegen, rather than a project-specific issue

The macro appears to depend on graph node attributes that may behave differently in Fusion, specifically:

{% set model_raw_sql = model.raw_sql or model.raw_code %}
It looks like the macro is not receiving usable model SQL in Fusion runtime context, and falls through to a placeholder result.

Are you interested in contributing the fix?

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions