Skip to content

BigQuery Python Client v0.28.0: Can't recover {Dataset,Table}References from Dataset or Table objects #4327

Closed

Description

@robfraz

Hello,

In v0.28.0 of the BigQuery Python Client, it doesn't seem possible to recover the original DatasetReference or TableReference used to create the the Dataset or Table, thus preventing any part of the API (or a user's application) that requires a reference to also take the Dataset or Table object. It seems the reference used in creating the Dataset or Table is lost on object creation [1][2].

For example, in the client.load_table_from_file() function [3], a table_ref is expected; it seems logically unreasonable that a full Table object can't be used to fulfil the need for a table reference.

Cheers,
Rob

[1] https://github.com/GoogleCloudPlatform/google-cloud-python/blob/0.28.0/bigquery/google/cloud/bigquery/table.py#L170-L177
[2] https://github.com/GoogleCloudPlatform/google-cloud-python/blob/0.28.0/bigquery/google/cloud/bigquery/dataset.py#L204-L208
[3] https://github.com/GoogleCloudPlatform/google-cloud-python/blob/0.28.0/bigquery/google/cloud/bigquery/client.py#L692-L706

Activity

  1. added
    api: bigqueryIssues related to the BigQuery API.
    type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.
    status: investigatingThe issue is under investigation, which is determined to be non-trivial.
    on Nov 2, 2017
  2. dhermes commented on Nov 2, 2017

    @dhermes
    Contributor

    @tswast Can you lend a hand here?

  3. tswast commented on Nov 10, 2017

    @tswast
    Contributor

    This is a good feature request. I agree that such a change would improve usability.

    I see two ways to address this:

    1. To allow either Table or TableReference for operations such as client.load_table_from_file(). Likewise for Dataset and DatasetReference.
    2. Add a helper method to get the TableReference from a Table object. Likewise for Dataset and DatasetReference.

    In the meantime, the workaround is to create a TableReference manually from a Table.

    dataset_ref = DatasetReference(table.project, table.dataset_id)
    table_ref = TableReference(dataset_ref, table.table_id)
    

    My preference would be for (2). Something like the following code:

    table_ref = table.reference
    
  4. robfraz commented on Nov 13, 2017

    @robfraz
    Author

    @tswast Sounds good. You want me to submit a pull request, or is this something that you'll add yourselves?

  5. tswast commented on Nov 13, 2017

    @tswast
    Contributor

    Contributions welcome. :-)

  6. removed
    status: investigatingThe issue is under investigation, which is determined to be non-trivial.
    on Nov 17, 2017
  7. self-assigned this
    on Nov 17, 2017
  8. tswast commented on Nov 17, 2017

    @tswast
    Contributor

    I've got a PR pending #4405

  9. robfraz commented on Nov 20, 2017

    @robfraz
    Author

    Nice - thanks. I wouldn't have had a chance to get to it until the weekend just gone, and you beat me to it.

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 BigQuery API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions