mongo-arrow icon indicating copy to clipboard operation
mongo-arrow copied to clipboard

Add an optional bool flag to the `write` function to skip writing `null` fields

Open alessio-locatelli opened this issue 1 year ago • 1 comments
trafficstars

Function parameters example

def write(collection, tabular, *, exclude_none: bool = False):
    ...

Usage example

write(collection, df, exclude_none=True)

How

Replacing https://github.com/mongodb-labs/mongo-arrow/blob/main/bindings/python/pymongoarrow/api.py#L390 with

if exclude_none:
    yield {k:v for k, v in row.items() if v is not None}
else:
    yield row

did the job.

alessio-locatelli avatar May 09 '24 09:05 alessio-locatelli

Hi @olk-m! I've opened https://jira.mongodb.org/browse/ARROW-233 to track the request.

blink1073 avatar May 09 '24 22:05 blink1073