Skip to content

Commit 6e37ba1

Browse files
girardarodireich
authored andcommitted
[low-code connectors] Get parent stream's full slice (#15631)
* always access parent stream using full_refresh mode * Update test * fix substream slicer * bump
1 parent b8315be commit 6e37ba1

File tree

5 files changed

+20
-15
lines changed

5 files changed

+20
-15
lines changed

airbyte-cdk/python/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## 0.1.76
4+
- Bugfix: Correctly set parent slice stream for sub-resource streams
5+
36
## 0.1.75
47
- Improve `filter_secrets` skip empty secret
58

airbyte-cdk/python/airbyte_cdk/sources/declarative/stream_slicers/substream_slicer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def stream_slices(self, sync_mode: SyncMode, stream_state: StreamState) -> Itera
127127
stream_state_field = parent_stream_config.stream_slice_field
128128
for parent_stream_slice in parent_stream.stream_slices(sync_mode=sync_mode, cursor_field=None, stream_state=stream_state):
129129
empty_parent_slice = True
130-
parent_slice = parent_stream_slice.get("slice")
130+
parent_slice = parent_stream_slice
131131

132132
for parent_record in parent_stream.read_records(
133133
sync_mode=SyncMode.full_refresh, cursor_field=None, stream_slice=parent_stream_slice, stream_state=None

airbyte-cdk/python/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
setup(
1717
name="airbyte-cdk",
18-
version="0.1.75",
18+
version="0.1.76",
1919
description="A framework for writing Airbyte Connectors.",
2020
long_description=README,
2121
long_description_content_type="text/markdown",

airbyte-cdk/python/unit_tests/sources/declarative/stream_slicers/test_substream_slicer.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ def read_records(
4747
stream_slice: Mapping[str, Any] = None,
4848
stream_state: Mapping[str, Any] = None,
4949
) -> Iterable[Mapping[str, Any]]:
50+
# The parent stream's records should always be read as full refresh
51+
assert sync_mode == SyncMode.full_refresh
5052
if not stream_slice:
5153
yield from self._records
5254
else:
@@ -64,7 +66,7 @@ def read_records(
6466
stream=MockStream([{}], [], "first_stream"), parent_key="id", stream_slice_field="first_stream_id", options={}
6567
)
6668
],
67-
[{"first_stream_id": None, "parent_slice": None}],
69+
[{"first_stream_id": None, "parent_slice": {}}],
6870
),
6971
(
7072
"test_single_parent_slices_with_records",
@@ -76,7 +78,7 @@ def read_records(
7678
options={},
7779
)
7880
],
79-
[{"first_stream_id": 1, "parent_slice": None}, {"first_stream_id": 2, "parent_slice": None}],
81+
[{"first_stream_id": 1, "parent_slice": {}}, {"first_stream_id": 2, "parent_slice": {}}],
8082
),
8183
(
8284
"test_with_parent_slices_and_records",
@@ -89,10 +91,10 @@ def read_records(
8991
)
9092
],
9193
[
92-
{"parent_slice": "first", "first_stream_id": 0},
93-
{"parent_slice": "first", "first_stream_id": 1},
94-
{"parent_slice": "second", "first_stream_id": 2},
95-
{"parent_slice": "third", "first_stream_id": None},
94+
{"parent_slice": {"slice": "first"}, "first_stream_id": 0},
95+
{"parent_slice": {"slice": "first"}, "first_stream_id": 1},
96+
{"parent_slice": {"slice": "second"}, "first_stream_id": 2},
97+
{"parent_slice": {"slice": "third"}, "first_stream_id": None},
9698
],
9799
),
98100
(
@@ -112,12 +114,12 @@ def read_records(
112114
),
113115
],
114116
[
115-
{"parent_slice": "first", "first_stream_id": 0},
116-
{"parent_slice": "first", "first_stream_id": 1},
117-
{"parent_slice": "second", "first_stream_id": 2},
118-
{"parent_slice": "third", "first_stream_id": None},
119-
{"parent_slice": "second_parent", "second_stream_id": 10},
120-
{"parent_slice": "second_parent", "second_stream_id": 20},
117+
{"parent_slice": {"slice": "first"}, "first_stream_id": 0},
118+
{"parent_slice": {"slice": "first"}, "first_stream_id": 1},
119+
{"parent_slice": {"slice": "second"}, "first_stream_id": 2},
120+
{"parent_slice": {"slice": "third"}, "first_stream_id": None},
121+
{"parent_slice": {"slice": "second_parent"}, "second_stream_id": 10},
122+
{"parent_slice": {"slice": "second_parent"}, "second_stream_id": 20},
121123
],
122124
),
123125
],

airbyte-integrations/connector-templates/source-configuration-based/setup.py.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from setuptools import find_packages, setup
77

88
MAIN_REQUIREMENTS = [
9-
"airbyte-cdk~=0.1.73",
9+
"airbyte-cdk~=0.1.76",
1010
]
1111

1212
TEST_REQUIREMENTS = [

0 commit comments

Comments
 (0)