Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Support the updating of incremental model description after initial creation #585

Open
2 tasks done
kiwamizamurai opened this issue Mar 14, 2024 · 6 comments · May be fixed by dbt-labs/dbt-bigquery#1139
Open
2 tasks done
Assignees
Labels
pkg:dbt-bigquery Issue affects dbt-bigquery type:enhancement New feature request

Comments

@kiwamizamurai
Copy link

kiwamizamurai commented Mar 14, 2024

Is this a new bug in dbt-bigquery?

  • I believe this is a new bug in dbt-bigquery
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

Table description does not changed even thought I modify the schema.yml with persist_docs=true and materialized=incremental.

Expected Behavior

Table description should be altered regardless of materialization type.

Steps To Reproduce

  1. write the hogehoge.sql as follows
{{
  config(
    materialized = 'incremental',
    persist_docs = {"relation": true, "columns": true}
  )
}}

select 1 as first_col
from unnest([struct(1 as dual)]) as dual

{% if is_incremental() %}
    where 1=1
{% endif %}
  1. write the hogehoge.yaml as follows
version: 2

models:
  - name: hogehoge
    description: before_changed
    columns:
      - name: first_col
        description: before_changed
  1. run the command dbt build --select hogehoge
  2. confirm that the table is created in bigquery console
  3. modify the sample.yaml as follows
version: 2

models:
  - name: hogehoge
    description: after_changed
    columns:
      - name: first_col
        description: after_changed
  1. confirm that only the column description is updated

Relevant log output

08:36:20  Concurrency: 4 threads (target='dev')
08:36:20  
08:36:20  1 of 1 START sql table model dbt_some_project.hogehoge ...................... [RUN]
08:36:24  1 of 1 OK created sql table model dbt_some_project.hogehoge ................. [CREATE TABLE (1.0 rows, 0 processed) in 4.13s]
08:36:24  
08:36:24  Finished running 1 table model in 0 hours 0 minutes and 9.00 seconds (9.00s).
08:36:24  
08:36:24  Completed successfully

Environment

- OS: MacOS13.6
- Python: 3.11.7
- dbt-core: 1.7.6
- dbt-bigquery: 1.7.6

Additional Context

I have not observed this phenomenon with other data platform adapter like snowflake.

@kiwamizamurai kiwamizamurai added type:bug Something isn't working as documented triage:product In Product's queue labels Mar 14, 2024
@kiwamizamurai kiwamizamurai changed the title [Bug] Table description does not updated in spite of setting persist_docs [Bug] Table description does not be altered in spite of setting persist_docs Mar 14, 2024
@dataders dataders changed the title [Bug] Table description does not be altered in spite of setting persist_docs [Feature] Support the updating of incremental model description after initial creation Mar 25, 2024
@dataders dataders added type:enhancement New feature request and removed type:bug Something isn't working as documented labels Mar 25, 2024
@dataders
Copy link
Contributor

thanks for opening @kiwamizamurai! Your example was excellent, I was able to reproduce!

AFAICT,column-level docs persistence was first introduced via dbt-labs/dbt-core#2402. The comment above bigquery__persist_docs is telling:

https://github.com/dbt-labs/dbt-bigquery/blob/955afbd74b19d37f6c7919a4a92dd2cc50eae905/dbt/include/bigquery/macros/adapters.sql#L98-L99

From this, I'm assuming the implementation is that a relation (table) description is only created at time of table creation, and not updated like that of columns.

This is a nitpick, but I accordingly changed this from being a bug to an enhancement, as we've never supported in dbt-bigquery the modification of table description metadata after creation.

However, I see no reason why bigquery__persist_docs could not be modified to include an "update table description if different that what is currently documented, similar to the .alter_table_comment() method you propose in dbt-labs/dbt-bigquery#1139. However, I see the adapter already has a update_table_description() method that might be of use instead?

https://github.com/dbt-labs/dbt-bigquery/blob/955afbd74b19d37f6c7919a4a92dd2cc50eae905/dbt/adapters/bigquery/impl.py#L627-L636

@dataders dataders added triage:awaiting-response Awaiting a response from the reporter and removed triage:product In Product's queue labels Mar 25, 2024
@kiwamizamurai
Copy link
Author

kiwamizamurai commented Mar 25, 2024

I understood it. Thank you. @dataders
So, I should use .update_table_description() instead of .alter_table_comment() in my PR dbt-labs/dbt-bigquery#1139. Is is right?

https://github.com/kiwamizamurai/dbt-bigquery/blob/fix/1138-table-description/dbt/include/bigquery/macros/adapters.sql#L52-L54

@github-actions github-actions bot added triage:product In Product's queue and removed triage:awaiting-response Awaiting a response from the reporter labels Mar 25, 2024
@dataders
Copy link
Contributor

So, I should use .update_table_description() instead of . alter_table_comment() in my PR dbt-labs/dbt-bigquery#1139.

Yeah give it a try? Maybe .update_table_description() doesn't work right and we need to change or delete it, but i think it it worth trying it out.

if that works, then we include a call to it within bigquery__persist_docs

@kiwamizamurai
Copy link
Author

@dataders
OK, Let me try it.

@kiwamizamurai
Copy link
Author

kiwamizamurai commented Mar 26, 2024

I modified the code
dbt-labs/dbt-bigquery@13f1701

@amychen1776 amychen1776 removed the triage:product In Product's queue label Aug 28, 2024
@mikealfare mikealfare added the pkg:dbt-bigquery Issue affects dbt-bigquery label Jan 14, 2025
@mikealfare mikealfare transferred this issue from dbt-labs/dbt-bigquery Jan 14, 2025
mikealfare added a commit that referenced this issue Jan 20, 2025
* Bump mypy from 1.5.0 to 1.5.1

Bumps [mypy](https://github.com/python/mypy) from 1.5.0 to 1.5.1.
- [Commits](python/mypy@v1.5.0...v1.5.1)

---
updated-dependencies:
- dependency-name: mypy
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Add automated changelog yaml from template for bot PR

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Github Build Bot <buildbot@fishtownanalytics.com>
Co-authored-by: Matthew McKnight <91097623+McKnight-42@users.noreply.github.com>
Co-authored-by: Mike Alfare <13974384+mikealfare@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg:dbt-bigquery Issue affects dbt-bigquery type:enhancement New feature request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants