You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/11/29 16:53:52 UTC

[GitHub] [arrow] pitrou commented on a diff in pull request #14646: ARROW-18269: [C++] Handle slash character in Hive-style partition values

pitrou commented on code in PR #14646:
URL: https://github.com/apache/arrow/pull/14646#discussion_r1035008910


##########
cpp/src/arrow/dataset/partition_test.cc:
##########
@@ -1048,5 +1051,60 @@ TEST(TestStripPrefixAndFilename, Basic) {
                                           "year=2019/month=12/day=01"));
 }
 
+TEST_F(TestPartitioning, PartitioningWithDataWithFilePaths) {
+  fs::TimePoint mock_now = std::chrono::system_clock::now();
+  ASSERT_OK_AND_ASSIGN(std::shared_ptr<fs::FileSystem> filesystem,
+                       fs::internal::MockFileSystem::Make(mock_now, {}));
+  auto base_path = "";
+  ASSERT_OK(filesystem->CreateDir(base_path));
+  // Create an Arrow Table
+  auto schema = arrow::schema(
+      {arrow::field("a", arrow::int64()), arrow::field("part", arrow::utf8())});
+  std::vector<std::shared_ptr<arrow::Array>> arrays(2);
+  arrow::NumericBuilder<arrow::Int64Type> builder;
+  ASSERT_OK(builder.AppendValues({0, 1, 2, 3, 4}));
+  ASSERT_OK(builder.Finish(&arrays[0]));
+  arrow::StringBuilder string_builder;
+  std::vector<std::string> partitions = {"experiment/A/f.csv", "experiment/B/f.csv",
+                                         "experiment/A/f.csv", "experiment/C/k.csv",
+                                         "experiment/M/i.csv"};
+  ASSERT_OK(string_builder.AppendValues(partitions));
+  ASSERT_OK(string_builder.Finish(&arrays[1]));
+  auto table = arrow::Table::Make(schema, arrays);

Review Comment:
   Can we use `ArrayFromJSON` or even `TableFromJSON` instead of building these step-by-step?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org