Skip to content

feat: Add new options to LoadJobConfig and ExternalConfig #2225

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

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

chalmerlowe
Copy link
Collaborator

This commit introduces new configuration options for BigQuery load jobs and external table definitions, aligning with recent updates to the underlying protos.

New options added:

  • time_zone: Specifies the default timezone for parsing timestamps. (Applies to LoadJobConfig, ExternalConfig; CSV & JSON)
  • date_format: Specifies the format for parsing DATE values. (Applies to LoadJobConfig, ExternalConfig; CSV & JSON)
  • datetime_format: Specifies the format for parsing DATETIME values. (Applies to LoadJobConfig, ExternalConfig; CSV & JSON)
  • time_format: Specifies the format for parsing TIME values. (Applies to LoadJobConfig, ExternalConfig; CSV & JSON)
  • timestamp_format: Specifies the format for parsing TIMESTAMP values. (Applies to LoadJobConfig, ExternalConfig; CSV & JSON)
  • null_markers: A list of strings to be interpreted as NULL. (Applies to LoadJobConfig, ExternalConfig (via CSVOptions); CSV only)
  • source_column_name_match_option: Controls how source columns are matched to the schema. (Applies to LoadJobConfig, ExternalConfig (via CSVOptions); CSV only)

Changes include:

  • Added corresponding properties (getters/setters) to LoadJobConfig, LoadJob, ExternalConfig, and CSVOptions.
  • Updated docstrings and type hints for all new attributes.
  • Updated unit tests to cover the new options, ensuring they are correctly handled during object initialization, serialization to API representation, and deserialization from API responses.

This commit introduces new configuration options for BigQuery load jobs and external table definitions, aligning with recent updates to the underlying protos.

New options added:

- `time_zone`: Specifies the default timezone for parsing timestamps.
  (Applies to LoadJobConfig, ExternalConfig; CSV & JSON)
- `date_format`: Specifies the format for parsing DATE values.
  (Applies to LoadJobConfig, ExternalConfig; CSV & JSON)
- `datetime_format`: Specifies the format for parsing DATETIME values.
  (Applies to LoadJobConfig, ExternalConfig; CSV & JSON)
- `time_format`: Specifies the format for parsing TIME values.
  (Applies to LoadJobConfig, ExternalConfig; CSV & JSON)
- `timestamp_format`: Specifies the format for parsing TIMESTAMP values.
  (Applies to LoadJobConfig, ExternalConfig; CSV & JSON)
- `null_markers`: A list of strings to be interpreted as NULL.
  (Applies to LoadJobConfig, ExternalConfig (via CSVOptions); CSV only)
- `source_column_name_match_option`: Controls how source columns are matched to the schema.
  (Applies to LoadJobConfig, ExternalConfig (via CSVOptions); CSV only)

Changes include:
- Added corresponding properties (getters/setters) to `LoadJobConfig`, `LoadJob`, `ExternalConfig`, and `CSVOptions`.
- Updated docstrings and type hints for all new attributes.
- Updated unit tests to cover the new options, ensuring they are correctly handled during object initialization, serialization to API representation, and deserialization from API responses.
@product-auto-label product-auto-label bot added size: l Pull request size is large. api: bigquery Issues related to the googleapis/python-bigquery API. labels Jun 26, 2025
chalmerlowe and others added 13 commits June 26, 2025 06:09
Adds miss, hit, and setter tests to `tests/unit/job/test_load_config.py`
for the following properties of `LoadJobConfig`:
- time_zone
- date_format
- datetime_format
- time_format
- timestamp_format
- null_markers
- source_column_name_match_option

These tests verify that the properties can be set, retrieved, and
correctly interact with the underlying configuration dictionary.
This commit restores user changes from commit a9b187f
that were inadvertently overwritten. These changes include:
- Addition of SourceColumnMatch enum in enums.py.
- Updates to docstrings in external_config.py and job/load.py.
- Renaming of source_column_name_match_option to source_column_match_strategy
  in LoadJobConfig and LoadJob, now using the SourceColumnMatch enum.
- Adjustments in related unit tests in test_load.py and test_external_config.py.

Additionally, this commit incorporates the new unit tests for all recently
added LoadJobConfig properties in tests/unit/job/test_load_config.py.

Corrections were made to tests/unit/job/test_load.py to align with the
renamed source_column_match_strategy property and its enum type.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the googleapis/python-bigquery API. size: l Pull request size is large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant