namanraii opened a new pull request, #41327: URL: https://github.com/apache/beam/pull/41327
## Description `WriteToBigQuery` accepts a string schema such as `"name:STRING"`. `get_table_schema_from_string` already stripped spaces around commas, but not around the colon, so `"name: STRING"` (the natural form from the docs and from users) stored the type as `" STRING"`. BigQuery then rejected it with `Invalid value for type: STRING is not a valid value`. This change strips whitespace on both sides of `:` when parsing each field. Compact schemas such as `"name:STRING"` are unchanged. A unit test covers the reported case, spaces around names and types in a multi-field schema, and the compact form. fixes #25704 `CHANGES.md` has a Bugfixes entry for 2.79.0. This is a small bugfix, so no ICLA is attached. ## Testing - `pytest -v apache_beam/io/gcp/bigquery_tools_test.py::TestTableSchemaParser::test_get_table_schema_from_string_strips_whitespace` failed before the production change (`' STRING' != 'STRING'`) and passed after. - `pytest -v apache_beam/io/gcp/bigquery_tools_test.py::TestTableSchemaParser` — 2 passed. - `pytest -v apache_beam/io/gcp/bigquery_tools_test.py` — 125 passed. `TestBigQueryWrapper::test_user_agent_insert_all` failed in this environment with `google.auth.exceptions.DefaultCredentialsError` while constructing `BigQueryWrapper()` (no ADC / metadata server). That test does not exercise the schema parser. ## Lint `yapf --diff` (v0.43.0) and `ruff check` (v0.15.7, `sdks/python/pyproject.toml`) were clean on the two Python files. Repo pre-commit hooks are yapf and ruff; isort is covered via ruff. `./gradlew formatChanges` / `validateChanges` were not run (sparse checkout, no Gradle setup). ## AI assistance This patch was written with assistance from Grok Bot. I have reviewed the change. The commit includes a `Generated-by: Grok Bot` trailer, following [ASF Generative Tooling Guidance](https://www.apache.org/legal/generative-tooling.html). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
