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

Function TestDecimalDictionaryBuilderBasic

cpp/src/arrow/array/array_dict_test.cc:876–895  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

874
875template <typename DecimalValue>
876void TestDecimalDictionaryBuilderBasic(std::shared_ptr<DataType> decimal_type) {
877 // Build the dictionary Array
878 DictionaryBuilder<FixedSizeBinaryType> builder(decimal_type);
879
880 // Test data
881 std::vector<DecimalValue> test{12, 12, 11, 12};
882 for (const auto& value : test) {
883 ASSERT_OK(builder.Append(value.ToBytes().data()));
884 }
885
886 std::shared_ptr<Array> result;
887 ASSERT_OK(builder.Finish(&result));
888
889 // Build expected data
890 DictionaryArray expected(dictionary(int8(), decimal_type),
891 ArrayFromJSON(int8(), "[0, 0, 1, 0]"),
892 ArrayFromJSON(decimal_type, "[\"12\", \"11\"]"));
893
894 ASSERT_TRUE(expected.Equals(result));
895}
896
897TEST(TestDecimal128DictionaryBuilder, Basic) {
898 TestDecimalDictionaryBuilderBasic<Decimal128>(arrow::decimal128(2, 0));

Callers

nothing calls this directly

Calls 7

ArrayFromJSONFunction · 0.85
ToBytesMethod · 0.80
dictionaryFunction · 0.50
AppendMethod · 0.45
dataMethod · 0.45
FinishMethod · 0.45
EqualsMethod · 0.45

Tested by

no test coverage detected