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: load table from json #1248

Closed

Conversation

abecerrilsalas
Copy link
Contributor

@abecerrilsalas abecerrilsalas commented May 11, 2022

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
@@ -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"),)
Copy link
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
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?

self.to_delete.insert(0, table)

# job_config = bigquery.LoadJobConfig()
job_config = bigquery.LoadJobConfig()
Copy link
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

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)
Copy link
Contributor

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
Contributor

Closing in favor of #1646.

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: 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