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

Method SetColumn

cpp/src/arrow/record_batch.cc:143–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

141 }
142
143 Result<std::shared_ptr<RecordBatch>> SetColumn(
144 int i, const std::shared_ptr<Field>& field,
145 const std::shared_ptr<Array>& column) const override {
146 ARROW_CHECK(field != nullptr);
147 ARROW_CHECK(column != nullptr);
148 ARROW_CHECK(column->device_type() == device_type_);
149
150 if (!field->type()->Equals(column->type())) {
151 return Status::TypeError("Column data type ", field->type()->name(),
152 " does not match field data type ",
153 column->type()->name());
154 }
155 if (column->length() != num_rows_) {
156 return Status::Invalid(
157 "Added column's length must match record batch's length. Expected length ",
158 num_rows_, " but got length ", column->length());
159 }
160
161 ARROW_ASSIGN_OR_RAISE(auto new_schema, schema_->SetField(i, field));
162 return RecordBatch::Make(std::move(new_schema), num_rows_,
163 internal::ReplaceVectorElement(columns_, i, column->data()),
164 device_type_, sync_event_);
165 }
166
167 Result<std::shared_ptr<RecordBatch>> RemoveColumn(int i) const override {
168 ARROW_ASSIGN_OR_RAISE(auto new_schema, schema_->RemoveField(i));

Callers

nothing calls this directly

Calls 10

ReplaceVectorElementFunction · 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