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

Function TestInferPrecisionAndScale

python/pyarrow/src/arrow/python/python_test.cc:380–403  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

378}
379
380Status TestInferPrecisionAndScale() {
381 OwnedRef decimal_constructor_;
382 OwnedRef decimal_module;
383
384 RETURN_NOT_OK(internal::ImportModule("decimal", &decimal_module));
385 RETURN_NOT_OK(
386 internal::ImportFromModule(decimal_module.obj(), "Decimal", &decimal_constructor_));
387
388 std::string decimal_string("-394029506937548693.42983");
389 PyObject* python_decimal =
390 internal::DecimalFromString(decimal_constructor_.obj(), decimal_string);
391
392 internal::DecimalMetadata metadata;
393 ASSERT_OK(metadata.Update(python_decimal));
394
395 const auto expected_precision =
396 static_cast<int32_t>(decimal_string.size() - 2); // 1 for -, 1 for .
397 const int32_t expected_scale = 5;
398
399 ASSERT_EQ(expected_precision, metadata.precision());
400 ASSERT_EQ(expected_scale, metadata.scale());
401
402 return Status::OK();
403}
404
405Status TestInferPrecisionAndNegativeScale() {
406 OwnedRef decimal_constructor_;

Callers

nothing calls this directly

Calls 8

ImportModuleFunction · 0.85
ImportFromModuleFunction · 0.85
DecimalFromStringFunction · 0.70
OKFunction · 0.50
UpdateMethod · 0.45
sizeMethod · 0.45
precisionMethod · 0.45
scaleMethod · 0.45

Tested by

no test coverage detected