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

Method AddColumn

cpp/src/arrow/table.cc:119–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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