bkietz commented on a change in pull request #8894:
URL: https://github.com/apache/arrow/pull/8894#discussion_r545411193



##########
File path: cpp/src/arrow/dataset/partition_test.cc
##########
@@ -99,38 +98,57 @@ class TestPartitioning : public ::testing::Test {
 
   std::shared_ptr<Partitioning> partitioning_;
   std::shared_ptr<PartitioningFactory> factory_;
+  std::shared_ptr<Schema> written_schema_;
 };
 
 TEST_F(TestPartitioning, DirectoryPartitioning) {
   partitioning_ = std::make_shared<DirectoryPartitioning>(
       schema({field("alpha", int32()), field("beta", utf8())}));
 
-  AssertParse("/0/hello", "alpha"_ == int32_t(0) and "beta"_ == "hello");
-  AssertParse("/3", "alpha"_ == int32_t(3));
-  AssertParseError("/world/0");   // reversed order
-  AssertParseError("/0.0/foo");   // invalid alpha
-  AssertParseError("/3.25");      // invalid alpha with missing beta
-  AssertParse("", scalar(true));  // no segments to parse
+  AssertParse("/0/hello", and_(equal(field_ref("alpha"), literal(0)),
+                               equal(field_ref("beta"), literal("hello"))));
+  AssertParse("/3", equal(field_ref("alpha"), literal(3)));
+  AssertParseError("/world/0");    // reversed order
+  AssertParseError("/0.0/foo");    // invalid alpha
+  AssertParseError("/3.25");       // invalid alpha with missing beta
+  AssertParse("", literal(true));  // no segments to parse
 
   // gotcha someday:
-  AssertParse("/0/dat.parquet", "alpha"_ == int32_t(0) and "beta"_ == 
"dat.parquet");
+  AssertParse("/0/dat.parquet", and_(equal(field_ref("alpha"), literal(0)),
+                                     equal(field_ref("beta"), 
literal("dat.parquet"))));
 
-  AssertParse("/0/foo/ignored=2341", "alpha"_ == int32_t(0) and "beta"_ == 
"foo");
+  AssertParse("/0/foo/ignored=2341", and_(equal(field_ref("alpha"), 
literal(0)),
+                                          equal(field_ref("beta"), 
literal("foo"))));
 }
 
 TEST_F(TestPartitioning, DirectoryPartitioningFormat) {
   partitioning_ = std::make_shared<DirectoryPartitioning>(
       schema({field("alpha", int32()), field("beta", utf8())}));
 
-  AssertFormat("alpha"_ == int32_t(0) and "beta"_ == "hello", "0/hello");
-  AssertFormat("beta"_ == "hello" and "alpha"_ == int32_t(0), "0/hello");
-  AssertFormat("alpha"_ == int32_t(0), "0");
-  AssertFormatError("beta"_ == "hello");
-  AssertFormat(scalar(true), "");
+  written_schema_ = partitioning_->schema();
 
-  AssertFormatError<StatusCode::TypeError>("alpha"_ == 0.0 and "beta"_ == 
"hello");
-  AssertFormat("gamma"_ == "yo" and "alpha"_ == int32_t(0) and "beta"_ == 
"hello",
+  AssertFormat(and_(equal(field_ref("alpha"), literal(0)),
+                    equal(field_ref("beta"), literal("hello"))),
+               "0/hello");
+  AssertFormat(and_(equal(field_ref("beta"), literal("hello")),
+                    equal(field_ref("alpha"), literal(0))),
+               "0/hello");
+  AssertFormat(equal(field_ref("alpha"), literal(0)), "0");
+  AssertFormatError(equal(field_ref("beta"), literal("hello")));
+  AssertFormat(literal(true), "");
+
+  ASSERT_OK_AND_ASSIGN(written_schema_,
+                       written_schema_->AddField(0, field("gamma", utf8())));
+  AssertFormat(and_({equal(field_ref("gamma"), literal("yo")),
+                     equal(field_ref("alpha"), literal(0)),
+                     equal(field_ref("beta"), literal("hello"))}),
                "0/hello");
+
+  // written_schema_ is incompatible with partitioning_'s schema

Review comment:
       I'll add a comment. `written_schema_` is the full schema of the written 
dataset (whereas `partitioning_.schema()` contains only the fields on which the 
dataset will be partitioned)




----------------------------------------------------------------
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.

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


Reply via email to