[ 
https://issues.apache.org/jira/browse/ARROW-1845?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16263457#comment-16263457
 ] 

ASF GitHub Bot commented on ARROW-1845:
---------------------------------------

wesm closed pull request #1348: ARROW-1845: [Python] Expose Decimal128Type
URL: https://github.com/apache/arrow/pull/1348
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/python/doc/source/api.rst b/python/doc/source/api.rst
index 8f2f23d9f..fb2a28677 100644
--- a/python/doc/source/api.rst
+++ b/python/doc/source/api.rst
@@ -50,7 +50,7 @@ Type and Schema Factory Functions
    date64
    binary
    string
-   decimal
+   decimal128
    list_
    struct
    dictionary
diff --git a/python/pyarrow/__init__.py b/python/pyarrow/__init__.py
index c8ded2d3c..c4db36e55 100644
--- a/python/pyarrow/__init__.py
+++ b/python/pyarrow/__init__.py
@@ -35,7 +35,7 @@
                          uint8, uint16, uint32, uint64,
                          time32, time64, timestamp, date32, date64,
                          float16, float32, float64,
-                         binary, string, decimal,
+                         binary, string, decimal128,
                          list_, struct, union, dictionary, field,
                          type_for_alias,
                          DataType, NAType,
diff --git a/python/pyarrow/includes/libarrow.pxd 
b/python/pyarrow/includes/libarrow.pxd
index 73e34c7b2..f1f59384b 100644
--- a/python/pyarrow/includes/libarrow.pxd
+++ b/python/pyarrow/includes/libarrow.pxd
@@ -209,10 +209,10 @@ cdef extern from "arrow/api.h" namespace "arrow" nogil:
         int byte_width()
         int bit_width()
 
-    cdef cppclass CDecimalType" arrow::DecimalType"(CFixedSizeBinaryType):
+    cdef cppclass CDecimal128Type" 
arrow::Decimal128Type"(CFixedSizeBinaryType):
+        CDecimal128Type(int precision, int scale)
         int precision()
         int scale()
-        CDecimalType(int precision, int scale)
 
     cdef cppclass CField" arrow::Field":
         const c_string& name()
diff --git a/python/pyarrow/lib.pxd b/python/pyarrow/lib.pxd
index 6413b838f..5abb72ba4 100644
--- a/python/pyarrow/lib.pxd
+++ b/python/pyarrow/lib.pxd
@@ -81,9 +81,9 @@ cdef class FixedSizeBinaryType(DataType):
         const CFixedSizeBinaryType* fixed_size_binary_type
 
 
-cdef class DecimalType(FixedSizeBinaryType):
+cdef class Decimal128Type(FixedSizeBinaryType):
     cdef:
-        const CDecimalType* decimal_type
+        const CDecimal128Type* decimal128_type
 
 
 cdef class Field:
diff --git a/python/pyarrow/pandas_compat.py b/python/pyarrow/pandas_compat.py
index 0aab9a41b..a50ef96e7 100644
--- a/python/pyarrow/pandas_compat.py
+++ b/python/pyarrow/pandas_compat.py
@@ -80,7 +80,7 @@ def get_logical_type(arrow_type):
             return 'list[{}]'.format(get_logical_type(arrow_type.value_type))
         elif isinstance(arrow_type, pa.lib.TimestampType):
             return 'datetimetz' if arrow_type.tz is not None else 'datetime'
-        elif isinstance(arrow_type, pa.lib.DecimalType):
+        elif isinstance(arrow_type, pa.lib.Decimal128Type):
             return 'decimal'
         raise NotImplementedError(str(arrow_type))
 
diff --git a/python/pyarrow/public-api.pxi b/python/pyarrow/public-api.pxi
index 90aff9e93..bf670c5c4 100644
--- a/python/pyarrow/public-api.pxi
+++ b/python/pyarrow/public-api.pxi
@@ -78,7 +78,7 @@ cdef public api object pyarrow_wrap_data_type(
     elif type.get().id() == _Type_FIXED_SIZE_BINARY:
         out = FixedSizeBinaryType()
     elif type.get().id() == _Type_DECIMAL:
-        out = DecimalType()
+        out = Decimal128Type()
     else:
         out = DataType()
 
diff --git a/python/pyarrow/tests/test_array.py 
b/python/pyarrow/tests/test_array.py
index b7b0b1833..a4d781a33 100644
--- a/python/pyarrow/tests/test_array.py
+++ b/python/pyarrow/tests/test_array.py
@@ -470,7 +470,7 @@ def test_simple_type_construction():
         (pa.binary(length=4), 'bytes'),
         (pa.string(), 'unicode'),
         (pa.list_(pa.list_(pa.int16())), 'list[list[int16]]'),
-        (pa.decimal(18, 3), 'decimal'),
+        (pa.decimal128(18, 3), 'decimal'),
         (pa.timestamp('ms'), 'datetime'),
         (pa.timestamp('us', 'UTC'), 'datetimetz'),
         (pa.time32('s'), 'time'),
diff --git a/python/pyarrow/tests/test_convert_builtin.py 
b/python/pyarrow/tests/test_convert_builtin.py
index c7a0d49b4..4c3d9e563 100644
--- a/python/pyarrow/tests/test_convert_builtin.py
+++ b/python/pyarrow/tests/test_convert_builtin.py
@@ -314,7 +314,7 @@ def test_mixed_types_fails(self):
 
     def test_decimal(self):
         data = [decimal.Decimal('1234.183'), decimal.Decimal('8094.234')]
-        type = pa.decimal(precision=7, scale=3)
+        type = pa.decimal128(precision=7, scale=3)
         arr = pa.array(data, type=type)
         assert arr.to_pylist() == data
 
@@ -322,32 +322,32 @@ def test_decimal_different_precisions(self):
         data = [
             decimal.Decimal('1234234983.183'), decimal.Decimal('80943244.234')
         ]
-        type = pa.decimal(precision=13, scale=3)
+        type = pa.decimal128(precision=13, scale=3)
         arr = pa.array(data, type=type)
         assert arr.to_pylist() == data
 
     def test_decimal_no_scale(self):
         data = [decimal.Decimal('1234234983'), decimal.Decimal('8094324')]
-        type = pa.decimal(precision=10)
+        type = pa.decimal128(precision=10)
         arr = pa.array(data, type=type)
         assert arr.to_pylist() == data
 
     def test_decimal_negative(self):
         data = [decimal.Decimal('-1234.234983'), decimal.Decimal('-8.094324')]
-        type = pa.decimal(precision=10, scale=6)
+        type = pa.decimal128(precision=10, scale=6)
         arr = pa.array(data, type=type)
         assert arr.to_pylist() == data
 
     def test_decimal_no_whole_part(self):
         data = [decimal.Decimal('-.4234983'), decimal.Decimal('.0103943')]
-        type = pa.decimal(precision=7, scale=7)
+        type = pa.decimal128(precision=7, scale=7)
         arr = pa.array(data, type=type)
         assert arr.to_pylist() == data
 
     def test_decimal_large_integer(self):
         data = [decimal.Decimal('-394029506937548693.42983'),
                 decimal.Decimal('32358695912932.01033')]
-        type = pa.decimal(precision=23, scale=5)
+        type = pa.decimal128(precision=23, scale=5)
         arr = pa.array(data, type=type)
         assert arr.to_pylist() == data
 
diff --git a/python/pyarrow/tests/test_convert_pandas.py 
b/python/pyarrow/tests/test_convert_pandas.py
index b9c3a1221..a2a1d6b69 100644
--- a/python/pyarrow/tests/test_convert_pandas.py
+++ b/python/pyarrow/tests/test_convert_pandas.py
@@ -828,7 +828,7 @@ def test_decimal_32_from_pandas(self):
             ]
         })
         converted = pa.Table.from_pandas(expected, preserve_index=False)
-        field = pa.field('decimals', pa.decimal(7, 3))
+        field = pa.field('decimals', pa.decimal128(7, 3))
         schema = pa.schema([field])
         assert converted.schema.equals(schema)
 
@@ -851,7 +851,7 @@ def test_decimal_64_from_pandas(self):
             ]
         })
         converted = pa.Table.from_pandas(expected, preserve_index=False)
-        field = pa.field('decimals', pa.decimal(12, 6))
+        field = pa.field('decimals', pa.decimal128(12, 6))
         schema = pa.schema([field])
         assert converted.schema.equals(schema)
 
