From 42368f9bd03fb96479a3c2ec4b0fbac21ad347ab Mon Sep 17 00:00:00 2001 From: Ollie <35436396+oliverrmaa@users.noreply.github.com> Date: Fri, 28 Jan 2022 07:16:51 -0800 Subject: [PATCH] Make sure partition_by is in config if setting require_partition_filter (#109) * initial commit * update changelog * fix typo in changelog * Hui's feedback --- CHANGELOG.md | 3 +++ dbt/adapters/bigquery/impl.py | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 48991628b..4b8d765e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,12 +4,15 @@ ### Fixes - Fix test related to preventing coercion of boolean values (True, False) to numeric values (0, 1) in query results ([#93](https://github.com/dbt-labs/dbt-bigquery/issues/93)) +- Add a check in `get_table_options` to check that the table has a `partition_by` in the config. +This will prevent BigQuery from throwing an error since non-partitioned tables cannot have `require_partition_filter` ([#107](https://github.com/dbt-labs/dbt-bigquery/issues/107)) ### Under the hood - Address BigQuery API deprecation warning and simplify usage of `TableReference` and `DatasetReference` objects ([#97](https://github.com/dbt-labs/dbt-bigquery/issues/97)) ### Contributors - [@hui-zheng](https://github.com/hui-zheng)([#50](https://github.com/dbt-labs/dbt-bigquery/pull/50)) +- [@oliverrmaa](https://github.com/oliverrmaa)([#109](https://github.com/dbt-labs/dbt-bigquery/pull/109)) ## dbt-bigquery 1.0.0 (December 3, 2021) diff --git a/dbt/adapters/bigquery/impl.py b/dbt/adapters/bigquery/impl.py index 73bf66e20..cb703f8b0 100644 --- a/dbt/adapters/bigquery/impl.py +++ b/dbt/adapters/bigquery/impl.py @@ -748,7 +748,8 @@ def get_table_options( # It doesn't apply the `require_partition_filter` option for a temporary table # so that we avoid the error by not specifying a partition with a temporary table # in the incremental model. - if config.get('require_partition_filter') is not None: + if config.get('require_partition_filter') is not None and \ + config.get('partition_by') is not None: opts['require_partition_filter'] = config.get( 'require_partition_filter') if config.get('partition_expiration_days') is not None: