Skip to content

Commit 09a4e86

Browse files
hzmshclaude
andcommitted
test: cover float32 defaults read from JSON
Float defaults are now stored as float32 values, like Java, so the REST round-trip test's float default of 22.27 read back as 22.270000457763672. Use 22.25, which is exact in float32, and add a unit test for reading a float default from JSON. Generated-by: Claude Code (Claude Opus 5.5) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 17274e8 commit 09a4e86

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

‎tests/integration/test_rest_schema.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,7 @@ def test_add_required_column(catalog: Catalog) -> None:
11001100
(BooleanType(), True, False),
11011101
(IntegerType(), 123, 456),
11021102
(LongType(), 123, 456),
1103-
(FloatType(), 19.25, 22.27),
1103+
(FloatType(), 19.25, 22.25), # exact in float32, so it reads back unchanged
11041104
(DoubleType(), 19.25, 22.27),
11051105
(DecimalType(10, 2), Decimal("19.25"), Decimal("22.27")),
11061106
(DecimalType(10, 2), Decimal("19.25"), Decimal("22.27")),

‎tests/test_conversions.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,11 @@ def test_json_serialize_roundtrip(primitive_type: PrimitiveType, value: Any) ->
609609
assert value == conversions.from_json(primitive_type, conversions.to_json(primitive_type, value))
610610

611611

612+
def test_json_float_is_read_as_float32() -> None:
613+
assert conversions.from_json(FloatType(), 22.27) == 22.270000457763672
614+
assert conversions.from_json(DoubleType(), 22.27) == 22.27
615+
616+
612617
def test_unknown_type_conversions() -> None:
613618
"""Unknown values are always null, so they have no binary or partition representation."""
614619
unknown = UnknownType()

0 commit comments

Comments
 (0)