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

Document how to construct external tables #773

Description

@machow

Is your feature request related to a problem? Please describe.

Currently, the document on creating a table is clear on how to initialize a Table object with a specific fields schema. For example, here is a code snippet from the docs:

image

However, a challenge I faced with these docs is knowing how to create a Table with, e.g., an ExternalConfig set.

Based on the source for Table / unit tests, is the correct approach using a property setter?:

from google.cloud import bigquery
client bigquery.Client()

table = bigquery.Table(...)

# use property setter
table.external_data_configuration = bigquery.ExternalConfig(...)

# edit: it looks like ExternalConfig also needs to use setters, so might include, e.g..
external_config = bigquery.ExternalConfig("NEWLINE_DELIMITED_JSON")
external_config.source_uris = [...]

Describe the solution you'd like

Can we add an example to the docs so that readers learn these two pieces?:

  • Table attributes like schema can be set on __init__ (or via setters)
  • Other Table attributes must be set using setters

It seems like two places users may look for this info is in the Table API doc, and in the usage/tables - creating a table doc. Also, apologies if it's already somewhere in the docs and I missed it 😅.

Describe alternatives you've considered

Since Table can be constructed using .from_api_repr(), I wondered if this is a more common approach for construction? In that case it seems like having a nudge in the docs on using this path for e.g. constructing an external table would be super helpful!

Activity

  1. added
    type: docsImprovement to the documentation for an API.
    on Jul 16, 2021
  2. tswast commented on Jul 20, 2021

    @tswast
    Contributor

    It could also be good to include such a sample here as well: https://cloud.google.com/bigquery/external-table-definition

  3. tswast commented on Jul 20, 2021

    @tswast
    Contributor
  4. self-assigned this
    on Jul 29, 2022
  5. reopened this on Jan 30, 2023
  6. tswast commented on Jan 30, 2023

    @tswast
    Contributor

    Looks like we already had such a code sample here:

    # [START bigquery_query_external_gcs_perm]

    It appears on cloud.google.com here: https://cloud.google.com/bigquery/docs/external-data-cloud-storage#create_an_external_table

    Admittedly, that was a bit difficult for me to find, but it's there. It does need an update, though.

    The Python code sample on https://cloud.google.com/bigquery/docs/external-table-definition is a bit misleading, so I propose we remove that one.

  7. tswast commented on Feb 1, 2023

    @tswast
    Contributor
    1. Move https://github.com/googleapis/python-bigquery/blob/main/samples/create_table_external_data_configuration.py to samples/snippets (and its corresponding test)

    2. Update the region tag. It should be bigquery_query_external_gcs_perm

    3. Update the docs here: https://cloud.google.com/bigquery/docs/external-data-cloud-storage

    4. Delete the old sample from snippets.py

      # [START bigquery_query_external_gcs_perm]

  8. meredithslota commented on Aug 17, 2023

    @meredithslota
    Contributor

    PR above addresses (1) and (2) steps in Tim's comment. Edit will reopen PR, there's a few more changes I want to make.

  9. meredithslota commented on Aug 18, 2023

    @meredithslota
    Contributor

    There are no Python samples in https://cloud.google.com/bigquery/docs/external-table-definition anymore (removed in internal change 506395040). Submitted a new PR to tackle (1) and (2) above.

  10. added
    priority: p3Desirable enhancement or fix. May not be included in next release.
    on Aug 18, 2023
  11. meredithslota commented on Sep 16, 2023

    @meredithslota
    Contributor

    Sent cl/565816568 to update the sample location as per (3) above. Pending.

  12. meredithslota commented on Sep 18, 2023

    @meredithslota
    Contributor

    CL to update sample location now submitted.

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

Metadata

Metadata

Assignees

Labels

api: bigqueryIssues related to the googleapis/python-bigquery API.priority: p3Desirable enhancement or fix. May not be included in next release.type: docsImprovement to the documentation for an API.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions