Title: catch pyarrow.lib.ArrowTypeError for augment_schema · Issue #15698 · googleapis/google-cloud-python · GitHub
Open Graph Title: catch pyarrow.lib.ArrowTypeError for augment_schema · Issue #15698 · googleapis/google-cloud-python
X Title: catch pyarrow.lib.ArrowTypeError for augment_schema · Issue #15698 · googleapis/google-cloud-python
Description: Is your feature request related to a problem? Please describe. The problematic field name is not returned in the error for the augment_schema function like it is elsewhere. This can then show up in places like load_table_from_dataframe s...
Open Graph Description: Is your feature request related to a problem? Please describe. The problematic field name is not returned in the error for the augment_schema function like it is elsewhere. This can then show up in...
X Description: Is your feature request related to a problem? Please describe. The problematic field name is not returned in the error for the augment_schema function like it is elsewhere. This can then show up in...
Opengraph URL: https://github.com/googleapis/google-cloud-python/issues/15698
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"catch pyarrow.lib.ArrowTypeError for augment_schema","articleBody":" **Is your feature request related to a problem? Please describe.**\nThe problematic field name is not returned in the error for the `augment_schema` function like it is elsewhere. This can then show up in places like `load_table_from_dataframe` since `augment_schema` is called.\n\n```\npyarrow.lib.ArrowTypeError: Expected bytes, got a 'float' object\n\n File \"...\", line 57, in load_table_bq\n job = client.load_table_from_dataframe(\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/.../.venv/lib/python3.12/site-packages/google/cloud/bigquery/client.py\", line 2781, in load_table_from_dataframe\n new_job_config.schema = _pandas_helpers.dataframe_to_bq_schema(\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/.../.venv/lib/python3.12/site-packages/google/cloud/bigquery/_pandas_helpers.py\", line 491, in dataframe_to_bq_schema\n bq_schema_out = augment_schema(dataframe, bq_schema_out)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/.../.venv/lib/python3.12/site-packages/google/cloud/bigquery/_pandas_helpers.py\", line 520, in augment_schema\n arrow_table = pyarrow.array(dataframe.reset_index()[field.name])\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"pyarrow/array.pxi\", line 360, in pyarrow.lib.array\n File \"pyarrow/array.pxi\", line 87, in pyarrow.lib._ndarray_to_array\n File \"pyarrow/error.pxi\", line 92, in pyarrow.lib.check_status\n```\n\n **Describe the solution you'd like**\nFix could be similar to googleapis/python-bigquery#1836 \n\n```python\ndef augment_schema(dataframe, current_bq_schema):\n ...\n for field in current_bq_schema:\n if field.field_type is not None:\n augmented_schema.append(field)\n continue\n try:\n arrow_table = pyarrow.array(dataframe.reset_index()[field.name])\n except ArrowTypeError:\n msg = f\"\"\"Error converting Pandas column with name: \"{field.name}\" and datatype: \"{field.dtype}\" to an appropriate pyarrow datatype: ...\"\"\"\n _LOGGER.error(msg)\n raise ArrowTypeError(msg)\n```\n\nHappy to submit a PR if this would be approved?","author":{"url":"https://github.com/j-blackwell","@type":"Person","name":"j-blackwell"},"datePublished":"2025-02-11T13:57:37Z","url":"https://github.com/googleapis/google-cloud-python/issues/15698"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:64d0e0d7-003b-7cf0-a086-3a5a413e6574 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C788:398D8A:BBDCA8:F7322F:6AFE8AB2 |
| html-safe-nonce | 5da69bc8803dae9386be6e495d7e63bb875acda83f5f6f5af1cf82e8d268396f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNzg4OjM5OEQ4QTpCQkRDQTg6RjczMjJGOjZBRkU4QUIyIiwidmlzaXRvcl9pZCI6IjE2NjM4ODkzMjg5MDU4MTY3NTQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | fd85832fc5fe629ed124bffb04411bfd73ca4b6dd66eb4733244f777158bfbfe |
| hovercard-subject-tag | issue:4011478261 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/googleapis/google-cloud-python/15698/issue_layout |
| twitter:image | https://opengraph.githubassets.com/393904541c8ae6a4cc3037d4b387206f1a35572d1527aeb5b9fe7ae0ea564b66/googleapis/google-cloud-python/issues/15698 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/393904541c8ae6a4cc3037d4b387206f1a35572d1527aeb5b9fe7ae0ea564b66/googleapis/google-cloud-python/issues/15698 |
| og:image:alt | Is your feature request related to a problem? Please describe. The problematic field name is not returned in the error for the augment_schema function like it is elsewhere. This can then show up in... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | j-blackwell |
| hostname | github.com |
| expected-hostname | github.com |
| None | b3c0f155eafc27e60db6e254d1ffff0e072e9ab3b4018a5ee518797c19d89f86 |
| turbo-cache-control | no-preview |
| go-import | github.com/googleapis/google-cloud-python git https://github.com/googleapis/google-cloud-python.git |
| octolytics-dimension-user_id | 16785467 |
| octolytics-dimension-user_login | googleapis |
| octolytics-dimension-repository_id | 16316451 |
| octolytics-dimension-repository_nwo | googleapis/google-cloud-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 16316451 |
| octolytics-dimension-repository_network_root_nwo | googleapis/google-cloud-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 4a10310af51a1bfffbedc4fd81cb582acf0cb0ff |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width