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

Method AddColumn

cpp/src/arrow/record_batch.cc:119–141  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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