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

Function test_schema_duplicate_fields

python/pyarrow/tests/test_schema.py:385–414  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

383
384
385def test_schema_duplicate_fields():
386 fields = [
387 pa.field('foo', pa.int32()),
388 pa.field('bar', pa.string()),
389 pa.field('foo', pa.list_(pa.int8())),
390 ]
391 sch = pa.schema(fields)
392 assert sch.names == ['foo', 'bar', 'foo']
393 assert sch.types == [pa.int32(), pa.string(), pa.list_(pa.int8())]
394 assert len(sch) == 3
395 assert repr(sch) == """\
396foo: int32
397bar: string
398foo: list<item: int8>
399 child 0, item: int8"""
400
401 assert sch[0].name == 'foo'
402 assert sch[0].type == fields[0].type
403 with pytest.warns(FutureWarning):
404 assert sch.field_by_name('bar') == fields[1]
405 with pytest.warns(FutureWarning):
406 assert sch.field_by_name('xxx') is None
407 with pytest.warns((UserWarning, FutureWarning)):
408 assert sch.field_by_name('foo') is None
409
410 # Schema::GetFieldIndex
411 assert sch.get_field_index('foo') == -1
412
413 # Schema::GetAllFieldIndices
414 assert sch.get_all_field_indices('foo') == [0, 2]
415
416
417def test_field_flatten():

Callers

nothing calls this directly

Calls 4

lenFunction · 0.85
fieldMethod · 0.45
stringMethod · 0.45
schemaMethod · 0.45

Tested by

no test coverage detected