Skip to content

Commit 3d93424

Browse files
committed
fix(target-s3-parquet): add a function to conver Decimal values
1 parent ba19a66 commit 3d93424

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

target_s3_parquet/sanitizer.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@
22
import numpy as np
33
import json
44
from typing import List
5-
5+
from decimal import Decimal
66

77
def _remove_nulls(array):
88
return [v for v in array if v != "null"]
99

1010

11+
def _convert_decimal(value):
12+
if isinstance(value, Decimal):
13+
return str(value)
14+
return value
15+
16+
1117
def get_valid_types(types):
1218
if isinstance(types, list):
1319
return _remove_nulls(types)[0]
@@ -47,7 +53,7 @@ def apply_json_dump_to_df(
4753
valid_attributes = get_valid_attributes(attributes_names, df)
4854
if len(valid_attributes) > 0:
4955
for attribute in valid_attributes:
50-
df.loc[:, attribute] = df[attribute].apply(lambda x: json.dumps(x))
56+
df.loc[:, attribute] = df[attribute].apply(lambda x: json.dumps(x, default=_convert_decimal))
5157
return df
5258

5359

0 commit comments

Comments
 (0)