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

Method SetColumn

cpp/src/arrow/record_batch.cc:144–166  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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