| 136 | } |
| 137 | |
| 138 | Result<std::shared_ptr<Table>> SetColumn( |
| 139 | int i, std::shared_ptr<Field> field_arg, |
| 140 | std::shared_ptr<ChunkedArray> col) const override { |
| 141 | DCHECK(col != nullptr); |
| 142 | |
| 143 | if (col->length() != num_rows_) { |
| 144 | return Status::Invalid( |
| 145 | "Added column's length must match table's length. Expected length ", num_rows_, |
| 146 | " but got length ", col->length()); |
| 147 | } |
| 148 | |
| 149 | if (!field_arg->type()->Equals(col->type())) { |
| 150 | return Status::Invalid("Field type did not match data type"); |
| 151 | } |
| 152 | |
| 153 | ARROW_ASSIGN_OR_RAISE(auto new_schema, schema_->SetField(i, field_arg)); |
| 154 | return Table::Make(std::move(new_schema), |
| 155 | internal::ReplaceVectorElement(columns_, i, std::move(col))); |
| 156 | } |
| 157 | |
| 158 | std::shared_ptr<Table> ReplaceSchemaMetadata( |
| 159 | const std::shared_ptr<const KeyValueMetadata>& metadata) const override { |