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

Method ValidateMeta

cpp/src/arrow/table.cc:210–243  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 15

strMethod · 0.80
InvalidFunction · 0.70
num_columnsFunction · 0.70
fieldFunction · 0.70
OKFunction · 0.70
sizeMethod · 0.45
num_fieldsMethod · 0.45
getMethod · 0.45
EqualsMethod · 0.45
typeMethod · 0.45
fieldMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected