| 2775 | } |
| 2776 | |
| 2777 | Status CompareFuzzBatches(const RecordBatchWithMetadata& left, |
| 2778 | const RecordBatchWithMetadata& right) { |
| 2779 | if ((left.custom_metadata != nullptr) != (right.custom_metadata != nullptr) || |
| 2780 | (left.custom_metadata && !left.custom_metadata->Equals(*right.custom_metadata))) { |
| 2781 | std::stringstream ss; |
| 2782 | auto print_metadata = [&](const RecordBatchWithMetadata& batch) { |
| 2783 | if (batch.custom_metadata) { |
| 2784 | ss << batch.custom_metadata->ToString(); |
| 2785 | } else { |
| 2786 | ss << "nullptr"; |
| 2787 | } |
| 2788 | }; |
| 2789 | ss << "Custom metadata unequal: left = "; |
| 2790 | print_metadata(left); |
| 2791 | ss << "\nright = "; |
| 2792 | print_metadata(right); |
| 2793 | return Status::Invalid(ss.str()); |
| 2794 | } |
| 2795 | |
| 2796 | bool ok = true; |
| 2797 | if ((left.batch != nullptr) != (right.batch != nullptr)) { |
| 2798 | ok = false; |
| 2799 | } else if (left.batch) { |
| 2800 | ok &= left.batch->Equals(*right.batch, EqualOptions{}.nans_equal(true)); |
| 2801 | } |
| 2802 | if (ok) { |
| 2803 | return Status::OK(); |
| 2804 | } |
| 2805 | std::stringstream ss; |
| 2806 | PrettyPrintOptions options{}; |
| 2807 | options.show_field_metadata = true; |
| 2808 | options.show_schema_metadata = true; |
| 2809 | auto print_batch = [&](const RecordBatchWithMetadata& batch) { |
| 2810 | if (batch.batch) { |
| 2811 | ss << "\n"; |
| 2812 | ARROW_UNUSED(PrettyPrint(*batch.batch, options, &ss)); |
| 2813 | } else { |
| 2814 | ss << "nullptr"; |
| 2815 | } |
| 2816 | }; |
| 2817 | ss << "Batches unequal: left = "; |
| 2818 | print_batch(left); |
| 2819 | ss << "\nright = "; |
| 2820 | print_batch(right); |
| 2821 | return Status::Invalid(ss.str()); |
| 2822 | } |
| 2823 | |
| 2824 | Status CompareFuzzBatches(const std::vector<RecordBatchWithMetadata>& left, |
| 2825 | const std::vector<RecordBatchWithMetadata>& right) { |
no test coverage detected