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

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

xhochy closed pull request #1321: ARROW-1811: [C++/Python] Rename all Decimal 
based APIs to Decimal128
URL: https://github.com/apache/arrow/pull/1321
 
 
   

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/cpp/src/arrow/array.cc b/cpp/src/arrow/array.cc
index 651fa26ba..f2dd75335 100644
--- a/cpp/src/arrow/array.cc
+++ b/cpp/src/arrow/array.cc
@@ -320,7 +320,7 @@ Decimal128Array::Decimal128Array(const 
std::shared_ptr<ArrayData>& data)
 }
 
 std::string Decimal128Array::FormatValue(int64_t i) const {
-  const auto& type_ = static_cast<const DecimalType&>(*type());
+  const auto& type_ = static_cast<const Decimal128Type&>(*type());
   const Decimal128 value(GetValue(i));
   return value.ToString(type_.scale());
 }
diff --git a/cpp/src/arrow/array.h b/cpp/src/arrow/array.h
index 3337e4b15..28756a6ab 100644
--- a/cpp/src/arrow/array.h
+++ b/cpp/src/arrow/array.h
@@ -562,7 +562,7 @@ class ARROW_EXPORT FixedSizeBinaryArray : public 
PrimitiveArray {
 // Decimal128Array
 class ARROW_EXPORT Decimal128Array : public FixedSizeBinaryArray {
  public:
-  using TypeClass = DecimalType;
+  using TypeClass = Decimal128Type;
 
   using FixedSizeBinaryArray::FixedSizeBinaryArray;
 
diff --git a/cpp/src/arrow/builder.cc b/cpp/src/arrow/builder.cc
index c910170dd..d2d3dbdf7 100644
--- a/cpp/src/arrow/builder.cc
+++ b/cpp/src/arrow/builder.cc
@@ -1147,17 +1147,18 @@ template class DictionaryBuilder<BinaryType>;
 template class DictionaryBuilder<StringType>;
 
 // ----------------------------------------------------------------------
-// DecimalBuilder
+// Decimal128Builder
 
-DecimalBuilder::DecimalBuilder(const std::shared_ptr<DataType>& type, 
MemoryPool* pool)
+Decimal128Builder::Decimal128Builder(const std::shared_ptr<DataType>& type,
+                                     MemoryPool* pool)
     : FixedSizeBinaryBuilder(type, pool) {}
 
-Status DecimalBuilder::Append(const Decimal128& value) {
+Status Decimal128Builder::Append(const Decimal128& value) {
   RETURN_NOT_OK(FixedSizeBinaryBuilder::Reserve(1));
   return FixedSizeBinaryBuilder::Append(value.ToBytes());
 }
 
-Status DecimalBuilder::FinishInternal(std::shared_ptr<ArrayData>* out) {
+Status Decimal128Builder::FinishInternal(std::shared_ptr<ArrayData>* out) {
   std::shared_ptr<Buffer> data;
   RETURN_NOT_OK(byte_builder_.Finish(&data));
 
diff --git a/cpp/src/arrow/builder.h b/cpp/src/arrow/builder.h
index c580eeb3b..bc25d0d21 100644
--- a/cpp/src/arrow/builder.h
+++ b/cpp/src/arrow/builder.h
@@ -753,10 +753,10 @@ class ARROW_EXPORT FixedSizeBinaryBuilder : public 
ArrayBuilder {
   BufferBuilder byte_builder_;
 };
 
-class ARROW_EXPORT DecimalBuilder : public FixedSizeBinaryBuilder {
+class ARROW_EXPORT Decimal128Builder : public FixedSizeBinaryBuilder {
  public:
-  explicit DecimalBuilder(const std::shared_ptr<DataType>& type,
-                          MemoryPool* pool ARROW_MEMORY_POOL_DEFAULT);
+  explicit Decimal128Builder(const std::shared_ptr<DataType>& type,
+                             MemoryPool* pool ARROW_MEMORY_POOL_DEFAULT);
 
   using FixedSizeBinaryBuilder::Append;
 
@@ -765,6 +765,8 @@ class ARROW_EXPORT DecimalBuilder : public 
FixedSizeBinaryBuilder {
   Status FinishInternal(std::shared_ptr<ArrayData>* out) override;
 };
 
+using DecimalBuilder = Decimal128Builder;
+
 // ----------------------------------------------------------------------
 // Struct
 
diff --git a/cpp/src/arrow/compare.cc b/cpp/src/arrow/compare.cc
index 253c2e1fe..72ef122e3 100644
--- a/cpp/src/arrow/compare.cc
+++ b/cpp/src/arrow/compare.cc
@@ -615,8 +615,8 @@ class TypeEqualsVisitor {
     return Status::OK();
   }
 
-  Status Visit(const DecimalType& left) {
-    const auto& right = static_cast<const DecimalType&>(right_);
+  Status Visit(const Decimal128Type& left) {
+    const auto& right = static_cast<const Decimal128Type&>(right_);
     result_ = left.precision() == right.precision() && left.scale() == 
right.scale();
     return Status::OK();
   }
diff --git a/cpp/src/arrow/ipc/json-internal.cc 
b/cpp/src/arrow/ipc/json-internal.cc
index 976f9660a..bdf1ef52b 100644
--- a/cpp/src/arrow/ipc/json-internal.cc
+++ b/cpp/src/arrow/ipc/json-internal.cc
@@ -253,7 +253,7 @@ class SchemaWriter {
     writer_->Int(type.byte_width());
   }
 
-  void WriteTypeMetadata(const DecimalType& type) {
+  void WriteTypeMetadata(const Decimal128Type& type) {
     writer_->Key("precision");
     writer_->Int(type.precision());
     writer_->Key("scale");
@@ -347,7 +347,7 @@ class SchemaWriter {
     return WritePrimitive("fixedsizebinary", type);
   }
 
-  Status Visit(const DecimalType& type) { return WritePrimitive("decimal", 
type); }
+  Status Visit(const Decimal128Type& type) { return WritePrimitive("decimal", 
type); }
   Status Visit(const TimestampType& type) { return WritePrimitive("timestamp", 
type); }
   Status Visit(const IntervalType& type) { return WritePrimitive("interval", 
type); }
 
@@ -1063,7 +1063,7 @@ class ArrayReader {
 
   template <typename T>
   typename std::enable_if<std::is_base_of<FixedSizeBinaryType, T>::value &&
-                              !std::is_base_of<DecimalType, T>::value,
+                              !std::is_base_of<Decimal128Type, T>::value,
                           Status>::type
   Visit(const T& type) {
     typename TypeTraits<T>::BuilderType builder(type_, pool_);
@@ -1105,7 +1105,7 @@ class ArrayReader {
   }
 
   template <typename T>
-  typename std::enable_if<std::is_base_of<DecimalType, T>::value, 
Status>::type Visit(
+  typename std::enable_if<std::is_base_of<Decimal128Type, T>::value, 
Status>::type Visit(
       const T& type) {
     typename TypeTraits<T>::BuilderType builder(type_, pool_);
 
diff --git a/cpp/src/arrow/ipc/metadata-internal.cc 
b/cpp/src/arrow/ipc/metadata-internal.cc
index 63ef8a549..87b4708bf 100644
--- a/cpp/src/arrow/ipc/metadata-internal.cc
+++ b/cpp/src/arrow/ipc/metadata-internal.cc
@@ -458,7 +458,7 @@ static Status TypeToFlatbuffer(FBB& fbb, const DataType& 
type,
       *offset = flatbuf::CreateTimestamp(fbb, fb_unit, fb_timezone).Union();
     } break;
     case Type::DECIMAL: {
-      const auto& dec_type = static_cast<const DecimalType&>(*value_type);
+      const auto& dec_type = static_cast<const Decimal128Type&>(*value_type);
       *out_type = flatbuf::Type_Decimal;
       *offset =
           flatbuf::CreateDecimal(fbb, dec_type.precision(), 
dec_type.scale()).Union();
diff --git a/cpp/src/arrow/python/arrow_to_pandas.cc 
b/cpp/src/arrow/python/arrow_to_pandas.cc
index f966b2987..2b0f96439 100644
--- a/cpp/src/arrow/python/arrow_to_pandas.cc
+++ b/cpp/src/arrow/python/arrow_to_pandas.cc
@@ -634,7 +634,7 @@ static Status ConvertDecimals(PandasOptions options, const 
ChunkedArray& data,
 
   for (int c = 0; c < data.num_chunks(); c++) {
     auto* arr(static_cast<arrow::Decimal128Array*>(data.chunk(c).get()));
-    auto type(std::dynamic_pointer_cast<arrow::DecimalType>(arr->type()));
+    auto type(std::dynamic_pointer_cast<arrow::Decimal128Type>(arr->type()));
     const int scale = type->scale();
 
     for (int64_t i = 0; i < arr->length(); ++i) {
@@ -1600,7 +1600,7 @@ class ArrowDeserializer {
     return VisitObjects(ConvertFixedSizeBinary);
   }
 
-  Status Visit(const DecimalType& type) { return 
VisitObjects(ConvertDecimals); }
+  Status Visit(const Decimal128Type& type) { return 
VisitObjects(ConvertDecimals); }
 
   Status Visit(const Time32Type& type) { return 
VisitObjects(ConvertTimes<Time32Type>); }
 
diff --git a/cpp/src/arrow/python/builtin_convert.cc 
b/cpp/src/arrow/python/builtin_convert.cc
index 0e775a0fb..fa0098bdf 100644
--- a/cpp/src/arrow/python/builtin_convert.cc
+++ b/cpp/src/arrow/python/builtin_convert.cc
@@ -700,7 +700,7 @@ class ListConverter : public 
TypedConverterVisitor<ListBuilder, ListConverter> {
 };
 
 class DecimalConverter
-    : public TypedConverterVisitor<arrow::DecimalBuilder, DecimalConverter> {
+    : public TypedConverterVisitor<arrow::Decimal128Builder, DecimalConverter> 
{
  public:
   inline Status AppendItem(const OwnedRef& item) {
     /// TODO(phillipc): Check for nan?
diff --git a/cpp/src/arrow/python/numpy_to_arrow.cc 
b/cpp/src/arrow/python/numpy_to_arrow.cc
index c5aff2e4f..a6c28af9b 100644
--- a/cpp/src/arrow/python/numpy_to_arrow.cc
+++ b/cpp/src/arrow/python/numpy_to_arrow.cc
@@ -305,7 +305,7 @@ class NumPyConverter {
     return TypeNotImplemented(type.ToString());
   }
 
-  Status Visit(const DecimalType& type) { return 
TypeNotImplemented(type.ToString()); }
+  Status Visit(const Decimal128Type& type) { return 
TypeNotImplemented(type.ToString()); }
 
   Status Visit(const DictionaryType& type) { return 
TypeNotImplemented(type.ToString()); }
 
@@ -669,9 +669,9 @@ Status NumPyConverter::ConvertDecimals() {
 
   RETURN_NOT_OK(internal::InferDecimalPrecisionAndScale(object, &precision, 
&scale));
 
-  type_ = std::make_shared<DecimalType>(precision, scale);
+  type_ = std::make_shared<Decimal128Type>(precision, scale);
 
-  DecimalBuilder builder(type_, pool_);
+  Decimal128Builder builder(type_, pool_);
   RETURN_NOT_OK(builder.Resize(length_));
 
   for (int64_t i = 0; i < length_; ++i) {
diff --git a/cpp/src/arrow/type.cc b/cpp/src/arrow/type.cc
index 0d1985fb2..ae1711832 100644
--- a/cpp/src/arrow/type.cc
+++ b/cpp/src/arrow/type.cc
@@ -373,7 +373,7 @@ ACCEPT_VISITOR(FixedSizeBinaryType);
 ACCEPT_VISITOR(StringType);
 ACCEPT_VISITOR(ListType);
 ACCEPT_VISITOR(StructType);
-ACCEPT_VISITOR(DecimalType);
+ACCEPT_VISITOR(Decimal128Type);
 ACCEPT_VISITOR(UnionType);
 ACCEPT_VISITOR(Date32Type);
 ACCEPT_VISITOR(Date64Type);
@@ -471,7 +471,7 @@ std::shared_ptr<Field> field(const std::string& name,
 }
 
 std::shared_ptr<DataType> decimal(int32_t precision, int32_t scale) {
-  return std::make_shared<DecimalType>(precision, scale);
+  return std::make_shared<Decimal128Type>(precision, scale);
 }
 
 static const BufferDescr kValidityBuffer(BufferType::VALIDITY, 1);
@@ -511,7 +511,7 @@ std::vector<BufferDescr> UnionType::GetBufferLayout() const 
{
   }
 }
 
-std::string DecimalType::ToString() const {
+std::string Decimal128Type::ToString() const {
   std::stringstream s;
   s << "decimal(" << precision_ << ", " << scale_ << ")";
   return s.str();
diff --git a/cpp/src/arrow/type.h b/cpp/src/arrow/type.h
index 9e11a0344..d86e7ef57 100644
--- a/cpp/src/arrow/type.h
+++ b/cpp/src/arrow/type.h
@@ -498,11 +498,11 @@ class ARROW_EXPORT StructType : public NestedType {
   std::vector<BufferDescr> GetBufferLayout() const override;
 };
 
-class ARROW_EXPORT DecimalType : public FixedSizeBinaryType {
+class ARROW_EXPORT Decimal128Type : public FixedSizeBinaryType {
  public:
   static constexpr Type::type type_id = Type::DECIMAL;
 
-  explicit DecimalType(int32_t precision, int32_t scale)
+  explicit Decimal128Type(int32_t precision, int32_t scale)
       : FixedSizeBinaryType(16, Type::DECIMAL), precision_(precision), 
scale_(scale) {}
 
   Status Accept(TypeVisitor* visitor) const override;
@@ -517,6 +517,8 @@ class ARROW_EXPORT DecimalType : public FixedSizeBinaryType 
{
   int32_t scale_;
 };
 
+using DecimalType = Decimal128Type;
+
 struct UnionMode {
   enum type { SPARSE, DENSE };
 };
diff --git a/cpp/src/arrow/type_fwd.h b/cpp/src/arrow/type_fwd.h
index 343487055..b8b3c5aa5 100644
--- a/cpp/src/arrow/type_fwd.h
+++ b/cpp/src/arrow/type_fwd.h
@@ -68,9 +68,9 @@ class StructType;
 class StructArray;
 class StructBuilder;
 
-class DecimalType;
+class Decimal128Type;
 class Decimal128Array;
-class DecimalBuilder;
+class Decimal128Builder;
 
 class UnionType;
 class UnionArray;
diff --git a/cpp/src/arrow/type_traits.h b/cpp/src/arrow/type_traits.h
index bc600372e..6707f3759 100644
--- a/cpp/src/arrow/type_traits.h
+++ b/cpp/src/arrow/type_traits.h
@@ -230,9 +230,9 @@ struct TypeTraits<DoubleType> {
 };
 
 template <>
-struct TypeTraits<DecimalType> {
+struct TypeTraits<Decimal128Type> {
   using ArrayType = Decimal128Array;
-  using BuilderType = DecimalBuilder;
+  using BuilderType = Decimal128Builder;
   constexpr static bool is_parameter_free = false;
 };
 
diff --git a/cpp/src/arrow/visitor.h b/cpp/src/arrow/visitor.h
index 34679eb95..030ffc857 100644
--- a/cpp/src/arrow/visitor.h
+++ b/cpp/src/arrow/visitor.h
@@ -83,7 +83,7 @@ class ARROW_EXPORT TypeVisitor {
   virtual Status Visit(const Time64Type& type);
   virtual Status Visit(const TimestampType& type);
   virtual Status Visit(const IntervalType& type);
-  virtual Status Visit(const DecimalType& type);
+  virtual Status Visit(const Decimal128Type& type);
   virtual Status Visit(const ListType& type);
   virtual Status Visit(const StructType& type);
   virtual Status Visit(const UnionType& type);
diff --git a/cpp/src/arrow/visitor_inline.h b/cpp/src/arrow/visitor_inline.h
index 5ecabd2a4..72c82a3bb 100644
--- a/cpp/src/arrow/visitor_inline.h
+++ b/cpp/src/arrow/visitor_inline.h
@@ -55,7 +55,7 @@ inline Status VisitTypeInline(const DataType& type, VISITOR* 
visitor) {
     TYPE_VISIT_INLINE(TimestampType);
     TYPE_VISIT_INLINE(Time32Type);
     TYPE_VISIT_INLINE(Time64Type);
-    TYPE_VISIT_INLINE(DecimalType);
+    TYPE_VISIT_INLINE(Decimal128Type);
     TYPE_VISIT_INLINE(ListType);
     TYPE_VISIT_INLINE(StructType);
     TYPE_VISIT_INLINE(UnionType);


 

----------------------------------------------------------------
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:
us...@infra.apache.org


> [C++/Python] Rename all Decimal based APIs to Decimal128
> --------------------------------------------------------
>
>                 Key: ARROW-1811
>                 URL: https://issues.apache.org/jira/browse/ARROW-1811
>             Project: Apache Arrow
>          Issue Type: Bug
>          Components: C++, Python
>    Affects Versions: 0.7.1
>            Reporter: Phillip Cloud
>            Assignee: Phillip Cloud
>              Labels: pull-request-available
>             Fix For: 0.8.0
>
>




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

Reply via email to