From 142535632f9155da2528e8712912691be70e8690 Mon Sep 17 00:00:00 2001 From: unytics Date: Fri, 26 Jul 2024 08:13:23 +0000 Subject: [PATCH] v0.28: fixed error when dash in dataset name --- airbyte_serverless/destinations.py | 10 +++++----- airbyte_serverless/version.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/airbyte_serverless/destinations.py b/airbyte_serverless/destinations.py index cded8a1..8208041 100644 --- a/airbyte_serverless/destinations.py +++ b/airbyte_serverless/destinations.py @@ -115,7 +115,7 @@ def __init__(self, dataset='', **kwargs): import google.cloud.bigquery assert dataset, 'dataset argument must be defined' assert len(dataset.split('.')) == 2, '`BigQueryDestination.dataset` must be like `project.dataset`' - self.dataset = dataset + self.dataset = dataset.replace('`', '').strip() self.project, _ = self.dataset.split('.') self.bigquery = google.cloud.bigquery.Client(project=self.project) self.created_tables = [] @@ -132,7 +132,7 @@ def get_state(self): json_value(_airbyte_data, '$.stream.stream_descriptor.name') as stream, _airbyte_data as state, _airbyte_loaded_at, - from {self.dataset}._airbyte_states + from `{self.dataset}._airbyte_states` where json_value(_airbyte_data, '$.type') = 'STREAM' qualify row_number() over (partition by stream order by _airbyte_loaded_at desc) = 1 @@ -143,7 +143,7 @@ def get_state(self): select _airbyte_data as state, _airbyte_loaded_at, - from {self.dataset}._airbyte_states + from `{self.dataset}._airbyte_states` where json_value(_airbyte_data, '$.type') = 'GLOBAL' order by _airbyte_loaded_at desc limit 1 @@ -155,7 +155,7 @@ def get_state(self): select json_extract(_airbyte_data, '$.data') as state, _airbyte_loaded_at, - from {self.dataset}._airbyte_states + from `{self.dataset}._airbyte_states` where json_extract(_airbyte_data, '$.data') is not null order by _airbyte_loaded_at desc limit 1 @@ -205,7 +205,7 @@ def _create_table_if_needed(self, table): for column, type, description in self.destination_columns ]) self.bigquery.query(f''' - create table if not exists {self.dataset}.{table} ( + create table if not exists `{self.dataset}.{table}` ( {columns_definitions} ) partition by date(_airbyte_loaded_at) diff --git a/airbyte_serverless/version.py b/airbyte_serverless/version.py index cf3d954..a81dc47 100644 --- a/airbyte_serverless/version.py +++ b/airbyte_serverless/version.py @@ -1 +1 @@ -VERSION = '0.27' +VERSION = '0.28'