dbt-labs / dbt-labs/dbt-codegen

The generate_model_yaml function is only writing column descriptions for tables with table materializations

Open
#247 6 comments 8 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
For non-table materialized models, the `generate_model_yaml` method does not generate columns description.

### Steps to reproduce
1. Write an intermediary model of type `materialized_view`:

```yaml
-- models/int_orders.sql

{{ config(
materialized='view' -- Specifies that this model should be materialized as a view
) }}

WITH orders AS (
SELECT
customer_id,
order_id,
order_date,
order_status,
total_amount
FROM {{ ref('raw_orders') }} -- Reference a raw source table
)

SELECT *
FROM orders
```

2. Then, execute `generate_model_yaml` for this model.
```yaml
version: 2

models:
- name: int_orders
description: ""
columns:
- name: customer_id
data_type: uuid
description: ""

- name: order_id
data_type: uuid
description: ""

- name: order_date
data_type: timestamp
description: ""

- name: order_status
data_type: character varying
description: ""

- name: total_amount
data_type: numeric
description: ""
```

### Actual results
```yaml
version: 2

models:
- name: int_orders
description: ""
columns:
```

### System information
**The contents of your `packages.yml` file:**
```yaml
packages:
- package: calogica/dbt_expectations
version: [">=0.1.0", "<1.0.0"]
- package: dbt-labs/audit_helper
version: [">=0.3.0", "<1.0.0"]
# - package: jpmmcneill/dbt_graph_theory
# version: [">=0.2.0", "<1.0.0"]
- package: calogica/dbt_date
version: [">=0.1.0", "<1.0.0"]
- package: dbt-labs/logging
version: [">=0.1.0", "<1.0.0"]
- package: dbt-labs/dbt_utils
version: [">=1.1.0", "<2.0.0"]
- package: elementary-data/elementary
version: 0.16.1
- package: dbt-labs/codegen
version: 0.13.1

```

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

**The output of `dbt --version`:**
```
Core:
- installed: 1.9.1
- latest: 1.9.1 - Up to date!

Plugins:
- postgres: 1.9.0 - Up to date!
```

**The operating system you're using:**
Apple M3 Pro

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

Contributor guide

Open the contributing guide

Research direction

Start by locating the generate_model_yaml function and reproduce the issue with the materialized_view example against PostgreSQL. Compare its output for a table materialization with the shown non-table output; done means the generated YAML includes each selected column with its data type and description for non-table materialized models.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgres, sql
Domain
databases, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.