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

Function test_hive_partitioning_dictionary_key

python/pyarrow/tests/test_dataset.py:2366–2391  ·  view source on GitHub ↗
(multisourcefs)

Source from the content-addressed store, hash-verified

2364
2365
2366def 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
2394def _create_single_file(base_dir, table=None, row_group_size=None):

Callers

nothing calls this directly

Calls 7

listFunction · 0.85
equalsMethod · 0.80
schemaMethod · 0.45
fieldMethod · 0.45
dictionaryMethod · 0.45
to_tableMethod · 0.45
columnMethod · 0.45

Tested by

no test coverage detected