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

DUPE (Do not merge) #358

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
dd3d52a
Fix nested primary key not supported bug
sukantaroy01 Jul 22, 2024
37ebcdb
Update code to pass lint cheks
sukantaroy01 Jul 22, 2024
a7ca8cd
Merge pull request #2 from pixisai/gads-fix-sr
sukantaroy01 Jul 25, 2024
1dc24e6
Merge branch 'airbytehq:main' into main
Udit107710 Jul 31, 2024
d9343f9
Merge branch 'airbytehq:main' into main
Udit107710 Aug 2, 2024
cf64dec
Merge branch 'airbytehq:main' into main
ajitpratap0 Aug 9, 2024
d88a765
Merge branch 'airbytehq:main' into main
Udit107710 Aug 12, 2024
3089e2d
Merge branch 'airbytehq:main' into main
Udit107710 Aug 20, 2024
a0b7134
Merge branch 'airbytehq:main' into main
Udit107710 Aug 21, 2024
c1f578d
Merge branch 'airbytehq:main' into main
ajitpratap0 Aug 29, 2024
4853670
Merge branch 'airbytehq:main' into main
Udit107710 Aug 31, 2024
5107547
Merge remote-tracking branch 'upstream/main'
Udit107710 Sep 3, 2024
fcce6bf
Merge pull request #4 from pixisai/UPSTREAM_MAIN
Udit107710 Sep 3, 2024
0975d3d
Merge branch 'airbytehq:main' into main
Udit107710 Sep 3, 2024
c1e620f
chore: fix tests
Udit107710 Sep 3, 2024
6580aa0
Merge pull request #5 from pixisai/UPSTREAM_MAIN
Udit107710 Sep 3, 2024
7b2956c
fix: fix import
Udit107710 Sep 3, 2024
98066cd
fix: indent import
Udit107710 Sep 3, 2024
27d1c57
fix: stream key (#7)
Udit107710 Sep 3, 2024
f788064
chore: reformat based on ruff
Udit107710 Sep 3, 2024
9395913
add unit test
aaronsteers Sep 4, 2024
fac9a71
improve parsing logic and guard statements for pk detection
aaronsteers Sep 4, 2024
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
24 changes: 18 additions & 6 deletions 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,13 +150,24 @@ def get_primary_keys(
if not pks:
return []

joined_pks = [".".join(pk) for pk in pks]
for pk in joined_pks:
if "." in pk:
msg = f"Nested primary keys are not yet supported. Found: {pk}"
raise NotImplementedError(msg)
normalized_pks: list[list[str]] = [
[LowerCaseNormalizer.normalize(c) for c in pk] for pk in pks
]

return joined_pks
for pk_nodes in normalized_pks:
if len(pk_nodes) != 1:
raise exc.AirbyteError(
message=(
"Nested primary keys are not supported. "
"Each PK column should have exactly one node. "
),
context={
"stream_name": stream_name,
"primary_key_nodes": pk_nodes,
},
)

return [pk_nodes[0] for pk_nodes in normalized_pks]

def get_cursor_key(
self,
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"},
},
},
},
]
},
}
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))
1 change: 1 addition & 0 deletions tests/unit_tests/test_text_normalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ def test_case_insensitive_w_pretty_keys(
("", "", True),
("*", "", True),
("!@$", "", True),
("some.col", "some_col", False),
],
)
def test_lower_case_normalizer(
Expand Down
Loading