| 515 | } |
| 516 | |
| 517 | void StreamReader::CheckColumn(Type::type physical_type, |
| 518 | ConvertedType::type converted_type, int length) { |
| 519 | if (static_cast<std::size_t>(column_index_) >= nodes_.size()) { |
| 520 | if (eof_) { |
| 521 | ParquetException::EofException(); |
| 522 | } |
| 523 | throw ParquetException("Column index out-of-bounds. Index " + |
| 524 | std::to_string(column_index_) + " is invalid for " + |
| 525 | std::to_string(nodes_.size()) + " columns"); |
| 526 | } |
| 527 | const auto& node = nodes_[column_index_]; |
| 528 | |
| 529 | if (physical_type != node->physical_type()) { |
| 530 | throw ParquetException("Column physical type mismatch. Column '" + node->name() + |
| 531 | "' has physical type '" + TypeToString(node->physical_type()) + |
| 532 | "' not '" + TypeToString(physical_type) + "'"); |
| 533 | } |
| 534 | if (converted_type != node->converted_type()) { |
| 535 | // The converted type does not always match with the value |
| 536 | // provided so check the set of exceptions. |
| 537 | if (converted_type_exceptions.find({converted_type, node->converted_type()}) == |
| 538 | converted_type_exceptions.end()) { |
| 539 | throw ParquetException("Column converted type mismatch. Column '" + node->name() + |
| 540 | "' has converted type '" + |
| 541 | ConvertedTypeToString(node->converted_type()) + "' not '" + |
| 542 | ConvertedTypeToString(converted_type) + "'"); |
| 543 | } |
| 544 | } |
| 545 | // Length must be exact. |
| 546 | if (length != node->type_length()) { |
| 547 | throw ParquetException("Column length mismatch. Column '" + node->name() + |
| 548 | "' has length " + std::to_string(node->type_length()) + |
| 549 | "] not " + std::to_string(length)); |
| 550 | } |
| 551 | } // namespace parquet |
| 552 | |
| 553 | void StreamReader::ThrowReadFailedException( |
| 554 | const std::shared_ptr<schema::PrimitiveNode>& node) { |
nothing calls this directly
no test coverage detected