westonpace commented on a change in pull request #10397: URL: https://github.com/apache/arrow/pull/10397#discussion_r643637975
########## File path: cpp/src/arrow/compute/exec/expression_test.cc ########## @@ -165,6 +165,56 @@ TEST(ExpressionUtils, StripOrderPreservingCasts) { Expect(cast(field_ref("i32"), uint64()), no_change); } +TEST(ExpressionUtils, MakeExecBatch) { + auto Expect = [](std::shared_ptr<RecordBatch> partial_batch) { + SCOPED_TRACE(partial_batch->ToString()); + ASSERT_OK_AND_ASSIGN(auto batch, MakeExecBatch(*kBoringSchema, partial_batch)); + + ASSERT_EQ(batch.num_values(), kBoringSchema->num_fields()); + for (int i = 0; i < kBoringSchema->num_fields(); ++i) { + const auto& field = *kBoringSchema->field(i); + + SCOPED_TRACE("Field#" + std::to_string(i) + " " + field.ToString()); + + EXPECT_TRUE(batch[i].type()->Equals(field.type())) + << "Incorrect type " << batch[i].type()->ToString(); + + ASSERT_OK_AND_ASSIGN(auto col, FieldRef(field.name()).GetOneOrNone(*partial_batch)); Review comment: Ah, I expected `GetColumnByName` to just return the first instance of the field (I thought duplicate field names were generally allowed outside of `compute`) but you are correct, it treats it the same as "not found". -- 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