z3z1ma / target-bigquery

target-bigquery is a Singer target for BigQuery. It supports storage write, GCS, streaming, and batch load methods. Built with the Meltano SDK.
MIT License
28 stars 37 forks source link

Upsert does not work with `gcs_stage` method #69

Closed tomasvotava closed 1 year ago

tomasvotava commented 1 year ago

Steps to reproduce

Set method to gcs_stage and upsert to true.

Expected behavior

The table gets loaded using MERGE query from a temporary table.

Actual behavior

AttributeError: Client has no attribute 'query'

This is probably caused by the fact that there are two client factories. If gcs_stage method is selected, the factory returns google.cloud.storage.Client instance instead of google.cloud.bigquery.Client instance and is therefore unable to run queries.

According to the README this should be supported. Is this something you would like to address? Do you prefer if I came up with a PR?