dbt-labs / dbt-labs/dbt-codegen

generate_source doesn't work in analysis tab in fusion

Open
#265 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
I set up the basic analysis sheet in a fusion project to generate_source like this:
{{ codegen.generate_source(schema_name= 'dbt_artifacts', database_name= 'copilot_converters') }}

NOTE: Running this as a run-operation works OK.

And Instead of being able to compile, i get this:
```
dbt1501: Failed to render SQL unknown function: In dispatch: No macro named 'generate_source' found within namespace: 'codegen'
Searched for: 'my_new_project.snowflake__generate_source', 'my_new_project.snowflake__generate_source', 'my_new_project.default__generate_source', 'my_new_project.default__generate_source', 'my_new_project.generate_source', 'my_new_project.generate_source'
(in analyses/sources_work.sql:1:1)
(in dbt_packages/codegen/macros/generate_source.sql:17:31)
--> analyses/sources_work.sql:1:1
```

Structured logs
```
[{
"resource": "/analyses/sources_work.sql",
"owner": "_generated_diagnostic_collection_name_#0",
"code": "1501",
"severity": 8,
"message": "dbt1501: Failed to render SQL unknown function: In dispatch: No macro named 'generate_source' found within namespace: 'codegen'\n Searched for: 'my_new_project.snowflake__generate_source', 'my_new_project.snowflake__generate_source', 'my_new_project.default__generate_source', 'my_new_project.default__generate_source', 'my_new_project.generate_source', 'my_new_project.generate_source'\n(in analyses/sources_work.sql:1:1)\n(in dbt_packages/codegen/macros/generate_source.sql:17:31)\n --> analyses/sources_work.sql:1:1",
"source": "dbt",
"startLineNumber": 1,
"startColumn": 1,
"endLineNumber": 2,
"endColumn": 1,
"origin": "extHost1"
}]
```

### Steps to reproduce

### Expected results

### Actual results
```
select distinct
table_schema as "table_schema",
table_name as "table_name",

case table_type
when 'BASE TABLE' then 'table'
when 'EXTERNAL TABLE' then 'external'
when 'MATERIALIZED VIEW' then 'materializedview'
else lower(table_type)
end as "table_type"

from copilot_converters.information_schema.tables
where table_schema ilike 'dbt_artifacts'
and table_name ilike '%'
and table_name not ilike ''
/* {"app": "dbt", "connection_name": "", "dbt_version": "2.0.0", "profile_name": "user", "target_name": "dev"} */
```

### Screenshots and log output

### System information
**The contents of your `packages.yml` file:**
```
packages:
- package: dbt-labs/codegen
version: 0.14.0
```

**Which database are you using dbt with?**
- [ ] postgres
- [ ] redshift
- [ ] bigquery
- [x] snowflake
- [ ] other (specify: ____________)

**The output of `dbt --version`:**
```
17:05:32 Cloud CLI invocation created: a4552264-ffa1-42be-ae39-a78da8f15ba3
17:05:33 dbt-fusion 2.0.0-preview.92
```

**The operating system you're using:**
Mac. In dbt platform studio.

**The output of `python --version`:**

### Additional context

### Are you interested in contributing the fix?

Contributor guide

Open the contributing guide

Research direction

Start with analyses/sources_work.sql and the generate_source macro at dbt_packages/codegen/macros/generate_source.sql:17. Reproduce compilation in dbt Fusion 2.0.0-preview.92 with codegen 0.14.0, then compare it with the working run-operation path. Done means the analysis compiles and resolves generate_source while run-operation continues to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
sql
Domain
database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
47/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.