Skip to content

feat(bigquery): add column data policies to SchemaField - #18710

Open
AliAbouelazm wants to merge 2 commits into
googleapis:mainfrom
AliAbouelazm:feat/bigquery-data-policies
Open

AliAbouelazm wants to merge 2 commits into
googleapis:mainfrom
AliAbouelazm:feat/bigquery-data-policies

Conversation

@AliAbouelazm

Copy link
Copy Markdown

Adds data_policies to SchemaField so callers can read and set column data policy names without using _properties. Names are serialized as dataPolicies entries, and equality and hashing account for them regardless of order.

The tests cover unset, null, empty, multiple and nested policies, API round trips, repr, and schemas that use policy tags on other columns. The usage guide explains the API representation and the limits around removing the last policy and dataPolicyList precedence.

Validation on Python 3.12: 2,859 unit tests passed, 2 skipped. Black, flake8, mypy and the documentation build passed. The test process used default OpenTelemetry sampling because the inherited setting caused the same seven failures on unmodified main.

Fixes #17617.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for column-level data policies in BigQuery schemas by adding a data_policies property to SchemaField, along with documentation and comprehensive unit tests. The review feedback suggests two key improvements: adding a type check to prevent strings or bytes from being silently iterated character-by-character when passed to data_policies, and replacing fragile index slicing ([:-1]) in the __repr__ method with dynamic filtering based on the named tuple's fields to ensure future-proof code.

Comment thread packages/google-cloud-bigquery/google/cloud/bigquery/schema.py
Comment thread packages/google-cloud-bigquery/google/cloud/bigquery/schema.py
@AliAbouelazm
AliAbouelazm marked this pull request as ready for review October 16, 2026 06:21
@AliAbouelazm
AliAbouelazm requested review from a team as code owners October 16, 2026 06:21
@AliAbouelazm
AliAbouelazm requested review from tswast and removed request for a team October 16, 2026 06:21

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

google-cloud-bigquery: support column-level data policies (dataPolicies) in SchemaField

1 participant