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

Method TestBasicsWithUnions

cpp/src/arrow/array/diff_test.cc:133–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

131 }
132
133 void TestBasicsWithUnions(UnionMode::type mode) {
134 ASSERT_OK_AND_ASSIGN(
135 auto type,
136 UnionType::Make({field("foo", utf8()), field("bar", int32())}, {2, 5}, mode));
137
138 // insert one
139 base_ = ArrayFromJSON(type, R"([[2, "!"], [5, 3], [5, 13]])");
140 target_ = ArrayFromJSON(type, R"([[2, "!"], [2, "?"], [5, 3], [5, 13]])");
141 DoDiff();
142 AssertInsertIs("[false, true]");
143 AssertRunLengthIs("[1, 2]");
144
145 // delete one
146 base_ = ArrayFromJSON(type, R"([[2, "!"], [2, "?"], [5, 3], [5, 13]])");
147 target_ = ArrayFromJSON(type, R"([[2, "!"], [5, 3], [5, 13]])");
148 DoDiff();
149 AssertInsertIs("[false, false]");
150 AssertRunLengthIs("[1, 2]");
151
152 // change one
153 base_ = ArrayFromJSON(type, R"([[5, 3], [2, "!"], [5, 13]])");
154 target_ = ArrayFromJSON(type, R"([[2, "3"], [2, "!"], [5, 13]])");
155 DoDiff();
156 AssertInsertIs("[false, false, true]");
157 AssertRunLengthIs("[0, 0, 2]");
158
159 // null out one
160 base_ = ArrayFromJSON(type, R"([[2, "!"], [5, 3], [5, 13]])");
161 target_ = ArrayFromJSON(type, R"([[2, "!"], [5, 3], null])");
162 DoDiff();
163 AssertInsertIs("[false, false, true]");
164 AssertRunLengthIs("[2, 0, 0]");
165 }
166
167 std::shared_ptr<RunEndEncodedArray> RunEndEncodedArrayFromJSON(
168 int64_t logical_length, const std::shared_ptr<DataType>& ree_type,

Callers

nothing calls this directly

Calls 1

ArrayFromJSONFunction · 0.85

Tested by

no test coverage detected