Repository navigation
Conversation
Every query job reported statistics.query.statementType=SELECT, and a CREATE TABLE AS SELECT job had no configuration.query.destinationTable. dbt-bigquery branches on statementType and, for SELECT, calls client.get_table(job.destination), so every dbt model build against the emulator failed with "'NoneType' object has no attribute 'path'". Classify the statement lexically into the statementType values the BigQuery API documents, and for CREATE TABLE statements set ddlTargetTable (and, for CTAS, destinationTable) from the catalog change the statement produced.
ymatrix1
marked this pull request as ready for review
September 22, 2026 23:37
Author
|
Status note: this fix is already running in production use of the emulator. While these PRs wait for review we carry them, together with the related fixes, in a fork: https://github.com/Flip-to/bigquery-emulator (branch Happy to rebase, split or adjust anything here if that helps review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #370.
Problem
Every query job reports
statistics.query.statementType = "SELECT", and aCREATE TABLE AS SELECTjob has noconfiguration.query.destinationTable. dbt-bigquery branches on the statement type (connections.py,get_query_status): forSELECTit callsclient.get_table(query_job.destination), so every dbt model build and unit test fails with:Measured with the Python client (
client.query(sql)):SELECT 1 AS idSELECT, destination setSELECT, destination setCREATE OR REPLACE TABLE ds.t AS SELECT 1 AS idCREATE_TABLE_AS_SELECT, destination =ds.tSELECT,destination=NoneCREATE_TABLE_AS_SELECT, destination =ds.t,num_rowsreadableINSERT/UPDATE/DELETESELECTCREATE VIEW/DROP VIEW/DROP TABLECREATE_VIEW/DROP_VIEW/DROP_TABLESELECTCREATE FUNCTION/CREATE TABLE FUNCTIONCREATE_FUNCTION/CREATE_TABLE_FUNCTIONSELECTSELECT 1; SELECT 2SCRIPTSELECTSCRIPTFix
statementType(query)classifies the statement lexically (comments and quoted text skipped) into the values theJobStatistics2.statementTypeAPI documentation lists. More than one statement, or a leading procedural keyword, isSCRIPT.CREATE TABLE/CREATE TABLE AS SELECT, setddlTargetTablefrom the catalog change the statement produced (ChangedCatalog), and for CTAS alsoconfiguration.query.destinationTable, which is what BigQuery returns and what clients read the row count through.jobs.insertandjobs.query.Tests
server/statement_type_test.goruns each statement above through the Go client and checksStatementType, and for CTAS the destination,DDLTargetTableand the destination'sNumRows.Before:
After: all 13 subtests pass.
go test ./...passes with no new failures againstmain. With this change dbt-bigquery unit tests run against the emulator without a client-side shim.