| 2364 | |
| 2365 | |
| 2366 | def test_hive_partitioning_dictionary_key(multisourcefs): |
| 2367 | # ARROW-8088 specifying partition key as dictionary type |
| 2368 | schema = pa.schema([ |
| 2369 | pa.field('year', pa.dictionary(pa.int8(), pa.int16())), |
| 2370 | pa.field('month', pa.dictionary(pa.int8(), pa.int16())) |
| 2371 | ]) |
| 2372 | part = ds.HivePartitioning.discover(schema=schema) |
| 2373 | |
| 2374 | dataset = ds.dataset( |
| 2375 | "hive", format="parquet", filesystem=multisourcefs, partitioning=part |
| 2376 | ) |
| 2377 | assert dataset.partitioning.schema == schema |
| 2378 | table = dataset.to_table() |
| 2379 | |
| 2380 | year_dictionary = list(range(2006, 2011)) |
| 2381 | month_dictionary = list(range(1, 13)) |
| 2382 | assert table.column('year').type.equals(schema.types[0]) |
| 2383 | for chunk in table.column('year').chunks: |
| 2384 | actual = chunk.dictionary.to_pylist() |
| 2385 | actual.sort() |
| 2386 | assert actual == year_dictionary |
| 2387 | assert table.column('month').type.equals(schema.types[1]) |
| 2388 | for chunk in table.column('month').chunks: |
| 2389 | actual = chunk.dictionary.to_pylist() |
| 2390 | actual.sort() |
| 2391 | assert actual == month_dictionary |
| 2392 | |
| 2393 | |
| 2394 | def _create_single_file(base_dir, table=None, row_group_size=None): |