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

Function test_fragments

python/pyarrow/tests/test_dataset.py:1402–1431  ·  view source on GitHub ↗
(tempdir, dataset_reader)

Source from the content-addressed store, hash-verified

1400
1401@pytest.mark.parquet
1402def test_fragments(tempdir, dataset_reader):
1403 table, dataset = _create_dataset_for_fragments(tempdir)
1404
1405 # list fragments
1406 fragments = list(dataset.get_fragments())
1407 assert len(fragments) == 2
1408 f = fragments[0]
1409
1410 physical_names = ['f1', 'f2']
1411 # file's schema does not include partition column
1412 assert f.physical_schema.names == physical_names
1413 assert f.format.inspect(f.path, f.filesystem) == f.physical_schema
1414 assert f.partition_expression.equals(ds.field('part') == 'a')
1415
1416 # By default, the partition column is not part of the schema.
1417 result = dataset_reader.to_table(f)
1418 assert result.column_names == physical_names
1419 assert result.equals(table.remove_column(2).slice(0, 4))
1420
1421 # scanning fragment includes partition columns when given the proper
1422 # schema.
1423 result = dataset_reader.to_table(f, schema=dataset.schema)
1424 assert result.column_names == ['f1', 'f2', 'part']
1425 assert result.equals(table.slice(0, 4))
1426 assert f.physical_schema == result.schema.remove(2)
1427
1428 # scanning fragments follow filter predicate
1429 result = dataset_reader.to_table(
1430 f, schema=dataset.schema, filter=ds.field('f1') < 2)
1431 assert result.column_names == ['f1', 'f2', 'part']
1432
1433
1434@pytest.mark.pandas

Callers

nothing calls this directly

Calls 9

listFunction · 0.85
lenFunction · 0.85
equalsMethod · 0.80
inspectMethod · 0.45
fieldMethod · 0.45
to_tableMethod · 0.45
sliceMethod · 0.45
remove_columnMethod · 0.45

Tested by

no test coverage detected