MCPcopy Create free account
hub / github.com/apache/arrow / AddColumn

Method AddColumn

cpp/src/arrow/record_batch.cc:120–142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118 const ArrayDataVector& column_data() const override { return columns_; }
119
120 Result<std::shared_ptr<RecordBatch>> AddColumn(
121 int i, const std::shared_ptr<Field>& field,
122 const std::shared_ptr<Array>& column) const override {
123 ARROW_CHECK(field != nullptr);
124 ARROW_CHECK(column != nullptr);
125 ARROW_CHECK(column->device_type() == device_type_);
126
127 if (!field->type()->Equals(column->type())) {
128 return Status::TypeError("Column data type ", field->type()->name(),
129 " does not match field data type ",
130 column->type()->name());
131 }
132 if (column->length() != num_rows_) {
133 return Status::Invalid(
134 "Added column's length must match record batch's length. Expected length ",
135 num_rows_, " but got length ", column->length());
136 }
137
138 ARROW_ASSIGN_OR_RAISE(auto new_schema, schema_->AddField(i, field));
139 return RecordBatch::Make(std::move(new_schema), num_rows_,
140 internal::AddVectorElement(columns_, i, column->data()),
141 device_type_, sync_event_);
142 }
143
144 Result<std::shared_ptr<RecordBatch>> SetColumn(
145 int i, const std::shared_ptr<Field>& field,

Callers

nothing calls this directly

Calls 10

AddVectorElementFunction · 0.85
TypeErrorFunction · 0.70
InvalidFunction · 0.70
MakeFunction · 0.70
device_typeMethod · 0.45
EqualsMethod · 0.45
typeMethod · 0.45
nameMethod · 0.45
lengthMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected