dbt-labs / dbt-bigquery

dbt-bigquery contains all of the code required to make dbt operate on a BigQuery database.
https://github.com/dbt-labs/dbt-bigquery
Apache License 2.0
224 stars 157 forks source link

[Bug] New RANGE type in bigquery failing when setting descriptions #1341

Closed borjavb closed 1 day ago

borjavb commented 2 months ago

Is this a new bug in dbt-bigquery?

Current Behavior

When using the new RANGE type, in a model, the model will be created correctly, but dbt will fail while trying to update the descriptions of the schema: 400 PATCH <> Range field <field> must have a range element type.

The new SchemaField for RANGE data types expects an extra parameter range_element_type with values {date,datetime,timestamp} in order to work https://cloud.google.com/python/docs/reference/bigquery/latest/google.cloud.bigquery.schema.SchemaField

Expected Behavior

dbt runs correctly and applies the column descriptions without erroring

Steps To Reproduce

Create a model with its respective yaml file description, and run it

table_a.sql

SELECT RANGE(DATE '2021-01-01', DATE '2023-01-01') column_range

table_a.yaml

models:
  - name: table_a
    description: something
    columns:
      - name: column_range
        description: placeholder

Relevant log output

400 PATCH <> Range field column_range must have a range element type.

Environment

- OS: Mac Os m1
- Python: 3.9
- dbt-core: 1.8
- dbt-bigquery: v1.8.2

Additional Context

No response

anaghshineh commented 2 months ago

Hey, @borjavb. I was interested in this and took a quick look. Seems to work for me based on some cursory playing around. Are you able to confirm what version of google-cloud-bigquery is running under the hood?

A few observations: