File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5757from pyiceberg .utils .parsing import ParseNumberFromBrackets
5858from pyiceberg .utils .singleton import Singleton
5959
60- DECIMAL_REGEX = re .compile (r"decimal\((\d+),\s*(\d+)\)" )
60+ DECIMAL_REGEX = re .compile (r"decimal\(\s* (\d+)\s* ,\s*(\d+)\s* \)" )
6161FIXED = "fixed"
6262FIXED_PARSER = ParseNumberFromBrackets (FIXED )
6363
Original file line number Diff line number Diff line change @@ -514,6 +514,21 @@ def test_deserialization_decimal() -> None:
514514 assert decimal .scale == 25
515515
516516
517+ @pytest .mark .parametrize (
518+ "decimal_str" ,
519+ [
520+ "decimal(9,2)" ,
521+ "decimal(9, 2)" ,
522+ "decimal( 9, 2 )" ,
523+ "decimal( 9 , 2 )" ,
524+ "decimal(9 ,2)" ,
525+ ],
526+ )
527+ def test_deserialization_decimal_optional_whitespace (decimal_str : str ) -> None :
528+ # Readers accept optional whitespace around parameters and the separator.
529+ assert DecimalType .model_validate_json (f'"{ decimal_str } "' ) == DecimalType (9 , 2 )
530+
531+
517532def test_deserialization_decimal_failure () -> None :
518533 with pytest .raises (ValidationError ) as exc_info :
519534 _ = DecimalType .model_validate_json ('"decimal(abc, def)"' )
You can’t perform that action at this time.
0 commit comments