Skip to content

Commit 036b455

Browse files
authored
feat: Allow passing list of fields to unwind parameter (#256)
We're adding an option to unwind multiple fields when listing the dataset items. This adds an option to DatasetClient to pass those multiple fields in the unwind parameter.
1 parent b9bfd41 commit 036b455

File tree

2 files changed

+38
-19
lines changed

2 files changed

+38
-19
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
## [1.7.2](../../releases/tag/v1.7.2) - Unreleased
44

5-
### Add
5+
### Added
66

77
- add `headers_template` kwarg to webhook create and update
8+
- allow passing list of fields to `unwind` parameter in dataset item listing endpoints
89

910
## [1.7.1](../../releases/tag/v1.7.1) - 2024-07-11
1011

src/apify_client/clients/resource_clients/dataset.py

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ def list_items(
6666
desc: bool | None = None,
6767
fields: list[str] | None = None,
6868
omit: list[str] | None = None,
69-
unwind: str | None = None,
69+
unwind: str | list[str] | None = None, # TODO: change to list[str] only when doing a breaking release
70+
# https://github.com/apify/apify-client-python/issues/255
7071
skip_empty: bool | None = None,
7172
skip_hidden: bool | None = None,
7273
flatten: list[str] | None = None,
@@ -89,7 +90,8 @@ def list_items(
8990
Note that the fields in the outputted items are sorted the same way as they are specified in the fields parameter.
9091
You can use this feature to effectively fix the output format.
9192
omit (list of str, optional): A list of fields which should be omitted from the items.
92-
unwind (str, optional): Name of a field which should be unwound.
93+
unwind (str or list of str, optional): A list of fields which should be unwound, in order which they should be processed.
94+
Each field should be either an array or an object.
9395
If the field is an array then every element of the array will become a separate record and merged with parent object.
9496
If the unwound field is an object then it is merged with the parent object.
9597
If the unwound field is missing or its value is neither an array nor an object and therefore cannot be merged with a parent object,
@@ -145,7 +147,8 @@ def iterate_items(
145147
desc: bool | None = None,
146148
fields: list[str] | None = None,
147149
omit: list[str] | None = None,
148-
unwind: str | None = None,
150+
unwind: str | list[str] | None = None, # TODO: change to list[str] only when doing a breaking release
151+
# https://github.com/apify/apify-client-python/issues/255
149152
skip_empty: bool | None = None,
150153
skip_hidden: bool | None = None,
151154
) -> Iterator[dict]:
@@ -166,7 +169,8 @@ def iterate_items(
166169
Note that the fields in the outputted items are sorted the same way as they are specified in the fields parameter.
167170
You can use this feature to effectively fix the output format.
168171
omit (list of str, optional): A list of fields which should be omitted from the items.
169-
unwind (str, optional): Name of a field which should be unwound.
172+
unwind (str or list of str, optional): A list of fields which should be unwound, in order which they should be processed.
173+
Each field should be either an array or an object.
170174
If the field is an array then every element of the array will become a separate record and merged with parent object.
171175
If the unwound field is an object then it is merged with the parent object.
172176
If the unwound field is missing or its value is neither an array nor an object and therefore cannot be merged with a parent object,
@@ -225,7 +229,8 @@ def download_items(
225229
delimiter: str | None = None,
226230
fields: list[str] | None = None,
227231
omit: list[str] | None = None,
228-
unwind: str | None = None,
232+
unwind: str | list[str] | None = None, # TODO: change to list[str] only when doing a breaking release
233+
# https://github.com/apify/apify-client-python/issues/255
229234
skip_empty: bool | None = None,
230235
skip_header_row: bool | None = None,
231236
skip_hidden: bool | None = None,
@@ -258,7 +263,8 @@ def download_items(
258263
Note that the fields in the outputted items are sorted the same way as they are specified in the fields parameter.
259264
You can use this feature to effectively fix the output format.
260265
omit (list of str, optional): A list of fields which should be omitted from the items.
261-
unwind (str, optional): Name of a field which should be unwound.
266+
unwind (str or list of str, optional): A list of fields which should be unwound, in order which they should be processed.
267+
Each field should be either an array or an object.
262268
If the field is an array then every element of the array will become a separate record and merged with parent object.
263269
If the unwound field is an object then it is merged with the parent object.
264270
If the unwound field is missing or its value is neither an array nor an object and therefore cannot be merged with a parent object,
@@ -312,7 +318,8 @@ def get_items_as_bytes(
312318
delimiter: str | None = None,
313319
fields: list[str] | None = None,
314320
omit: list[str] | None = None,
315-
unwind: str | None = None,
321+
unwind: str | list[str] | None = None, # TODO: change to list[str] only when doing a breaking release
322+
# https://github.com/apify/apify-client-python/issues/255
316323
skip_empty: bool | None = None,
317324
skip_header_row: bool | None = None,
318325
skip_hidden: bool | None = None,
@@ -343,7 +350,8 @@ def get_items_as_bytes(
343350
Note that the fields in the outputted items are sorted the same way as they are specified in the fields parameter.
344351
You can use this feature to effectively fix the output format.
345352
omit (list of str, optional): A list of fields which should be omitted from the items.
346-
unwind (str, optional): Name of a field which should be unwound.
353+
unwind (str or list of str, optional): A list of fields which should be unwound, in order which they should be processed.
354+
Each field should be either an array or an object.
347355
If the field is an array then every element of the array will become a separate record and merged with parent object.
348356
If the unwound field is an object then it is merged with the parent object.
349357
If the unwound field is missing or its value is neither an array nor an object and therefore cannot be merged with a parent object,
@@ -401,7 +409,8 @@ def stream_items(
401409
delimiter: str | None = None,
402410
fields: list[str] | None = None,
403411
omit: list[str] | None = None,
404-
unwind: str | None = None,
412+
unwind: str | list[str] | None = None, # TODO: change to list[str] only when doing a breaking release
413+
# https://github.com/apify/apify-client-python/issues/255
405414
skip_empty: bool | None = None,
406415
skip_header_row: bool | None = None,
407416
skip_hidden: bool | None = None,
@@ -431,7 +440,8 @@ def stream_items(
431440
Note that the fields in the outputted items are sorted the same way as they are specified in the fields parameter.
432441
You can use this feature to effectively fix the output format.
433442
omit (list of str, optional): A list of fields which should be omitted from the items.
434-
unwind (str, optional): Name of a field which should be unwound.
443+
unwind (str or list of str, optional): A list of fields which should be unwound, in order which they should be processed.
444+
Each field should be either an array or an object.
435445
If the field is an array then every element of the array will become a separate record and merged with parent object.
436446
If the unwound field is an object then it is merged with the parent object.
437447
If the unwound field is missing or its value is neither an array nor an object and therefore cannot be merged with a parent object,
@@ -557,7 +567,8 @@ async def list_items(
557567
desc: bool | None = None,
558568
fields: list[str] | None = None,
559569
omit: list[str] | None = None,
560-
unwind: str | None = None,
570+
unwind: str | list[str] | None = None, # TODO: change to list[str] only when doing a breaking release
571+
# https://github.com/apify/apify-client-python/issues/255
561572
skip_empty: bool | None = None,
562573
skip_hidden: bool | None = None,
563574
flatten: list[str] | None = None,
@@ -580,7 +591,8 @@ async def list_items(
580591
Note that the fields in the outputted items are sorted the same way as they are specified in the fields parameter.
581592
You can use this feature to effectively fix the output format.
582593
omit (list of str, optional): A list of fields which should be omitted from the items.
583-
unwind (str, optional): Name of a field which should be unwound.
594+
unwind (str or list of str, optional): A list of fields which should be unwound, in order which they should be processed.
595+
Each field should be either an array or an object.
584596
If the field is an array then every element of the array will become a separate record and merged with parent object.
585597
If the unwound field is an object then it is merged with the parent object.
586598
If the unwound field is missing or its value is neither an array nor an object and therefore cannot be merged with a parent object,
@@ -636,7 +648,8 @@ async def iterate_items(
636648
desc: bool | None = None,
637649
fields: list[str] | None = None,
638650
omit: list[str] | None = None,
639-
unwind: str | None = None,
651+
unwind: str | list[str] | None = None, # TODO: change to list[str] only when doing a breaking release
652+
# https://github.com/apify/apify-client-python/issues/255
640653
skip_empty: bool | None = None,
641654
skip_hidden: bool | None = None,
642655
) -> AsyncIterator[dict]:
@@ -657,7 +670,8 @@ async def iterate_items(
657670
Note that the fields in the outputted items are sorted the same way as they are specified in the fields parameter.
658671
You can use this feature to effectively fix the output format.
659672
omit (list of str, optional): A list of fields which should be omitted from the items.
660-
unwind (str, optional): Name of a field which should be unwound.
673+
unwind (str or list of str, optional): A list of fields which should be unwound, in order which they should be processed.
674+
Each field should be either an array or an object.
661675
If the field is an array then every element of the array will become a separate record and merged with parent object.
662676
If the unwound field is an object then it is merged with the parent object.
663677
If the unwound field is missing or its value is neither an array nor an object and therefore cannot be merged with a parent object,
@@ -717,7 +731,8 @@ async def get_items_as_bytes(
717731
delimiter: str | None = None,
718732
fields: list[str] | None = None,
719733
omit: list[str] | None = None,
720-
unwind: str | None = None,
734+
unwind: str | list[str] | None = None, # TODO: change to list[str] only when doing a breaking release
735+
# https://github.com/apify/apify-client-python/issues/255
721736
skip_empty: bool | None = None,
722737
skip_header_row: bool | None = None,
723738
skip_hidden: bool | None = None,
@@ -748,7 +763,8 @@ async def get_items_as_bytes(
748763
Note that the fields in the outputted items are sorted the same way as they are specified in the fields parameter.
749764
You can use this feature to effectively fix the output format.
750765
omit (list of str, optional): A list of fields which should be omitted from the items.
751-
unwind (str, optional): Name of a field which should be unwound.
766+
unwind (str or list of str, optional): A list of fields which should be unwound, in order which they should be processed.
767+
Each field should be either an array or an object.
752768
If the field is an array then every element of the array will become a separate record and merged with parent object.
753769
If the unwound field is an object then it is merged with the parent object.
754770
If the unwound field is missing or its value is neither an array nor an object and therefore cannot be merged with a parent object,
@@ -806,7 +822,8 @@ async def stream_items(
806822
delimiter: str | None = None,
807823
fields: list[str] | None = None,
808824
omit: list[str] | None = None,
809-
unwind: str | None = None,
825+
unwind: str | list[str] | None = None, # TODO: change to list[str] only when doing a breaking release
826+
# https://github.com/apify/apify-client-python/issues/255
810827
skip_empty: bool | None = None,
811828
skip_header_row: bool | None = None,
812829
skip_hidden: bool | None = None,
@@ -836,7 +853,8 @@ async def stream_items(
836853
Note that the fields in the outputted items are sorted the same way as they are specified in the fields parameter.
837854
You can use this feature to effectively fix the output format.
838855
omit (list of str, optional): A list of fields which should be omitted from the items.
839-
unwind (str, optional): Name of a field which should be unwound.
856+
unwind (str or list of str, optional): A list of fields which should be unwound, in order which they should be processed.
857+
Each field should be either an array or an object.
840858
If the field is an array then every element of the array will become a separate record and merged with parent object.
841859
If the unwound field is an object then it is merged with the parent object.
842860
If the unwound field is missing or its value is neither an array nor an object and therefore cannot be merged with a parent object,

0 commit comments

Comments
 (0)