BigQuery: Remove "Job ID" metadata on annotaton to avoid cache misses (#7541)

This commit is contained in:
Tsuneo Yoshioka
2025-09-24 23:44:40 +09:00
committed by GitHub
parent 5e8915afe5
commit 56c06adc24
2 changed files with 6 additions and 1 deletions

View File

@@ -156,6 +156,11 @@ class BigQuery(BaseSQLQueryRunner):
"secret": ["jsonKeyFile"],
}
def annotate_query(self, query, metadata):
# Remove "Job ID" before annotating the query to avoid cache misses
metadata = {k: v for k, v in metadata.items() if k != "Job ID"}
return super().annotate_query(query, metadata)
def _get_bigquery_service(self):
socket.setdefaulttimeout(settings.BIGQUERY_HTTP_TIMEOUT)

View File

@@ -20,7 +20,7 @@ class TestBigQueryQueryRunner(unittest.TestCase):
query = "SELECT a FROM tbl"
expect = (
"/* Username: username, query_id: adhoc, "
"Job ID: job-id, Query Hash: query-hash, "
"Query Hash: query-hash, "
"Scheduled: False */ SELECT a FROM tbl"
)