| 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, |