dbt-labs / dbt-labs/dbt-codegen

generate_model_import_ctes returns --placeholder-- on dbt Fusion

Open
#268 0 comments 0 reactions 0 assignees View on GitHub
bug triage
Dominant language
Makefile
Stars
676
Forks
132
PR merge metrics
No merged PRs in 30d

Description

### 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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.