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

Method TEST

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

Source from the content-addressed store, hash-verified

767}
768
769TEST(TestDictPartitionColumn, SelectPartitionColumnFilterPhysicalColumn) {
770 auto partition_field = field("part", dictionary(int32(), utf8()));
771 auto path = "/dataset/part=one/data.json";
772 auto dictionary = ArrayFromJSON(utf8(), R"(["one"])");
773
774 auto mock_fs = std::make_shared<fs::internal::MockFileSystem>(fs::kNoTime);
775 ARROW_EXPECT_OK(mock_fs->CreateFile(path, R"([ {"phy_1": 111, "phy_2": 211} ])",
776 /*recursive=*/true));
777
778 auto physical_schema = SchemaFromNames({"phy_1", "phy_2"});
779 auto format = std::make_shared<JSONRecordBatchFileFormat>(
780 [=](const FileSource&) { return physical_schema; });
781
782 FileSystemFactoryOptions options;
783 options.partition_base_dir = "/dataset";
784 options.partitioning = std::make_shared<HivePartitioning>(schema({partition_field}),
785 ArrayVector{dictionary});
786
787 ASSERT_OK_AND_ASSIGN(auto factory,
788 FileSystemDatasetFactory::Make(mock_fs, {path}, format, options));
789
790 ASSERT_OK_AND_ASSIGN(auto schema, factory->Inspect());
791
792 ASSERT_OK_AND_ASSIGN(auto dataset, factory->Finish(schema));
793
794 // Selects re-ordered virtual column with a filter on a physical column
795 ASSERT_OK_AND_ASSIGN(auto scan_builder, dataset->NewScan());
796 ASSERT_OK(scan_builder->Filter(equal(field_ref("phy_1"), literal(111))));
797 ASSERT_OK(scan_builder->Project({"part"}));
798
799 ASSERT_OK_AND_ASSIGN(auto scanner, scan_builder->Finish());
800 ASSERT_OK_AND_ASSIGN(auto table, scanner->ToTable());
801 AssertArraysEqual(*table->column(0)->chunk(0),
802 *ArrayFromJSON(partition_field->type(), R"(["one"])"));
803}
804
805} // namespace dataset
806} // namespace arrow

Callers

nothing calls this directly

Calls 14

ArrayFromJSONFunction · 0.85
SchemaFromNamesFunction · 0.85
equalFunction · 0.85
field_refFunction · 0.85
AssertArraysEqualFunction · 0.85
fieldFunction · 0.50
dictionaryFunction · 0.50
schemaFunction · 0.50
literalFunction · 0.50
CreateFileMethod · 0.45
FilterMethod · 0.45
ProjectMethod · 0.45

Tested by

no test coverage detected