Skip to content

Commit

Permalink
[SPARK-26645][PYTHON] Support decimals with negative scale when parsi…
Browse files Browse the repository at this point in the history
…ng datatype
  • Loading branch information
mgaido91 committed Jan 17, 2019
1 parent 650b879 commit d14e0b8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion python/pyspark/sql/types.py
Expand Up @@ -752,7 +752,7 @@ def __eq__(self, other):
for v in [ArrayType, MapType, StructType])


_FIXED_DECIMAL = re.compile(r"decimal\(\s*(\d+)\s*,\s*(\d+)\s*\)")
_FIXED_DECIMAL = re.compile(r"decimal\(\s*(\d+)\s*,\s*(-?\d+)\s*\)")


def _parse_datatype_string(s):
Expand Down Expand Up @@ -865,6 +865,8 @@ def _parse_datatype_json_string(json_string):
>>> complex_maptype = MapType(complex_structtype,
... complex_arraytype, False)
>>> check_datatype(complex_maptype)
>>> # Decimal with negative scale.
>>> check_datatype(DecimalType(1,-1))
"""
return _parse_datatype_json_value(json.loads(json_string))

Expand Down

0 comments on commit d14e0b8

Please sign in to comment.