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 2020/09/14 06:20:18 UTC

[GitHub] [arrow] emkornfield commented on a change in pull request #8178: ARROW-9969: [C++] RecordBatch schema has correct types

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



##########
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:
       small nit: please don't use auto (spell out the type).




----------------------------------------------------------------
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:
users@infra.apache.org