troels commented on a change in pull request #8178:
URL: https://github.com/apache/arrow/pull/8178#discussion_r487712100



##########
File path: cpp/src/arrow/table_builder.cc
##########
@@ -62,7 +62,21 @@ Status RecordBatchBuilder::Flush(bool reset_builders,
     }
     length = fields[i]->length();
   }
-  *batch = RecordBatch::Make(schema_, length, std::move(fields));
+
+  // For certain types like dictionaries, types may not be fully
+  // determined before we have flushed. Make sure that the RecordBatch
+  // gets the correct types in schema.
+  // See: #ARROW-9969
+  std::shared_ptr<Schema> schema(schema_);
+  std::vector<std::shared_ptr<Field>> schema_fields(schema->fields());
+  for (int i = 0; i < this->num_fields(); ++i) {
+    if (!schema_fields[i]->type()->Equals(fields[i]->type())) {
+      auto new_type(schema_fields[i]->WithType(fields[i]->type()));

Review comment:
       Sure thing.




----------------------------------------------------------------
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:
[email protected]


Reply via email to