Skip to content

Commit b85b63b

Browse files
authored
fix(source-google-ads): Fix custom query regex conditions (#69802)
1 parent 24efb98 commit b85b63b

File tree

5 files changed

+50
-9
lines changed

5 files changed

+50
-9
lines changed

airbyte-integrations/connectors/source-google-ads/metadata.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ data:
1111
connectorSubtype: api
1212
connectorType: source
1313
definitionId: 253487c0-2246-43ba-a21f-5116b20a2c50
14-
dockerImageTag: 4.1.0
14+
dockerImageTag: 4.1.1
1515
dockerRepository: airbyte/source-google-ads
1616
documentationUrl: https://docs.airbyte.com/integrations/sources/google-ads
1717
externalDocumentationUrls:
@@ -32,10 +32,8 @@ data:
3232
registryOverrides:
3333
cloud:
3434
enabled: true
35-
dockerImageTag: 4.0.2
3635
oss:
3736
enabled: true
38-
dockerImageTag: 4.0.2
3937
releaseStage: generally_available
4038
releases:
4139
rolloutConfiguration:

airbyte-integrations/connectors/source-google-ads/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ requires = [ "poetry-core>=1.0.0",]
33
build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
6-
version = "4.1.0"
6+
version = "4.1.1"
77
name = "source-google-ads"
88
description = "Source implementation for Google Ads."
99
authors = [ "Airbyte <[email protected]>",]

airbyte-integrations/connectors/source-google-ads/source_google_ads/manifest.yaml

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,19 @@ definitions:
10161016
"datetime_format": "%Y-%m-%d"
10171017
}
10181018
}
1019-
condition: "{{ (components_values.get('query', '').count('segments.date') == 1 and (components_values.get('query') | regex_search('SELECT.*segments\\.date.*FROM')) is not none) or (components_values.get('query', '').count('segments.date') == 2 and (components_values.get('query') | regex_search('SELECT.*segments\\.date.*FROM')) is not none and (components_values.get('query') | regex_search('ORDER BY.*?segments\\.date.*?LIMIT')) is not none) }}"
1019+
condition: >-
1020+
{{
1021+
(
1022+
components_values.get('query', '').count('segments.date') == 1
1023+
and (components_values.get('query') | regex_search('(SELECT[\s\S]*?segments\\.date[\s\S]*?FROM)'))
1024+
)
1025+
or
1026+
(
1027+
components_values.get('query', '').count('segments.date') == 2
1028+
and (components_values.get('query') | regex_search('(SELECT[\s\S]*?segments\\.date[\s\S]*?FROM)'))
1029+
and (components_values.get('query') | regex_search('(ORDER BY[\s\S]*?segments\\.date)'))
1030+
)
1031+
}}
10201032
create_or_update: true
10211033
- type: ComponentMappingDefinition
10221034
field_path:
@@ -1033,7 +1045,19 @@ definitions:
10331045
- $parameters
10341046
- cursor_field
10351047
value: "segments.date"
1036-
condition: "{{ (components_values.get('query', '').count('segments.date') == 1 and (components_values.get('query') | regex_search('SELECT.*segments\\.date.*FROM')) is not none) or (components_values.get('query', '').count('segments.date') == 2 and (components_values.get('query') | regex_search('SELECT.*segments\\.date.*FROM')) is not none and (components_values.get('query') | regex_search('ORDER BY.*?segments\\.date.*?LIMIT')) is not none) }}"
1048+
condition: >-
1049+
{{
1050+
(
1051+
components_values.get('query', '').count('segments.date') == 1
1052+
and (components_values.get('query') | regex_search('(SELECT[\s\S]*?segments\\.date[\s\S]*?FROM)'))
1053+
)
1054+
or
1055+
(
1056+
components_values.get('query', '').count('segments.date') == 2
1057+
and (components_values.get('query') | regex_search('(SELECT[\s\S]*?segments\\.date[\s\S]*?FROM)'))
1058+
and (components_values.get('query') | regex_search('(ORDER BY[\s\S]*?segments\\.date)'))
1059+
)
1060+
}}
10371061
create_or_update: true
10381062
- type: ComponentMappingDefinition
10391063
field_path:
@@ -1047,7 +1071,19 @@ definitions:
10471071
- schema_loader
10481072
- cursor_field
10491073
value: "segments.date"
1050-
condition: "{{ (components_values.get('query', '').count('segments.date') == 1 and (components_values.get('query') | regex_search('SELECT.*segments\\.date.*FROM')) is not none) or (components_values.get('query', '').count('segments.date') == 2 and (components_values.get('query') | regex_search('SELECT.*segments\\.date.*FROM')) is not none and (components_values.get('query') | regex_search('ORDER BY.*?segments\\.date.*?LIMIT')) is not none) }}"
1074+
condition: >-
1075+
{{
1076+
(
1077+
components_values.get('query', '').count('segments.date') == 1
1078+
and (components_values.get('query') | regex_search('(SELECT[\s\S]*?segments\\.date[\s\S]*?FROM)'))
1079+
)
1080+
or
1081+
(
1082+
components_values.get('query', '').count('segments.date') == 2
1083+
and (components_values.get('query') | regex_search('(SELECT[\s\S]*?segments\\.date[\s\S]*?FROM)'))
1084+
and (components_values.get('query') | regex_search('(ORDER BY[\s\S]*?segments\\.date)'))
1085+
)
1086+
}}
10511087
create_or_update: true
10521088
- type: ComponentMappingDefinition
10531089
field_path:

