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

Function _read_table_internal

python/pyarrow/feather.py:264–298  ·  view source on GitHub ↗

Internal implementation for reading a Feather file as a pyarrow.Table. Does not emit deprecation warnings.

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

Source from the content-addressed store, hash-verified

262
263
264def _read_table_internal(source, columns=None, memory_map=False,
265 use_threads=True):
266 """
267 Internal implementation for reading a Feather file as a pyarrow.Table.
268 Does not emit deprecation warnings.
269 """
270 reader = _feather.FeatherReader(
271 source, use_memory_map=memory_map, use_threads=use_threads)
272
273 if columns is None:
274 return reader.read()
275
276 if not isinstance(columns, Sequence):
277 raise TypeError("Columns must be a sequence but, got {}"
278 .format(type(columns).__name__))
279
280 column_types = [type(column) for column in columns]
281 if all(map(lambda t: t == int, column_types)):
282 table = reader.read_indices(columns)
283 elif all(map(lambda t: t == str, column_types)):
284 table = reader.read_names(columns)
285 else:
286 column_type_names = [t.__name__ for t in column_types]
287 raise TypeError("Columns must be indices or names. "
288 f"Got columns {columns} of types {column_type_names}")
289
290 # Feather v1 already respects the column selection
291 if reader.version < 3:
292 return table
293 # Feather v2 reads with sorted / deduplicated selection
294 elif sorted(set(columns)) == columns:
295 return table
296 else:
297 # follow exact order / selection of names
298 return table.select(columns)
299
300
301def 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