GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Reading the labels set on a job fails · Issue #469 · googleapis/python-bigquery

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.

Reading the labels set on a job fails #469

Copy link
Copy link
Closed
#471
Closed
Reading the labels set on a job fails#469
#471
Copy link
Assignees
plamut
Labels
api: bigqueryIssues related to the googleapis/python-bigquery API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Description

@rholloway
rholloway
opened on Jan 11, 2021
Issue body actions

The ability to specify labels on created BigQuery jobs was supposedly added in googleapis/google-cloud-python#5654, but it doesn't work. There is also a comment in the documentation from that same PR referring to Client.update_job() which doesn't even exist.

Environment details

python --version

Python 3.7.3

pip freeze | grep google

google-api-core==1.24.1
google-auth==1.24.0
google-cloud-bigquery==2.6.2
google-cloud-bigtable==1.6.1
google-cloud-core==1.5.0
google-cloud-pubsub==2.2.0
google-cloud-storage==1.35.0
google-crc32c==1.1.0
google-resumable-media==1.2.0
googleapis-common-protos==1.52.0
grpc-google-iam-v1==0.12.3

Code example

job_config = bigquery.QueryJobConfig(labels={"app": "test"})
query_job = client.query("SELECT 1", job_config=job_config)

# no labels seen below
print(query_job.labels)

# try and get a job later, also no labels
job = client.get_job(query_job.job_id)
print(job.labels)

Activity

  1. plamut
    transferred this issue fromgoogleapis/google-cloud-pythonon Jan 12, 2021
  2. product-auto-label
    added
    api: bigqueryIssues related to the googleapis/python-bigquery API.
    on Jan 12, 2021
  3. plamut
    added
    type: questionRequest for information or clarification. Not an issue.
    on Jan 12, 2021
  4. plamut
    self-assigned this
    on Jan 12, 2021
  5. plamut commented on Jan 13, 2021

    @plamut
    plamut
    on Jan 13, 2021
    Contributor
    More actions

    @rholloway Thanks for the report, I can confirm the reported behavior.

    It turns out the labels are actually present in the raw job data, i.e. in query_job._properties["configuration"]["labels"], but the labels property tries to read them from self._properties["labels"]. If that's the only cause, it should be an easy fix.

    It's worth mentioning that labels on the Table, Dataset, and Model resources are actually present an the top level of the corresponding JSON responses, while in the Job resources they are nested under the configuration dict representing a JobConfiguration resource.

    Reacted by Ryan Arredondo
  6. plamut
    added
    priority: p2Moderately-important priority. Fix may not be included in next release.
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    and removed
    type: questionRequest for information or clarification. Not an issue.
    on Jan 13, 2021
  7. rarredon commented on Jan 13, 2021

    @rarredon
    rarredon
    on Jan 13, 2021
    More actions

    @plamut I can confirm that there's a workaround by going through the job's configuration. In my case, I was able to submit a job with labels and then later access them as follows

    client = BigQueryClient()
    job = client.submit_job(sql, labels={'foo': 'bar'})
    ...
    job = client.get_job(job.job_id)
    print(job._configuration.labels)  # {'foo': 'bar'}
    

    Perhaps the _configuration attr is synonymous with _properties['configuration'], just as you found. I hope that helps.

  8. plamut commented on Jan 13, 2021

    @plamut
    plamut
    on Jan 13, 2021
    Contributor
    More actions

    @rarredon Indeed, semantically they represent the same thing. 👍
    _configuration is a QueryJobConfig() instance, while _properties["configuration"] is the former's "raw" form (a nested dict structure).

  9. plamut commented on Jan 14, 2021

    @plamut
    plamut
    on Jan 14, 2021
    Contributor
    More actions

    Got an update from the backend maintainers - the labels on the jobs are immutable once a job is created, thus the client cannot update them even if it wanted to.

    It still needs to read them from the correct nesting level, of course, which will be fixed soon.

  10. plamut
    changed the title [-]BigQuery: Adding labels to jobs fails to add labels[/-] [+]Reading the labels set on a job fails[/+] on Jan 14, 2021
  11. tswast
    closed this as completedin #471on Jan 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @plamut
    plamut

Labels

api: bigqueryIssues related to the googleapis/python-bigquery API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.