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

Function promotable_mockfs

python/pyarrow/tests/test_dataset.py:151–183  ·  view source on GitHub ↗

Creates a _MockFileSystem with two parquet files that have promotable schemas. - file1: value: int8, dictionary: dictionary - file2: value: uint16, dictionary: dictionary

()

Source from the content-addressed store, hash-verified

149
150@pytest.fixture
151def promotable_mockfs():
152 """
153 Creates a _MockFileSystem with two parquet files that have promotable schemas.
154 - file1: value: int8, dictionary: dictionary<int8, string>
155 - file2: value: uint16, dictionary: dictionary<int16, string>
156 """
157 mockfs = fs._MockFileSystem()
158
159 table1 = pa.table({
160 'value': pa.array([1, 2], type=pa.int8()),
161 'dictionary': pa.DictionaryArray.from_arrays(
162 pa.array([0, 1], type=pa.int8()),
163 ['a', 'b'],
164 ),
165 })
166 table2 = pa.table({
167 'value': pa.array([3, 4], type=pa.uint16()),
168 'dictionary': pa.DictionaryArray.from_arrays(
169 pa.array([1, 0], type=pa.int16()),
170 ['d', 'c'],
171 ),
172 })
173
174 mockfs.create_dir('subdir/zzz')
175 path1 = 'subdir/zzz/file1.parquet'
176 with mockfs.open_output_stream(path1) as out:
177 pq.write_table(table1, out)
178
179 path2 = 'subdir/zzz/file2.parquet'
180 with mockfs.open_output_stream(path2) as out:
181 pq.write_table(table2, out)
182
183 return mockfs, path1, path2
184
185
186@pytest.fixture

Callers

nothing calls this directly

Calls 4

arrayMethod · 0.45
create_dirMethod · 0.45
open_output_streamMethod · 0.45
write_tableMethod · 0.45

Tested by

no test coverage detected