Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lang/py/avro/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,7 @@ def get_other_props(all_props: Mapping[str, object], reserved_props: Sequence[st

def make_bytes_decimal_schema(other_props):
"""Make a BytesDecimalSchema from just other_props."""
return BytesDecimalSchema(other_props.get("precision"), other_props.get("scale", 0))
return BytesDecimalSchema(other_props.get("precision"), other_props.get("scale", 0), other_props)


def make_logical_schema(logical_type, type_, other_props):
Expand Down
4 changes: 2 additions & 2 deletions lang/py/avro/test/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,16 +642,16 @@ def test_decimal_valid_type(self):
}
)

bytes_decimal_schema = ValidTestSchema({"type": "bytes", "logicalType": "decimal", "precision": 4})

fixed_decimal = fixed_decimal_schema.parse()
self.assertEqual(4, fixed_decimal.get_prop("precision"))
self.assertEqual(2, fixed_decimal.get_prop("scale"))
self.assertEqual(2, fixed_decimal.get_prop("size"))

bytes_decimal_schema = ValidTestSchema({"type": "bytes", "logicalType": "decimal", "precision": 4})
bytes_decimal = bytes_decimal_schema.parse()
self.assertEqual(4, bytes_decimal.get_prop("precision"))
self.assertEqual(0, bytes_decimal.get_prop("scale"))
self.assertEqual("decimal", bytes_decimal.get_prop("logicalType"))

def test_fixed_decimal_valid_max_precision(self):
# An 8 byte number can represent any 18 digit number.
Expand Down