@@ -874,7 +874,7 @@ def test_decimal_128_from_pandas(self):
             ]
         })
         converted = pa.Table.from_pandas(expected, preserve_index=False)
-        field = pa.field('decimals', pa.decimal(26, 11))
+        field = pa.field('decimals', pa.decimal128(26, 11))
         schema = pa.schema([field])
         assert converted.schema.equals(schema)
 
diff --git a/python/pyarrow/tests/test_schema.py 
b/python/pyarrow/tests/test_schema.py
index 116f39783..dbca139e2 100644
--- a/python/pyarrow/tests/test_schema.py
+++ b/python/pyarrow/tests/test_schema.py
@@ -333,7 +333,7 @@ def test_type_schema_pickling():
         pa.date64(),
         pa.timestamp('ms'),
         pa.timestamp('ns'),
-        pa.decimal(12, 2),
+        pa.decimal128(12, 2),
         pa.field('a', 'string', metadata={b'foo': b'bar'})
     ]
 
diff --git a/python/pyarrow/tests/test_types.py 
b/python/pyarrow/tests/test_types.py
index 9eefa33b6..e352e35a3 100644
--- a/python/pyarrow/tests/test_types.py
+++ b/python/pyarrow/tests/test_types.py
@@ -56,7 +56,7 @@ def test_is_null():
 
 
 def test_is_decimal():
-    assert types.is_decimal(pa.decimal(19, 4))
+    assert types.is_decimal(pa.decimal128(19, 4))
     assert not types.is_decimal(pa.int32())
 
 
diff --git a/python/pyarrow/types.pxi b/python/pyarrow/types.pxi
index abd678bac..1563b5785 100644
--- a/python/pyarrow/types.pxi
+++ b/python/pyarrow/types.pxi
@@ -290,28 +290,28 @@ cdef class FixedSizeBinaryType(DataType):
             return self.fixed_size_binary_type.byte_width()
 
 
-cdef class DecimalType(FixedSizeBinaryType):
+cdef class Decimal128Type(FixedSizeBinaryType):
 
     cdef void init(self, const shared_ptr[CDataType]& type):
         DataType.init(self, type)
-        self.decimal_type = <const CDecimalType*> type.get()
+        self.decimal128_type = <const CDecimal128Type*> type.get()
 
     def __getstate__(self):
         return (self.precision, self.scale)
 
     def __setstate__(self, state):
-        cdef DataType reconstituted = decimal(*state)
+        cdef DataType reconstituted = decimal128(*state)
         self.init(reconstituted.sp_type)
 
     property precision:
 
         def __get__(self):
-            return self.decimal_type.precision()
+            return self.decimal128_type.precision()
 
     property scale:
 
         def __get__(self):
-            return self.decimal_type.scale()
+            return self.decimal128_type.scale()
 
 
 cdef class Field:
@@ -953,9 +953,9 @@ def float64():
     return primitive_type(_Type_DOUBLE)
 
 
-cpdef DataType decimal(int precision, int scale=0):
+cpdef DataType decimal128(int precision, int scale=0):
     """
-    Create decimal type with precision and scale
+    Create decimal type with precision and scale and 128bit width
 
     Parameters
     ----------
@@ -964,10 +964,10 @@ cpdef DataType decimal(int precision, int scale=0):
 
     Returns
     -------
-    decimal_type : DecimalType
+    decimal_type : Decimal128Type
     """
     cdef shared_ptr[CDataType] decimal_type
-    decimal_type.reset(new CDecimalType(precision, scale))
+    decimal_type.reset(new CDecimal128Type(precision, scale))
     return pyarrow_wrap_data_type(decimal_type)
 
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> [Python] Expose Decimal128Type
> ------------------------------
>
>                 Key: ARROW-1845
>                 URL: https://issues.apache.org/jira/browse/ARROW-1845
>             Project: Apache Arrow
>          Issue Type: Bug
>          Components: Python
>            Reporter: Uwe L. Korn
>            Assignee: Uwe L. Korn
>              Labels: pull-request-available
>             Fix For: 0.8.0
>
>
> In the course of the renaming, we forgot to update the Python code to the new 
> {{Decimal128Type}}, thus master is currently failing.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to