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

Function _read_table_internal

python/pyarrow/feather.py:238–281  ·  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

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