| 767 | } |
| 768 | |
| 769 | TEST(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 |
nothing calls this directly
no test coverage detected