bigquery-emulator icon indicating copy to clipboard operation
bigquery-emulator copied to clipboard

Support populating DestinationTable in the response when using `CREATE OR REPLACE table.name.foo AS (...)` syntax

Open andrewegel opened this issue 1 year ago • 1 comments

We're looking at using the bigquery emulator as a testing backend with the dbt-bigquery project - While investigating issue https://github.com/dbt-labs/dbt-bigquery/issues/358#issuecomment-1561763403 I found that this project doesn't populate the DestinationTable fields in the response to the client if the query uses the CREATE OR REPLACE table.name.foo AS (...) syntax. The emulator handles the case when DestinationTable is part of the Job Submit API call and a normal select * from source.table.foo (ie: bq --api ... query --destination_table 'table.name.foo' 'select * from source.table.foo), but dbt-bigquery likes to use the CREATE OR REPLACE table.name.foo AS (...) syntax because you can have more controls over how the results are materialized https://docs.getdbt.com/docs/build/materializations

I cannot speak to the feasibility of such a change, I'm just logging it as a behavior difference between BQ the service and the emulator.

andrewegel avatar May 24 '23 18:05 andrewegel

this is a duplicate of https://github.com/goccy/bigquery-emulator/issues/180
there is also a merge request linked to this issue. I tried it myself and it works like a charm.

yaronneuman avatar May 24 '23 19:05 yaronneuman