(mockfs, infer_dictionary, pickled,
pickle_module)
| 2000 | @pytest.mark.parametrize( |
| 2001 | "pickled", [lambda x, m: x, lambda x, m: m.loads(m.dumps(x))]) |
| 2002 | def test_partitioning_factory_dictionary(mockfs, infer_dictionary, pickled, |
| 2003 | pickle_module): |
| 2004 | paths_or_selector = fs.FileSelector('subdir', recursive=True) |
| 2005 | format = ds.ParquetFileFormat() |
| 2006 | options = ds.FileSystemFactoryOptions('subdir') |
| 2007 | |
| 2008 | partitioning_factory = ds.DirectoryPartitioning.discover( |
| 2009 | ['group', 'key'], infer_dictionary=infer_dictionary) |
| 2010 | options.partitioning_factory = pickled(partitioning_factory, pickle_module) |
| 2011 | |
| 2012 | factory = ds.FileSystemDatasetFactory( |
| 2013 | mockfs, paths_or_selector, format, options) |
| 2014 | |
| 2015 | inferred_schema = factory.inspect() |
| 2016 | if infer_dictionary: |
| 2017 | expected_type = pa.dictionary(pa.int32(), pa.string()) |
| 2018 | assert inferred_schema.field('key').type == expected_type |
| 2019 | |
| 2020 | table = factory.finish().to_table().combine_chunks() |
| 2021 | actual = table.column('key').chunk(0) |
| 2022 | expected = pa.array(['xxx'] * 5 + ['yyy'] * 5).dictionary_encode() |
| 2023 | assert actual.equals(expected) |
| 2024 | |
| 2025 | # ARROW-9345 ensure filtering on the partition field works |
| 2026 | table = factory.finish().to_table(filter=ds.field('key') == 'xxx') |
| 2027 | actual = table.column('key').chunk(0) |
| 2028 | expected = expected.slice(0, 5) |
| 2029 | assert actual.equals(expected) |
| 2030 | else: |
| 2031 | assert inferred_schema.field('key').type == pa.string() |
| 2032 | |
| 2033 | |
| 2034 | @pytest.mark.parametrize( |
nothing calls this directly
no test coverage detected