Skip to content
Open
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 parquet/converted_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def convert_column(data, schemae):
"""Convert known types from primitive to rich."""
ctype = schemae.converted_type
if ctype == parquet_thrift.ConvertedType.DECIMAL:
scale_factor = Decimal("10e-{}".format(schemae.scale))
scale_factor = Decimal("1e-{}".format(schemae.scale))
if schemae.type == parquet_thrift.Type.INT32 or schemae.type == parquet_thrift.Type.INT64:
return [Decimal(unscaled) * scale_factor for unscaled in data]
return [Decimal(intbig(unscaled)) * scale_factor for unscaled in data]
Expand Down
8 changes: 4 additions & 4 deletions test/test_converted_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_int32(self):

self.assertEqual(
convert_column([9876543210], schema)[0],
Decimal('9.87654321')
Decimal('0.987654321')
)

def test_int64(self):
Expand All @@ -43,7 +43,7 @@ def test_int64(self):

self.assertEqual(
convert_column([1099511627776], schema)[0],
Decimal('10995116277.76')
Decimal('1099511627.776')
)

def test_fixedlength(self):
Expand All @@ -59,7 +59,7 @@ def test_fixedlength(self):

self.assertEqual(
convert_column([b'\x02\x00\x01'], schema)[0],
Decimal('1310.73')
Decimal('131.073')
)

def test_binary(self):
Expand All @@ -74,7 +74,7 @@ def test_binary(self):

self.assertEqual(
convert_column([b'\x02\x00\x00\x00\x00\x00\x00\x00\x00\x01'], schema)[0],
Decimal('94447329657392904273.93')
Decimal('9444732965739290427.393')
)


Expand Down