| 107 | |
| 108 | template <typename ArrowDecimal> |
| 109 | Status DecimalFromStdString(const std::string& decimal_string, |
| 110 | const DecimalType& arrow_type, ArrowDecimal* out) { |
| 111 | int32_t inferred_precision; |
| 112 | int32_t inferred_scale; |
| 113 | |
| 114 | RETURN_NOT_OK(ArrowDecimal::FromString(decimal_string, out, &inferred_precision, |
| 115 | &inferred_scale)); |
| 116 | |
| 117 | const int32_t precision = arrow_type.precision(); |
| 118 | const int32_t scale = arrow_type.scale(); |
| 119 | |
| 120 | if (scale != inferred_scale) { |
| 121 | ARROW_DCHECK_NE(out, NULLPTR); |
| 122 | ARROW_ASSIGN_OR_RAISE(*out, out->Rescale(inferred_scale, scale)); |
| 123 | } |
| 124 | |
| 125 | auto inferred_scale_delta = inferred_scale - scale; |
| 126 | if (ARROW_PREDICT_FALSE((inferred_precision - inferred_scale_delta) > precision)) { |
| 127 | return Status::Invalid( |
| 128 | "Decimal type with precision ", inferred_precision, |
| 129 | " does not fit into precision inferred from first array element: ", precision); |
| 130 | } |
| 131 | |
| 132 | return Status::OK(); |
| 133 | } |
| 134 | |
| 135 | template <typename ArrowDecimal> |
| 136 | Status InternalDecimalFromPythonDecimal(PyObject* python_decimal, |
no test coverage detected