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

Method test_explicit_schema_decimal

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

Source from the content-addressed store, hash-verified

240 assert table.num_rows == 2
241
242 def test_explicit_schema_decimal(self):
243 rows = (b'{"a": 1}\n'
244 b'{"a": 1.45}\n'
245 b'{"a": -23.456}\n'
246 b'{}\n')
247 expected = {
248 'a': [Decimal("1"), Decimal("1.45"), Decimal("-23.456"), None],
249 }
250
251 decimal_types = (pa.decimal32, pa.decimal64, pa.decimal128, pa.decimal256)
252 for type_factory in decimal_types:
253 schema = pa.schema([('a', type_factory(9, 4))])
254 opts = ParseOptions(explicit_schema=schema)
255 table = self.read_bytes(rows, parse_options=opts)
256 assert table.schema == schema
257 assert table.to_pydict() == expected
258
259 def test_explicit_schema_with_unexpected_behaviour(self):
260 # 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