airbyte-integrations/connectors/source-google-ads/unit_tests/test_empty_streams.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,9 @@ def test_custom_query_stream(customers, config_for_custom_query_tests, requests_
244244
False,
245245
),
246246
("SELECT ad_group_ad.ad.name, segments.date FROM ad_group_ad", True),
247+
("SELECT \n ad_group_ad.ad.name, \n segments.date FROM ad_group_ad ORDER BY \n segments.date DESC", True),
247248
("SELECT ad_group_ad.ad.name, segments.date FROM ad_group_ad ORDER BY segments.date DESC", True),
249+
("SELECT ad_group_ad.ad.name, segments.date FROM ad_group_ad ORDER BY ad_group_ad.ad.name, segments.date DESC", True),
248250
("SELECT ad_group_ad.ad.name, segments.date FROM ad_group_ad ORDER BY segments.date DESC LIMIT 100", True),
249251
(
250252
"SELECT ad_group_ad.ad.name, segments.date FROM ad_group_ad ORDER BY ad_group_ad.ad.name DESC, segments.date DESC LIMIT 100",
@@ -254,8 +256,12 @@ def test_custom_query_stream(customers, config_for_custom_query_tests, requests_
254256
"SELECT ad_group_ad.ad.name, segments.date FROM ad_group_ad ORDER BY segments.date DESC, ad_group_ad.ad.name DESC LIMIT 100",
255257
True,
256258
),
257-
# This query currently gets incremental sync due to manifest regex condition matching SELECT.*segments.date.*FROM pattern
258-
("SELECT ad_group_ad.ad.name, segments.date FROM ad_group_ad WHERE segments.date DURING LAST_30_DAYS", True),
259+
("SELECT ad_group_ad.ad.name, segments.date FROM ad_group_ad WHERE segments.date DURING LAST_30_DAYS", False),
260+
("SELECT ad_group_ad.ad.name, segments.date FROM ad_group_ad WHERE \n segments.date DURING LAST_30_DAYS", False),
261+
(
262+
"SELECT ad_group_ad.ad.name, segments.date FROM ad_group_ad WHERE segments.date DURING LAST_30_DAYS ORDER BY ad_group_ad.ad.name",
263+
False,
264+
),
259265
],
260266
)
261267
def test_custom_query_stream_with_different_queries(query, expected_incremental_sync, config_for_custom_query_tests, requests_mock):

docs/integrations/sources/google-ads.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ Due to a limitation in the Google Ads API which does not allow getting performan
335335

336336
| Version | Date | Pull Request | Subject |
337337
|:------------|:-----------|:---------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
338+
| 4.1.1 | 2025-11-21 | [69802](https://github.com/airbytehq/airbyte/pull/69802) | Fix custom query regex conditions |
338339
| 4.1.0 | 2025-11-20 | [69776](https://github.com/airbytehq/airbyte/pull/69776) | Promoting release candidate 4.1.0-rc.8 to a main version. |
339340
| 4.1.0-rc.8 | 2025-10-29 | [69084](https://github.com/airbytehq/airbyte/pull/69084) | Fix criterion streams |
340341
| 4.1.0-rc.7 | 2025-10-16 | [68030](https://github.com/airbytehq/airbyte/pull/68030) | Fix schema loader for `custom_queries` streams |

0 commit comments

Comments
 (0)