-
Notifications
You must be signed in to change notification settings - Fork 301
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: load table from json #1248
fix: load table from json #1248
Conversation
…ilsalas/python-bigquery into load_table_from_json_bug
…ilsalas/python-bigquery into load_table_from_json_bug
tests/system/test_client.py
Outdated
@@ -859,6 +859,69 @@ def test_load_table_from_json_basic_use(self): | |||
self.assertEqual(tuple(table.schema), table_schema) | |||
self.assertEqual(table.num_rows, 2) | |||
|
|||
def test_load_table_from_json_bug_check_with_schema(self): | |||
table_schema = (bigquery.SchemaField("age", "INTEGER", mode="REQUIRED"),) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This field should be type "STRING"
table = helpers.retry_403(Config.CLIENT.create_table)(Table(table_id)) | ||
self.to_delete.insert(0, table) | ||
|
||
job_config = bigquery.LoadJobConfig(schema=table_schema) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to provide schema here?
self.to_delete.insert(0, table) | ||
|
||
# job_config = bigquery.LoadJobConfig() | ||
job_config = bigquery.LoadJobConfig() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add table as destination so it will be created during the load job
if job_config.schema is None: | ||
# make table id | ||
# table_id = "your-project.your_dataset.your_table" | ||
destination = _table_arg_to_table_ref(destination, default_project=self.project) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we calling _table_arg_to_table_ref()
here?
The very first line of get_table()
calls that function.
def get_table(
self,
table: Union[Table, TableReference, TableListItem, str],
retry: retries.Retry = DEFAULT_RETRY,
timeout: TimeoutType = DEFAULT_TIMEOUT,
) -> Table:
""" REMOVED DOCSTRING FOR SPACE """
table_ref = _table_arg_to_table_ref(table, default_project=self.project)
Closing in favor of #1646. |
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:
Fixes #1228 🦕