Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Resolve issue where PyAirbyte would fail if property names contain the dot character ('.'), e.g. with source-google-ads #343

Merged
merged 21 commits into from
Sep 7, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,6 @@ dmypy.json

# Cython debug symbols
cython_debug/

# Pycharm
.idea
5 changes: 4 additions & 1 deletion airbyte/shared/catalog_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
)

from airbyte import exceptions as exc
from airbyte._util.name_normalizers import LowerCaseNormalizer
from airbyte.strategies import WriteMethod, WriteStrategy


Expand Down Expand Up @@ -149,7 +150,9 @@ def get_primary_keys(
if not pks:
return []

joined_pks = [".".join(pk) for pk in pks]
normalized_pks = [[LowerCaseNormalizer.normalize(c) for c in pk] for pk in pks]
joined_pks = [".".join(pk) for pk in normalized_pks]

for pk in joined_pks:
if "." in pk:
msg = f"Nested primary keys are not yet supported. Found: {pk}"
Expand Down
32 changes: 32 additions & 0 deletions tests/integration_tests/fixtures/source-test/source_test/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,23 @@
},
},
},
{
"name": "primary-key-with-dot",
"description": "This stream has a primary key with dot similar what is there in GAds.",
"source_defined_primary_key": [["table1.Column1"]],
"source_defined_cursor": False,
"supported_sync_modes": ["full_refresh"],
"json_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"table1.Column1": {"type": "string"},
"table1.Column2": {"type": "number"},
"table1.empty_column": {"type": "string"},
"table1.big_number": {"type": "number"},
},
aaronsteers marked this conversation as resolved.
Show resolved Hide resolved
},
},
]
},
}
Expand Down Expand Up @@ -137,6 +154,19 @@
"emitted_at": 1704067200,
},
}
sample_record_primary_key_with_dot = {
"type": "RECORD",
"record": {
"data": {
"table1.Column1": "value1",
"table1.Column2": 1,
"table1.empty_column": None,
"table1.big_number": 1234567890123456,
},
"stream": "primary-key-with-dot",
"emitted_at": 1704067200,
},
}


def parse_args():
Expand Down Expand Up @@ -184,3 +214,5 @@ def run():
print(json.dumps(sample_record2_stream1))
elif stream["stream"]["name"] == "stream2":
print(json.dumps(sample_record_stream2))
elif stream["stream"]["name"] == "primary-key-with-dot":
print(json.dumps(sample_record_primary_key_with_dot))