MCPcopy Create free account
hub / github.com/apache/arrow / DecimalArrayFromJSON

Function DecimalArrayFromJSON

cpp/src/arrow/compute/kernels/test_util_internal.h:77–84  ·  view source on GitHub ↗

Construct an array of decimals, where negative scale is allowed. Works around DecimalXXX::FromString intentionally not inferring negative scales.

Source from the content-addressed store, hash-verified

75// Works around DecimalXXX::FromString intentionally not inferring
76// negative scales.
77inline std::shared_ptr<Array> DecimalArrayFromJSON(const std::shared_ptr<DataType>& type,
78 const std::string& json) {
79 const auto& ty = checked_cast<const DecimalType&>(*type);
80 if (ty.scale() >= 0) return ArrayFromJSON(type, json);
81 auto p = ty.precision() - ty.scale();
82 auto adjusted_ty = ty.id() == Type::DECIMAL128 ? decimal128(p, 0) : decimal256(p, 0);
83 return Cast(ArrayFromJSON(adjusted_ty, json), type).ValueOrDie().make_array();
84}
85
86inline std::shared_ptr<Scalar> DecimalScalarFromJSON(
87 const std::shared_ptr<DataType>& type, const std::string& json) {

Callers 4

TESTFunction · 0.85
TESTFunction · 0.85
TEST_FFunction · 0.85
TEST_FFunction · 0.85

Calls 9

ArrayFromJSONFunction · 0.85
decimal256Function · 0.85
CastFunction · 0.85
make_arrayMethod · 0.80
ValueOrDieMethod · 0.80
decimal128Function · 0.50
scaleMethod · 0.45
precisionMethod · 0.45
idMethod · 0.45

Tested by

no test coverage detected