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

Method AddColumn

cpp/src/arrow/table.cc:118–136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116 }
117
118 Result<std::shared_ptr<Table>> AddColumn(
119 int i, std::shared_ptr<Field> field_arg,
120 std::shared_ptr<ChunkedArray> col) const override {
121 DCHECK(col != nullptr);
122
123 if (col->length() != num_rows_) {
124 return Status::Invalid(
125 "Added column's length must match table's length. Expected length ", num_rows_,
126 " but got length ", col->length());
127 }
128
129 if (!field_arg->type()->Equals(col->type())) {
130 return Status::Invalid("Field type did not match data type");
131 }
132
133 ARROW_ASSIGN_OR_RAISE(auto new_schema, schema_->AddField(i, field_arg));
134 return Table::Make(std::move(new_schema),
135 internal::AddVectorElement(columns_, i, std::move(col)));
136 }
137
138 Result<std::shared_ptr<Table>> SetColumn(
139 int i, std::shared_ptr<Field> field_arg,

Callers

nothing calls this directly

Calls 6

AddVectorElementFunction · 0.85
InvalidFunction · 0.70
MakeFunction · 0.70
lengthMethod · 0.45
EqualsMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected