Skip to content
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

fix: no longer set autodetect=True with empty schema in load_table_from_json() #1801

Closed
wants to merge 3 commits into from

Conversation

Linchin
Copy link
Contributor

@Linchin Linchin commented Jan 25, 2024

In the past, if we don't set autodetect=True when schema is empty, the backend will throw an error. This has changed now, backend will autodetect even if we don't send autodetect value. This has caused some issues with users, when the detected schema doesn't match that of the existing table. (#1228, #1563)

For more discussions, see #1228.

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #1228 🦕

@Linchin Linchin requested review from tswast and chalmerlowe January 25, 2024 23:35
@Linchin Linchin requested review from a team as code owners January 25, 2024 23:35
@product-auto-label product-auto-label bot added size: xs Pull request size is extra small. api: bigquery Issues related to the googleapis/python-bigquery API. labels Jan 25, 2024
@@ -2833,9 +2833,6 @@ def load_table_from_json(

new_job_config.source_format = job.SourceFormat.NEWLINE_DELIMITED_JSON

if new_job_config.schema is None:
Copy link
Contributor

Choose a reason for hiding this comment

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

We are still getting test failures with this change:


>           raise exceptions.from_http_response(exc.response)
E           google.api_core.exceptions.BadRequest: 400 POST https://bigquery.googleapis.com/upload/bigquery/v2/projects/precise-truck-742/jobs?uploadType=multipart: No schema specified on job or table.

I think we can only omit these if the table already exists and we are appending rows.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I think I made a mistake in my test code and created the table with schema in it.

@Linchin
Copy link
Contributor Author

Linchin commented Jan 29, 2024

use #1804 instead

@Linchin Linchin closed this Jan 29, 2024
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: xs Pull request size is extra small.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

load_table_from_json interpolates string as int
2 participants