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

Function TEST

cpp/src/arrow/dataset/dataset_test.cc:280–332  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

278}
279
280TEST(TestProjector, CheckProjectable) {
281 struct Assert {
282 explicit Assert(FieldVector from) : from_(from) {}
283 Schema from_;
284
285 void ProjectableTo(FieldVector to) {
286 ARROW_EXPECT_OK(CheckProjectable(from_, Schema(to)));
287 }
288
289 void NotProjectableTo(FieldVector to, std::string substr = "") {
290 EXPECT_RAISES_WITH_MESSAGE_THAT(TypeError, testing::HasSubstr(substr),
291 CheckProjectable(from_, Schema(to)));
292 }
293 };
294
295 auto i8 = field("i8", int8());
296 auto u16 = field("u16", uint16());
297 auto str = field("str", utf8());
298 auto i8_req = field("i8", int8(), false);
299 auto u16_req = field("u16", uint16(), false);
300 auto str_req = field("str", utf8(), false);
301 auto str_nil = field("str", null());
302
303 // trivial
304 Assert({}).ProjectableTo({});
305 Assert({i8}).ProjectableTo({i8});
306 Assert({i8, u16_req}).ProjectableTo({i8, u16_req});
307
308 // reorder
309 Assert({i8, u16}).ProjectableTo({u16, i8});
310 Assert({i8, str, u16}).ProjectableTo({u16, i8, str});
311
312 // drop field(s)
313 Assert({i8}).ProjectableTo({});
314
315 // add field(s)
316 Assert({}).ProjectableTo({i8});
317 Assert({}).ProjectableTo({i8, u16});
318 Assert({}).NotProjectableTo({u16_req},
319 "is not nullable and does not exist in origin schema");
320 Assert({i8}).NotProjectableTo({u16_req, i8});
321
322 // change nullability
323 Assert({i8}).NotProjectableTo({i8_req},
324 "not nullable but is not required in origin schema");
325 Assert({i8_req}).ProjectableTo({i8});
326 Assert({str_nil}).ProjectableTo({str});
327 Assert({str_nil}).NotProjectableTo({str_req});
328
329 // change field type
330 Assert({i8}).NotProjectableTo({field("i8", utf8())},
331 "fields had matching names but differing types");
332}
333
334class TestEndToEnd : public TestUnionDataset {
335 void SetUp() override {

Callers

nothing calls this directly

Calls 4

AssertClass · 0.85
ProjectableToMethod · 0.80
NotProjectableToMethod · 0.80
fieldFunction · 0.50

Tested by

no test coverage detected