MCPcopy Create free account
hub / github.com/apache/arrow / _read_table_internal

Function _read_table_internal

python/pyarrow/feather.py:243–286  ·  view source on GitHub ↗

Internal implementation for reading a Feather file as a pyarrow.Table. Emits a deprecation warning if the file is a legacy Feather V1 file.

(source, columns=None, memory_map=False,
                         use_threads=True)

Source from the content-addressed store, hash-verified

241
242
243def _read_table_internal(source, columns=None, memory_map=False,
244 use_threads=True):
245 """
246 Internal implementation for reading a Feather file as a pyarrow.Table.
247 Emits a deprecation warning if the file is a legacy Feather V1 file.
248 """
249 reader = _feather.FeatherReader(
250 source, use_memory_map=memory_map, use_threads=use_threads)
251
252 if reader.version < 3:
253 warnings.warn(
254 "Feather V1 files are deprecated as of 25.0.0 and support will "
255 "be removed in a future version. Consider rewriting this file "
256 "in the Arrow IPC file format (Feather V2).",
257 DeprecationWarning,
258 stacklevel=3
259 )
260
261 if columns is None:
262 return reader.read()
263
264 if not isinstance(columns, Sequence):
265 raise TypeError("Columns must be a sequence but, got {}"
266 .format(type(columns).__name__))
267
268 column_types = [type(column) for column in columns]
269 if all(map(lambda t: t == int, column_types)):
270 table = reader.read_indices(columns)
271 elif all(map(lambda t: t == str, column_types)):
272 table = reader.read_names(columns)
273 else:
274 column_type_names = [t.__name__ for t in column_types]
275 raise TypeError("Columns must be indices or names. "
276 f"Got columns {columns} of types {column_type_names}")
277
278 # Feather v1 already respects the column selection
279 if reader.version < 3:
280 return table
281 # Feather v2 reads with sorted / deduplicated selection
282 elif sorted(set(columns)) == columns:
283 return table
284 else:
285 # follow exact order / selection of names
286 return table.select(columns)
287
288
289def read_table(source, columns=None, memory_map=False, use_threads=True):

Callers 3

read_tableMethod · 0.85
read_featherFunction · 0.85
read_tableFunction · 0.85

Calls 6

mapFunction · 0.85
TypeErrorFunction · 0.50
typeEnum · 0.50
readMethod · 0.45
formatMethod · 0.45
selectMethod · 0.45

Tested by

no test coverage detected