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

Function TEST

cpp/src/arrow/dataset/discovery_test.cc:421–451  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

419}
420
421TEST(UnionDatasetFactoryTest, Basic) {
422 auto f64 = field("f64", float64());
423 auto i32 = field("i32", int32());
424 auto i32_req = field("i32", int32(), /*nullable*/ false);
425 auto str = field("str", utf8());
426
427 auto schema_1 = schema({f64, i32_req});
428 auto schema_2 = schema({f64, i32});
429 auto schema_3 = schema({str, i32});
430
431 auto dataset_1 = DatasetFactoryFromSchemas({schema_1, schema_2});
432 auto dataset_2 = DatasetFactoryFromSchemas({schema_2});
433 auto dataset_3 = DatasetFactoryFromSchemas({schema_3});
434
435 ASSERT_OK_AND_ASSIGN(auto factory,
436 UnionDatasetFactory::Make({dataset_1, dataset_2, dataset_3}));
437
438 ASSERT_OK_AND_ASSIGN(auto schemas, factory->InspectSchemas({}));
439 AssertSchemasAre(schemas, {schema_2, schema_2, schema_3});
440
441 auto expected_schema = schema({f64, i32, str});
442 ASSERT_OK_AND_ASSIGN(auto inspected, factory->Inspect());
443 EXPECT_EQ(*inspected, *expected_schema);
444
445 ASSERT_OK_AND_ASSIGN(auto dataset, factory->Finish());
446 EXPECT_EQ(*dataset->schema(), *expected_schema);
447
448 auto f64_schema = schema({f64});
449 ASSERT_OK_AND_ASSIGN(dataset, factory->Finish(f64_schema));
450 EXPECT_EQ(*dataset->schema(), *f64_schema);
451}
452
453TEST(UnionDatasetFactoryTest, ConflictingSchemas) {
454 auto f64 = field("f64", float64());

Callers

nothing calls this directly

Calls 8

AssertSchemasAreFunction · 0.85
ASSERT_OK_AND_ASSIGNFunction · 0.70
fieldFunction · 0.50
schemaFunction · 0.50
schemaMethod · 0.45
FinishMethod · 0.45
InspectMethod · 0.45

Tested by

no test coverage detected