From a230680a4ea72bc9b7da99b1facc7cf4b4e9955d Mon Sep 17 00:00:00 2001 From: Luishfs Date: Thu, 3 Oct 2024 16:26:22 -0300 Subject: [PATCH] source-google-ads: fixing config transformations google ads transformations were breaking due to something re-using the same variables from a earlier step. This made the config transformation step to break. Also, custom queries were not working due to the lack of primary keys in the validation step. I've added a dud primary key, which will be replaced by the actual primary key input in newer version, in order to allow for already created streams to work --- source-google-ads/source_google_ads/custom_query_stream.py | 5 +++-- source-google-ads/source_google_ads/source.py | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/source-google-ads/source_google_ads/custom_query_stream.py b/source-google-ads/source_google_ads/custom_query_stream.py index 2cf6066c48..84a585a1ae 100644 --- a/source-google-ads/source_google_ads/custom_query_stream.py +++ b/source-google-ads/source_google_ads/custom_query_stream.py @@ -21,8 +21,9 @@ def primary_key(self) -> str: It will be ignored if provided. If you need to enable it, uncomment the next line instead of `return None` and modify your config """ - # return self.config.get("primary_key") or None - return None + # TODO luis: Thats a quick hack to pass validation step with already created custom queries, will be removed along + # with the new custom query creation + return ["segments.date"] @property def name(self): diff --git a/source-google-ads/source_google_ads/source.py b/source-google-ads/source_google_ads/source.py index 5c93d1a5c1..e382fcb28d 100644 --- a/source-google-ads/source_google_ads/source.py +++ b/source-google-ads/source_google_ads/source.py @@ -49,7 +49,8 @@ def _validate_and_transform(config: Mapping[str, Any]): config.pop("end_date") for query in config.get("custom_queries", []): try: - query["query"] = GAQL.parse(query["query"]) + if type(query["query"]) == str: + query["query"] = GAQL.parse(query["query"]) except ValueError: message = f"The custom GAQL query {query['table_name']} failed. Validate your GAQL query with the Google Ads query validator. https://developers.google.com/google-ads/api/fields/v17/query_validator" raise AirbyteTracedException(message=message, failure_type=FailureType.config_error)