@@ -304,6 +304,46 @@ TYPED_TEST(TestDictionaryBuilder, Dictionary32_BasicPrimitive) {
304304 ASSERT_TRUE (expected.Equals (result));
305305}
306306
307+ TYPED_TEST (TestDictionaryBuilder, FinishResetBehavior) {
308+ // ARROW-6861
309+ using c_type = typename TypeParam::c_type;
310+ auto type = std::make_shared<TypeParam>();
311+
312+ Dictionary32Builder<TypeParam> builder;
313+
314+ ASSERT_OK (builder.Append (static_cast <c_type>(1 )));
315+ ASSERT_OK (builder.AppendNull ());
316+ ASSERT_OK (builder.Append (static_cast <c_type>(1 )));
317+ ASSERT_OK (builder.Append (static_cast <c_type>(2 )));
318+
319+ // Properties from indices_builder propagated
320+ ASSERT_LT (0 , builder.capacity ());
321+ ASSERT_LT (0 , builder.null_count ());
322+ ASSERT_EQ (4 , builder.length ());
323+
324+ std::shared_ptr<Array> result;
325+ ASSERT_OK (builder.Finish (&result));
326+
327+ // Everything reset
328+ ASSERT_EQ (0 , builder.capacity ());
329+ ASSERT_EQ (0 , builder.length ());
330+ ASSERT_EQ (0 , builder.null_count ());
331+ }
332+
333+ TEST (TestDictionaryBuilderAdHoc, AppendIndicesUpdateCapacity) {
334+ DictionaryBuilder<Int32Type> builder;
335+ Dictionary32Builder<Int32Type> builder32;
336+
337+ std::vector<int32_t > indices_i32 = {0 , 1 , 2 };
338+ std::vector<int64_t > indices_i64 = {0 , 1 , 2 };
339+
340+ ASSERT_OK (builder.AppendIndices (indices_i64.data (), 3 ));
341+ ASSERT_OK (builder32.AppendIndices (indices_i32.data (), 3 ));
342+
343+ ASSERT_LT (0 , builder.capacity ());
344+ ASSERT_LT (0 , builder32.capacity ());
345+ }
346+
307347TEST (TestStringDictionaryBuilder, Basic) {
308348 // Build the dictionary Array
309349 StringDictionaryBuilder builder;
0 commit comments