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

Method test_explicit_schema_decimal

python/pyarrow/tests/test_json.py:248–263  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

246 assert table.num_rows == 2
247
248 def test_explicit_schema_decimal(self):
249 rows = (b'{"a": 1}\n'
250 b'{"a": 1.45}\n'
251 b'{"a": -23.456}\n'
252 b'{}\n')
253 expected = {
254 'a': [Decimal("1"), Decimal("1.45"), Decimal("-23.456"), None],
255 }
256
257 decimal_types = (pa.decimal32, pa.decimal64, pa.decimal128, pa.decimal256)
258 for type_factory in decimal_types:
259 schema = pa.schema([('a', type_factory(9, 4))])
260 opts = ParseOptions(explicit_schema=schema)
261 table = self.read_bytes(rows, parse_options=opts)
262 assert table.schema == schema
263 assert table.to_pydict() == expected
264
265 def test_explicit_schema_with_unexpected_behaviour(self):
266 # infer by default

Callers

nothing calls this directly

Calls 4

read_bytesMethod · 0.95
DecimalClass · 0.90
ParseOptionsClass · 0.90
schemaMethod · 0.45

Tested by

no test coverage detected