fix(google): Support Table objects in BigQueryHook.create_table table_resource - #73099
Open
X33834 wants to merge 1 commit into
Open
fix(google): Support Table objects in BigQueryHook.create_table table_resource#73099X33834 wants to merge 1 commit into
X33834 wants to merge 1 commit into
Conversation
…_resource The `table_resource` parameter is typed and documented to accept a dict, `Table`, `TableReference`, or `TableListItem`, but the implementation only worked with a plain dict. `Table.from_api_repr()` was called backwards on a `Table` instance (TypeError) and raw `**`-unpacking was applied to `TableReference`/`TableListItem` objects (TypeError: not a mapping). Convert any object input to a plain dict via `.to_api_repr()`, wrapping a bare `TableReference` under `"tableReference"` since its serialization is flat, before merging `schema_fields`. Add unit tests covering dict, Table, TableReference, TableListItem inputs and schema merging. Closes: apache#73091
|
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide
|
shahar1
requested changes
Sep 13, 2026
shahar1
left a comment
Contributor
There was a problem hiding this comment.
Welcome to Apache Airflow!
Before letting maintainers to review your PR:
- Please add AI attribution as part of the PR body according to the PR template.
- We don't use conventional commits - please remove
fix(google):from title.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Closes: #73091
BigQueryHook.create_table()'stable_resourceparameter is typed and documented to accept adict,Table,TableReference, orTableListItem, but the implementation only worked with a plaindict:Tableinstance:Table.from_api_repr()was called backwards (it expects an API-JSON dict, not aTableobject) →TypeError: argument of type 'Table' is not iterableTableReference/TableListItem: raw**-unpacking on a non-mapping →TypeError: 'TableReference' object is not a mappingThis is reachable from
BigQueryCreateTableOperator, which has the identical type hint and forwardstable_resourcestraight into the hook. A DAG author who follows the documented type hint and passes aTableobtained fromget_table()/list_tables()hits a crash.Solution
Convert any object input to a plain dict via
.to_api_repr()before mergingschema_fieldsand building the finalTable. A bareTableReferenceis wrapped under"tableReference"since itsto_api_repr()is flat, unlikeTable/TableListItem.Tests
Added unit tests in
TestTableOperationscovering all four input forms (dict,Table,TableReference,TableListItem) plus schema merging:test_create_table_with_table_objecttest_create_table_with_table_reference_objecttest_create_table_with_table_list_itemtest_create_table_with_table_object_and_schema_fieldsRan locally: conversion logic verified against real
google.cloud.bigqueryobjects;ruff checkandpy_compileclean. Full provider test suite runs in CI via breeze.