Skip to content

feat: repr of QueryJob (and other jobs) should include job reference info (project ID, location, job ID) #958

@tswast

Description

@tswast

Without a job ID, there's not much I can do to follow-up with an investigation into test flakes. Project ID, location, and job ID are the first things backend engineers request if there is a problem with a query job. We should ensure that our exceptions include this information (I believe we do much of the time) and just as importantly the repr of the job, so that assertion errors like this include the right information.

Context

#947 had a system test flake.

        # Insert a few rows and check the stats.
        sql = f"""
            BEGIN TRANSACTION;
              INSERT INTO `{table_id}`
              VALUES ("one", 1), ("two", 2), ("three", 3), ("four", 4);

              UPDATE `{table_id}`
              SET bar = bar + 1
              WHERE bar > 2;
            COMMIT TRANSACTION;
        """
        query_job = Config.CLIENT.query(sql)
        query_job.result()

        # Transaction ID set by the server should be accessible
>       assert query_job.transaction_info is not None
E       AssertionError: assert None is not None
E        +  where None = <google.cloud.bigquery.job.query.QueryJob object at 0x7fa1b2732610>.transaction_info

tests/system/test_client.py:1583: AssertionError

https://source.cloud.google.com/results/invocations/10d5f32f-86da-4278-85d6-25799e2f8155/targets/cloud-devrel%2Fclient-libraries%2Fpython%2Fgoogleapis%2Fpython-bigquery%2Fpresubmit%2Fprerelease-deps-3.8/log

Without a job ID, there's little I can do to investigate further.

Metadata

Metadata

Assignees

Labels

api: bigqueryIssues related to the googleapis/python-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