5858_MAX_WRITE_BATCH_SIZE = max (100000 , MAX_WRITE_BATCH_SIZE )
5959
6060
61- def find_arrow_all (collection , query , * , schema , ** kwargs ):
61+ def find_arrow_all (collection , query , * , schema = None , ** kwargs ):
6262 """Method that returns the results of a find query as a
6363 :class:`pyarrow.Table` instance.
6464
6565 :Parameters:
6666 - `collection`: Instance of :class:`~pymongo.collection.Collection`.
6767 against which to run the ``find`` operation.
6868 - `query`: A mapping containing the query to use for the find operation.
69- - `schema`: Instance of :class:`~pymongoarrow.schema.Schema`.
69+ - `schema` (optional) : Instance of :class:`~pymongoarrow.schema.Schema`.
7070
7171 Additional keyword-arguments passed to this method will be passed
7272 directly to the underlying ``find`` operation.
@@ -84,23 +84,25 @@ def find_arrow_all(collection, query, *, schema, **kwargs):
8484 stacklevel = 2 ,
8585 )
8686
87- kwargs .setdefault ("projection" , schema ._get_projection ())
87+ if schema :
88+ kwargs .setdefault ("projection" , schema ._get_projection ())
89+
8890 raw_batch_cursor = collection .find_raw_batches (query , ** kwargs )
8991 for batch in raw_batch_cursor :
9092 process_bson_stream (batch , context )
9193
9294 return context .finish ()
9395
9496
95- def aggregate_arrow_all (collection , pipeline , * , schema , ** kwargs ):
97+ def aggregate_arrow_all (collection , pipeline , * , schema = None , ** kwargs ):
9698 """Method that returns the results of an aggregation pipeline as a
9799 :class:`pyarrow.Table` instance.
98100
99101 :Parameters:
100102 - `collection`: Instance of :class:`~pymongo.collection.Collection`.
101103 against which to run the ``aggregate`` operation.
102104 - `pipeline`: A list of aggregation pipeline stages.
103- - `schema`: Instance of :class:`~pymongoarrow.schema.Schema`.
105+ - `schema` (optional) : Instance of :class:`~pymongoarrow.schema.Schema`.
104106
105107 Additional keyword-arguments passed to this method will be passed
106108 directly to the underlying ``aggregate`` operation.
@@ -143,15 +145,15 @@ def _arrow_to_pandas(arrow_table):
143145 return arrow_table .to_pandas (split_blocks = True , self_destruct = True )
144146
145147
146- def find_pandas_all (collection , query , * , schema , ** kwargs ):
148+ def find_pandas_all (collection , query , * , schema = None , ** kwargs ):
147149 """Method that returns the results of a find query as a
148150 :class:`pandas.DataFrame` instance.
149151
150152 :Parameters:
151153 - `collection`: Instance of :class:`~pymongo.collection.Collection`.
152154 against which to run the ``find`` operation.
153155 - `query`: A mapping containing the query to use for the find operation.
154- - `schema`: Instance of :class:`~pymongoarrow.schema.Schema`.
156+ - `schema` (optional) : Instance of :class:`~pymongoarrow.schema.Schema`.
155157
156158 Additional keyword-arguments passed to this method will be passed
157159 directly to the underlying ``find`` operation.
@@ -162,15 +164,15 @@ def find_pandas_all(collection, query, *, schema, **kwargs):
162164 return _arrow_to_pandas (find_arrow_all (collection , query , schema = schema , ** kwargs ))
163165
164166
165- def aggregate_pandas_all (collection , pipeline , * , schema , ** kwargs ):
167+ def aggregate_pandas_all (collection , pipeline , * , schema = None , ** kwargs ):
166168 """Method that returns the results of an aggregation pipeline as a
167169 :class:`pandas.DataFrame` instance.
168170
169171 :Parameters:
170172 - `collection`: Instance of :class:`~pymongo.collection.Collection`.
171173 against which to run the ``find`` operation.
172174 - `pipeline`: A list of aggregation pipeline stages.
173- - `schema`: Instance of :class:`~pymongoarrow.schema.Schema`.
175+ - `schema` (optional) : Instance of :class:`~pymongoarrow.schema.Schema`.
174176
175177 Additional keyword-arguments passed to this method will be passed
176178 directly to the underlying ``aggregate`` operation.
@@ -181,7 +183,7 @@ def aggregate_pandas_all(collection, pipeline, *, schema, **kwargs):
181183 return _arrow_to_pandas (aggregate_arrow_all (collection , pipeline , schema = schema , ** kwargs ))
182184
183185
184- def _arrow_to_numpy (arrow_table , schema ):
186+ def _arrow_to_numpy (arrow_table , schema = None ):
185187 """Helper function that converts an Arrow Table to a dictionary
186188 containing NumPy arrays. The memory buffers backing the given Arrow Table
187189 may be destroyed after conversion if the resulting Numpy array(s) is not a
@@ -190,6 +192,9 @@ def _arrow_to_numpy(arrow_table, schema):
190192 See https://arrow.apache.org/docs/python/numpy.html for details.
191193 """
192194 container = {}
195+ if not schema :
196+ schema = arrow_table .schema
197+
193198 for fname in schema :
194199 dtype = get_numpy_type (schema .typemap [fname ])
195200 if dtype == np .str_ :
@@ -199,7 +204,7 @@ def _arrow_to_numpy(arrow_table, schema):
199204 return container
200205
201206
202- def find_numpy_all (collection , query , * , schema , ** kwargs ):
207+ def find_numpy_all (collection , query , * , schema = None , ** kwargs ):
203208 """Method that returns the results of a find query as a
204209 :class:`dict` instance whose keys are field names and values are
205210 :class:`~numpy.ndarray` instances bearing the appropriate dtype.
@@ -208,7 +213,7 @@ def find_numpy_all(collection, query, *, schema, **kwargs):
208213 - `collection`: Instance of :class:`~pymongo.collection.Collection`.
209214 against which to run the ``find`` operation.
210215 - `query`: A mapping containing the query to use for the find operation.
211- - `schema`: Instance of :class:`~pymongoarrow.schema.Schema`.
216+ - `schema` (optional) : Instance of :class:`~pymongoarrow.schema.Schema`.
212217
213218 Additional keyword-arguments passed to this method will be passed
214219 directly to the underlying ``find`` operation.
@@ -228,7 +233,7 @@ def find_numpy_all(collection, query, *, schema, **kwargs):
228233 return _arrow_to_numpy (find_arrow_all (collection , query , schema = schema , ** kwargs ), schema )
229234
230235
231- def aggregate_numpy_all (collection , pipeline , * , schema , ** kwargs ):
236+ def aggregate_numpy_all (collection , pipeline , * , schema = None , ** kwargs ):
232237 """Method that returns the results of an aggregation pipeline as a
233238 :class:`dict` instance whose keys are field names and values are
234239 :class:`~numpy.ndarray` instances bearing the appropriate dtype.
@@ -237,7 +242,7 @@ def aggregate_numpy_all(collection, pipeline, *, schema, **kwargs):
237242 - `collection`: Instance of :class:`~pymongo.collection.Collection`.
238243 against which to run the ``find`` operation.
239244 - `query`: A mapping containing the query to use for the find operation.
240- - `schema`: Instance of :class:`~pymongoarrow.schema.Schema`.
245+ - `schema` (optional) : Instance of :class:`~pymongoarrow.schema.Schema`.
241246
242247 Additional keyword-arguments passed to this method will be passed
243248 directly to the underlying ``aggregate`` operation.
0 commit comments