dbt-labs / dbt-core

dbt enables data analysts and engineers to transform their data using the same practices that software engineers use to build applications.
https://getdbt.com
Apache License 2.0
9.75k stars 1.62k forks source link

[CT-3098] [Bug] Columns are not exported in the json output of dbt list #8601

Closed frco9 closed 1 year ago

frco9 commented 1 year ago

Is this a new bug in dbt-core?

Current Behavior

I have define a model with columns and an enforced contract. When using dbt --quiet list --resource-types model --output json it outputs models definition without its columns

Expected Behavior

When using the list and has columns were defined, I was expecting to get the columns definition.

Steps To Reproduce

Given this model config :

models:
  - name: dataset_test1
    config:
      materialized: table
      contract: { enforced: true }
    columns:
      - name: CTRY_C
        description: This is a column
        data_type: varchar

Then run the following command : dbt --quiet list --resource-types model --output json

Relevant log output

{
    "name": "dataset_test1",
    "resource_type": "model",
    "package_name": "demo_dbt",
    "original_file_path": "models/example/dataset_test1.sql",
    "unique_id": "model.demo_dbt.dataset_test1",
    "alias": "dataset_test1",
    "config": {
        "enabled": true,
        "alias": null,
        "schema": null,
        "database": null,
        "tags": [],
        "meta": {},
        "group": null,
        "materialized": "table",
        "incremental_strategy": null,
        "persist_docs": {},
        "quoting": {},
        "column_types": {},
        "full_refresh": null,
        "unique_key": null,
        "on_schema_change": "ignore",
        "grants": {},
        "packages": [],
        "docs": {
            "show": true,
            "node_color": null
        },
        "contract": {
            "enforced": true
        },
        "post-hook": [],
        "pre-hook": []
    },
    "tags": [],
    "depends_on": {
        "macros": ["macro.demo_dbt.get_latest_snapshot", "macro.demo_dbt.get_reference_ts", "macro.dbt.dateadd"],
        "nodes": []
    }
}

### Environment

```markdown
- OS: MacOS 13.4
- Python: 3.9.9
- dbt: 1.5.1

Which database adapter are you using with dbt?

other (mention it in "Additional Context")

Additional Context

athena: 1.5.1

jtcohen6 commented 1 year ago

@frco9 Try:

dbt --quiet list --resource-types model --output json --output-keys name columns # whatever else you want
{"name": "my_model", "columns": {"id": {"name": "id", "description": "This is my id column", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}}

(This is mentioned in the docs, though only briefly)

frco9 commented 1 year ago

It works Thanks ! I thought it would only apply to keys already shown, but indeed it is not !