dbt-bigquery icon indicating copy to clipboard operation
dbt-bigquery copied to clipboard

[Feature] Change BigQuery `labels` to be additive instead of "clobber"

Open moseleyi opened this issue 1 year ago • 8 comments

Current Behavior

When we set labels in dbt_project.yml

      finance: 
        +labels:
          domain: finance
          test: "yes"

and then extra ones in the model file

{{
  config(
    labels = {"type": "financial", "contains_pii": "yes"}
  )
}}

The configuration of the model gets overwritten, even though the labels are different.

image

Expected Behavior

I expected all labels to be applied and if a label is specified twice then for the single model configuration to take precedence.

Steps To Reproduce

Create a sample model in folder models/finance/finance_test.sql and add the following configuration:

{{
  config(
    labels = {"type": "financial", "contains_pii": "yes"}
  )
}}

In dbt_project.yml add the following configuration:

models:
  project_name:
    finance:
      +labels:
        domain: finance
        test: yes

Relevant log output

No response

Environment

- OS: Windows 10
- Python: 3.8.4rc1
- dbt: 1.7.7
- dbt-bigquery: 1.7.4

Additional Context

No response

moseleyi avatar Feb 06 '24 17:02 moseleyi

Thanks for reaching out @moseleyi !

Based on the docs here, this looks like the intended behavior rather than a bug.

So I'm going to close this as "not planned".

In order to make the documentation for the labels config in dbt-bigquery more clear, I've opened this issue: https://github.com/dbt-labs/docs.getdbt.com/issues/4864

dbeatty10 avatar Feb 06 '24 19:02 dbeatty10

Why wouldn't you plan it? Having it like it is right now, diminishes the usability of this feature.

It's expected as per the docs but surely they should be additive? They should work just like tags

moseleyi avatar Feb 07 '24 09:02 moseleyi

@graciegoheen and I discussed this briefly.

The current (non-additive) behavior of labels is clearly documented, so it is not a bug. But we're open to recategorizing this as a feature request to get a feel if others are interested in this as well.

At this point, it's not a priority for us, and I'm labeling this as "refinement" for us to determine at some point in the future if we'd want to adopt this or not.

In the meantime, you could take a look at what others have done as a workaround here.

dbeatty10 avatar Feb 10 '24 04:02 dbeatty10

@dbeatty10 Given historic issues such as https://github.com/dbt-labs/dbt-bigquery/issues/893, this issue here, the discussion you mention on dbt Discourse, this seems to be a relevant issue for many community members. Even if this is not a bug and currently intended behavior, many seem to expect additive behavior, and it would make using labels much easier.

The proposed workarounds are not optimal:

  • Repeated labels: This workaround is not DRY and creates potentially lots of duplication
  • Post-hooks: Running so many post-hooks is not efficient and creates a lot of overhead

davidwitk avatar Feb 12 '24 10:02 davidwitk

I feel the current one could be related to this one https://github.com/dbt-labs/dbt-bigquery/issues/1110

iamtodor avatar Feb 20 '24 11:02 iamtodor

This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please comment on the issue or else it will be closed in 7 days.

github-actions[bot] avatar Aug 26 '24 01:08 github-actions[bot]

Can we please not stale the issue?

iamtodor avatar Aug 26 '24 05:08 iamtodor

Yes, this is still very much valid feature I would like to see!

moseleyi avatar Aug 26 '24 06:08 moseleyi