dbt-labs / dbt-codegen

Macros that generate dbt code
https://hub.getdbt.com/dbt-labs/codegen/latest/
Apache License 2.0
464 stars 102 forks source link

generate_model_yaml returns empty column list on BigQuery #107

Closed NicolasGuary closed 1 year ago

NicolasGuary commented 1 year ago

Describe the bug

Tested using 9.0.0 and 8.1.0

When trying to generate YAML for an existing model based on a BigQuery table, I get an empty column section. I believe it is linked to https://github.com/dbt-labs/dbt-codegen/issues/69

Steps to reproduce

Running :

dbt run-operation generate_model_yaml --args '{"model_name": "<my_model>"}'

Returns :

16:46:36  Unable to do partial parsing because config vars, config profile, or config target have changed
16:46:51  version: 2

models:
  - name: <my_model>
    description: ""
    columns:

Expected results

Expected the columns section to contain all the columns of the table in BigQuery.

Actual results

An empty column section.

The output of dbt --version: Running from dbt Cloud CLI

NicolasGuary commented 1 year ago

Find what caused the bug : you should run dbt run --select <model_name> before trying to generate the model's YAML and that makes sense.

The workflow should then be :

  1. Generate your source using generate_source
  2. Generate the base SQL and edit it if needed using generate_base_model
  3. Run dbt run --select with the previously created model to make it "discoverable" in dbt
  4. Use generate_model_yaml to create the YAML associated with your updated model

Closing the issue and thank's for this really useful lib ! :muscle: