Source Google Ads: improve GAQL parser error messages (#25947)
Signed-off-by: Sergey Chvalyuk <grubberr@gmail.com>
This commit is contained in:
@@ -14139,7 +14139,7 @@
|
||||
"sourceDefinitionId": "253487c0-2246-43ba-a21f-5116b20a2c50",
|
||||
"name": "Google Ads",
|
||||
"dockerRepository": "airbyte/source-google-ads",
|
||||
"dockerImageTag": "0.2.17",
|
||||
"dockerImageTag": "0.2.18",
|
||||
"documentationUrl": "https://docs.airbyte.com/integrations/sources/google-ads",
|
||||
"icon": "google-adwords.svg",
|
||||
"sourceType": "api",
|
||||
|
||||
@@ -805,7 +805,7 @@
|
||||
- name: Google Ads
|
||||
sourceDefinitionId: 253487c0-2246-43ba-a21f-5116b20a2c50
|
||||
dockerRepository: airbyte/source-google-ads
|
||||
dockerImageTag: 0.2.17
|
||||
dockerImageTag: 0.2.18
|
||||
documentationUrl: https://docs.airbyte.com/integrations/sources/google-ads
|
||||
icon: google-adwords.svg
|
||||
sourceType: api
|
||||
|
||||
@@ -5795,7 +5795,7 @@
|
||||
supportsNormalization: false
|
||||
supportsDBT: false
|
||||
supported_destination_sync_modes: []
|
||||
- dockerImage: "airbyte/source-google-ads:0.2.17"
|
||||
- dockerImage: "airbyte/source-google-ads:0.2.18"
|
||||
spec:
|
||||
documentationUrl: "https://docs.airbyte.com/integrations/sources/google-ads"
|
||||
connectionSpecification:
|
||||
|
||||
@@ -13,5 +13,5 @@ COPY main.py ./
|
||||
|
||||
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]
|
||||
|
||||
LABEL io.airbyte.version=0.2.17
|
||||
LABEL io.airbyte.version=0.2.18
|
||||
LABEL io.airbyte.name=airbyte/source-google-ads
|
||||
|
||||
@@ -6,7 +6,7 @@ data:
|
||||
connectorSubtype: api
|
||||
connectorType: source
|
||||
definitionId: 253487c0-2246-43ba-a21f-5116b20a2c50
|
||||
dockerImageTag: 0.2.17
|
||||
dockerImageTag: 0.2.18
|
||||
dockerRepository: airbyte/source-google-ads
|
||||
githubIssueLabel: source-google-ads
|
||||
icon: google-adwords.svg
|
||||
|
||||
@@ -28,7 +28,7 @@ class GAQL:
|
||||
r"""\s*
|
||||
SELECT\s+(?P<FieldNames>\S.*)
|
||||
\s+
|
||||
FROM\s+(?P<ResourceName>[a-z]([a-zA-Z_])*)
|
||||
FROM\s+(?P<ResourceNames>[a-z][a-zA-Z_]*(\s*,\s*[a-z][a-zA-Z_]*)*)
|
||||
\s*
|
||||
(\s+WHERE\s+(?P<WhereClause>\S.*?))?
|
||||
(\s+ORDER\s+BY\s+(?P<OrderByClause>\S.*?))?
|
||||
@@ -57,7 +57,12 @@ class GAQL:
|
||||
if not cls.REGEX_FIELD_NAME.match(field):
|
||||
raise query_error
|
||||
|
||||
resource_name = m.group("ResourceName")
|
||||
resource_names = re.split(r"\s*,\s*", m.group("ResourceNames"))
|
||||
if len(resource_names) > 1:
|
||||
message = f"Incorrect GAQL query: multiple resources '{', '.join(resource_names)}' is not allowed"
|
||||
raise AirbyteTracedException(message=message, internal_message=message, failure_type=FailureType.config_error)
|
||||
resource_name = resource_names[0]
|
||||
|
||||
where = cls._normalize(m.group("WhereClause") or "")
|
||||
order_by = cls._normalize(m.group("OrderByClause") or "")
|
||||
limit = m.group("LimitClause")
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#
|
||||
|
||||
import pytest
|
||||
from airbyte_cdk.utils import AirbyteTracedException
|
||||
from source_google_ads.utils import GAQL
|
||||
|
||||
|
||||
@@ -70,17 +71,21 @@ def test_parse_GAQL_ok():
|
||||
|
||||
|
||||
def test_parse_GAQL_fail():
|
||||
with pytest.raises(Exception) as e:
|
||||
with pytest.raises(AirbyteTracedException) as e:
|
||||
GAQL.parse("SELECT field1, field2 FROM x_Table2")
|
||||
assert str(e.value) == "Incorrect GAQL query statement: 'SELECT field1, field2 FROM x_Table2'"
|
||||
|
||||
with pytest.raises(Exception) as e:
|
||||
with pytest.raises(AirbyteTracedException) as e:
|
||||
GAQL.parse("SELECT field1, field2 FROM x_Table WHERE ")
|
||||
with pytest.raises(Exception) as e:
|
||||
with pytest.raises(AirbyteTracedException) as e:
|
||||
GAQL.parse("SELECT field1, , field2 FROM table")
|
||||
with pytest.raises(Exception) as e:
|
||||
with pytest.raises(AirbyteTracedException) as e:
|
||||
GAQL.parse("SELECT fie ld1, field2 FROM table")
|
||||
|
||||
with pytest.raises(AirbyteTracedException) as e:
|
||||
GAQL.parse("SELECT field1, field2 FROM customer, campaign_labels")
|
||||
assert str(e.value) == "Incorrect GAQL query: multiple resources 'customer, campaign_labels' is not allowed"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"query, fields",
|
||||
|
||||
@@ -141,6 +141,7 @@ Due to a limitation in the Google Ads API which does not allow getting performan
|
||||
|
||||
| Version | Date | Pull Request | Subject |
|
||||
|:---------|:-----------|:---------------------------------------------------------|:-------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `0.2.18` | 2023-05-15 | [25947](https://github.com/airbytehq/airbyte/pull/25947) | Improve GAQL parser error message if multiple resources provided |
|
||||
| `0.2.17` | 2023-05-11 | [25987](https://github.com/airbytehq/airbyte/pull/25987) | Categorized Config Errors Accurately |
|
||||
| `0.2.16` | 2023-05-10 | [25965](https://github.com/airbytehq/airbyte/pull/25965) | Fix Airbyte date-time data-types |
|
||||
| `0.2.14` | 2023-03-21 | [24945](https://github.com/airbytehq/airbyte/pull/24945) | for custom google query fixed schema type for "data_type: ENUM" and "is_repeated: true" to array of strings |
|
||||
|
||||
Reference in New Issue
Block a user