Skip to content

[Bug] Using on_schema_change makes reporting "bytes processed" in run results incorrect in BigQuery #12277

@cheyuriy

Description

@cheyuriy

Is this a new bug in dbt-core?

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

Current Behavior

Using the on_schema_change='append_new_columns' configuration option (and possibly other values too) for an incremental model makes DBT split the calculation into two scripts - first one creates temp table (and checks for schema changes using it) and the second one performs actual incremental update of the target table.

However, it seems taht DBT only counts the second script when showing "bytes processed" (in logs, run results, etc). This behavior heavily underestimates the cost of such models. For one of them the difference were more than x300. And accurate cost reporting is extremely important in BigQuery when using the on-demand billing plan.

Expected Behavior

DBT must count ALL scripts and queries run to build a table for "bytes processed".

Steps To Reproduce

  1. Create a simple incremental model with on_schema_change option. I.e. the following configuration:
{{
    config(
        materialized='incremental',
        partition_by = {'field':'created','data_type':'timestamp'},
        on_schema_change='append_new_columns',
        incremental_strategy = 'insert_overwrite'
    )
}}
  1. Run incremental build.
  2. Check logs for "bytes processed"
  3. Compare with actual bytes billed using BigQuery's INFORMATION_SCHEMA.JOBS view, or other mediums.

Relevant log output

Environment

- OS: DBT Cloud
- Python: -
- dbt: `latest`

Which database adapter are you using with dbt?

bigquery

Additional Context

Using DBT Cloud with DBT version set to "latest" for runs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions