()
| 2305 | |
| 2306 | |
| 2307 | def test_partitioning_function(): |
| 2308 | schema = pa.schema([("year", pa.int16()), ("month", pa.int8())]) |
| 2309 | names = ["year", "month"] |
| 2310 | |
| 2311 | # default DirectoryPartitioning |
| 2312 | part = ds.partitioning(schema) |
| 2313 | assert isinstance(part, ds.DirectoryPartitioning) |
| 2314 | part = ds.partitioning(schema, dictionaries="infer") |
| 2315 | assert isinstance(part, ds.PartitioningFactory) |
| 2316 | part = ds.partitioning(field_names=names) |
| 2317 | assert isinstance(part, ds.PartitioningFactory) |
| 2318 | # needs schema or list of names |
| 2319 | with pytest.raises(ValueError): |
| 2320 | ds.partitioning() |
| 2321 | with pytest.raises(ValueError, match="Expected list"): |
| 2322 | ds.partitioning(field_names=schema) |
| 2323 | with pytest.raises(ValueError, match="Cannot specify both"): |
| 2324 | ds.partitioning(schema, field_names=schema) |
| 2325 | |
| 2326 | # Hive partitioning |
| 2327 | part = ds.partitioning(schema, flavor="hive") |
| 2328 | assert isinstance(part, ds.HivePartitioning) |
| 2329 | part = ds.partitioning(schema, dictionaries="infer", flavor="hive") |
| 2330 | assert isinstance(part, ds.PartitioningFactory) |
| 2331 | part = ds.partitioning(flavor="hive") |
| 2332 | assert isinstance(part, ds.PartitioningFactory) |
| 2333 | # cannot pass list of names |
| 2334 | with pytest.raises(ValueError): |
| 2335 | ds.partitioning(names, flavor="hive") |
| 2336 | with pytest.raises(ValueError, match="Cannot specify 'field_names'"): |
| 2337 | ds.partitioning(field_names=names, flavor="hive") |
| 2338 | |
| 2339 | # unsupported flavor |
| 2340 | with pytest.raises(ValueError): |
| 2341 | ds.partitioning(schema, flavor="unsupported") |
| 2342 | |
| 2343 | |
| 2344 | @pytest.mark.parquet |
nothing calls this directly
no test coverage detected