Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.

fix: load table from json - #1248

Closed
abecerrilsalas wants to merge 39 commits into
googleapis:mainfrom
abecerrilsalas:load_table_from_json_bug
Closed

abecerrilsalas wants to merge 39 commits into
googleapis:mainfrom
abecerrilsalas:load_table_from_json_bug

Conversation

@abecerrilsalas

@abecerrilsalas abecerrilsalas commented May 11, 2022 •

Copy link
Copy Markdown
Contributor

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 🦕

@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 May 11, 2022
@steffnay steffnay changed the title bug: load table from json fix: load table from json May 13, 2022
@product-auto-label product-auto-label Bot added size: s Pull request size is small. and removed size: xs Pull request size is extra small. labels May 13, 2022
@product-auto-label product-auto-label Bot added size: m Pull request size is medium. and removed size: s Pull request size is small. labels May 17, 2022
Comment thread google/cloud/bigquery/client.py Resolved
Comment thread tests/system/test_client.py Resolved
Comment thread google/cloud/bigquery/client.py Resolved
Comment thread google/cloud/bigquery/client.py Resolved
Comment thread tests/system/test_client.py Outdated
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"),)

Copy link
Copy Markdown
Contributor

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)

Copy link
Copy Markdown
Contributor

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?

Comment thread tests/system/test_client.py Resolved
Comment thread tests/system/test_client.py Resolved
Comment thread tests/system/test_client.py Resolved
self.to_delete.insert(0, table)

# job_config = bigquery.LoadJobConfig()
job_config = bigquery.LoadJobConfig()

Copy link
Copy Markdown
Contributor

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

Comment thread tests/system/test_client.py Resolved
Comment thread tests/system/test_client.py Resolved
Comment thread tests/system/test_client.py Resolved
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)

@chalmerlowe chalmerlowe May 22, 2023 •

Copy link
Copy Markdown
Collaborator

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)

@chalmerlowe chalmerlowe added kokoro:run Add this label to force Kokoro to re-run the tests. kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Jul 20, 2023
@yoshi-kokoro yoshi-kokoro removed kokoro:run Add this label to force Kokoro to re-run the tests. kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Jul 20, 2023
@meredithslota

Copy link
Copy Markdown
Contributor

Closing in favor of googleapis/google-cloud-python#15720.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api: bigquery Issues related to the googleapis/python-bigquery API. size: m Pull request size is medium.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

load_table_from_json interpolates string as int

6 participants