Skip to content

Commit 19f4cf7

Browse files
committed
pr feedback and bug fix so we always include properties if no property chunking
1 parent df6dd69 commit 19f4cf7

File tree

4 files changed

+111
-41
lines changed

4 files changed

+111
-41
lines changed

airbyte_cdk/sources/declarative/requesters/query_properties/json_schema_property_selector.py

Lines changed: 0 additions & 38 deletions
This file was deleted.

airbyte_cdk/sources/declarative/requesters/query_properties/property_selector/json_schema_property_selector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def select(self) -> Optional[Set[str]]:
3636
This is different from the empty set where the json_schema was empty and no schema fields were selected.
3737
"""
3838

39-
# For CHECK/DISCOVER operations, there is no catalog and therefor no configured stream or selected
39+
# For CHECK/DISCOVER operations, there is no catalog and therefore no configured stream or selected
4040
# columns. In this case we return None which is interpreted by the QueryProperties component to not
4141
# perform any filtering of schema properties and fetch all of them
4242
if self.configured_stream is None:

airbyte_cdk/sources/declarative/requesters/query_properties/query_properties.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@ def get_request_property_chunks(
5858
)
5959
else:
6060
if configured_properties is not None:
61-
yield from [[field for field in fields if field in configured_properties]]
61+
all_fields = (
62+
[field for field in fields if field in configured_properties]
63+
if configured_properties is not None
64+
else list(fields)
65+
)
6266
else:
63-
yield list(fields)
67+
all_fields = list(fields)
68+
69+
if self.always_include_properties:
70+
all_fields = list(self.always_include_properties) + all_fields
71+
72+
yield all_fields

unit_tests/sources/declarative/requesters/query_properties/test_query_properties.py

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,105 @@ def test_get_request_property_chunks_static_list_with_always_include_properties(
149149
assert property_chunks[2] == ["zero", "seven", "lotus", "nine"]
150150

151151

152+
def test_get_request_no_property_chunking_selected_properties_always_include_properties():
153+
configured_airbyte_stream = _create_configured_airbyte_stream(
154+
["santa", "clover", "junpei", "june", "remove_me"]
155+
)
156+
157+
stream_slice = StreamSlice(cursor_slice={}, partition={})
158+
159+
query_properties = QueryProperties(
160+
property_list=[
161+
"ace",
162+
"snake",
163+
"santa",
164+
"clover",
165+
"junpei",
166+
"june",
167+
"seven",
168+
"lotus",
169+
"nine",
170+
],
171+
always_include_properties=["zero"],
172+
property_chunking=None,
173+
property_selector=JsonSchemaPropertySelector(
174+
configured_stream=configured_airbyte_stream,
175+
properties_transformations=[
176+
RemoveFields(field_pointers=[["remove_me"]], parameters={}),
177+
],
178+
config=CONFIG,
179+
parameters={},
180+
),
181+
config=CONFIG,
182+
parameters={},
183+
)
184+
185+
property_chunks = list(query_properties.get_request_property_chunks(stream_slice=stream_slice))
186+
187+
assert len(property_chunks) == 1
188+
assert property_chunks[0] == ["zero", "santa", "clover", "junpei", "june"]
189+
190+
191+
def test_get_request_no_property_chunking_always_include_properties():
192+
configured_airbyte_stream = _create_configured_airbyte_stream(
193+
[
194+
"ace",
195+
"snake",
196+
"santa",
197+
"clover",
198+
"junpei",
199+
"june",
200+
"seven",
201+
"lotus",
202+
"nine",
203+
]
204+
)
205+
206+
stream_slice = StreamSlice(cursor_slice={}, partition={})
207+
208+
query_properties = QueryProperties(
209+
property_list=[
210+
"ace",
211+
"snake",
212+
"santa",
213+
"clover",
214+
"junpei",
215+
"june",
216+
"seven",
217+
"lotus",
218+
"nine",
219+
],
220+
always_include_properties=["zero"],
221+
property_chunking=None,
222+
property_selector=JsonSchemaPropertySelector(
223+
configured_stream=configured_airbyte_stream,
224+
properties_transformations=[
225+
RemoveFields(field_pointers=[["remove_me"]], parameters={}),
226+
],
227+
config=CONFIG,
228+
parameters={},
229+
),
230+
config=CONFIG,
231+
parameters={},
232+
)
233+
234+
property_chunks = list(query_properties.get_request_property_chunks(stream_slice=stream_slice))
235+
236+
assert len(property_chunks) == 1
237+
assert property_chunks[0] == [
238+
"zero",
239+
"ace",
240+
"snake",
241+
"santa",
242+
"clover",
243+
"junpei",
244+
"june",
245+
"seven",
246+
"lotus",
247+
"nine",
248+
]
249+
250+
152251
def test_get_request_property_chunks_dynamic_endpoint():
153252
configured_airbyte_stream = _create_configured_airbyte_stream(
154253
["alice", "clover", "dio", "k", "luna", "phi", "quark", "sigma", "tenmyouji"]

0 commit comments

Comments
 (0)