| 209 | |
| 210 | protected: |
| 211 | Status ValidateMeta() const { |
| 212 | // Make sure columns and schema are consistent |
| 213 | if (static_cast<int>(columns_.size()) != schema_->num_fields()) { |
| 214 | return Status::Invalid("Number of columns did not match schema"); |
| 215 | } |
| 216 | for (int i = 0; i < num_columns(); ++i) { |
| 217 | const ChunkedArray* col = columns_[i].get(); |
| 218 | if (col == nullptr) { |
| 219 | return Status::Invalid("Column ", i, " was null"); |
| 220 | } |
| 221 | if (!col->type()->Equals(*schema_->field(i)->type())) { |
| 222 | return Status::Invalid("Column data for field ", i, " with type ", |
| 223 | col->type()->ToString(), " is inconsistent with schema ", |
| 224 | schema_->field(i)->type()->ToString()); |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | // Make sure columns are all the same length, and validate them |
| 229 | for (int i = 0; i < num_columns(); ++i) { |
| 230 | const ChunkedArray* col = columns_[i].get(); |
| 231 | if (col->length() != num_rows_) { |
| 232 | return Status::Invalid("Column ", i, " named ", field(i)->name(), |
| 233 | " expected length ", num_rows_, " but got length ", |
| 234 | col->length()); |
| 235 | } |
| 236 | Status st = col->Validate(); |
| 237 | if (!st.ok()) { |
| 238 | std::stringstream ss; |
| 239 | ss << "Column " << i << ": " << st.message(); |
| 240 | return st.WithMessage(ss.str()); |
| 241 | } |
| 242 | } |
| 243 | return Status::OK(); |
| 244 | } |
| 245 | |
| 246 | private: |
| 247 | std::vector<std::shared_ptr<ChunkedArray>> columns_; |
nothing calls this directly
no test coverage detected