| 2696 | } |
| 2697 | |
| 2698 | Status CompareFuzzBatches(const RecordBatchWithMetadata& left, |
| 2699 | const RecordBatchWithMetadata& right) { |
| 2700 | if ((left.custom_metadata != nullptr) != (right.custom_metadata != nullptr) || |
| 2701 | (left.custom_metadata && !left.custom_metadata->Equals(*right.custom_metadata))) { |
| 2702 | std::stringstream ss; |
| 2703 | auto print_metadata = [&](const RecordBatchWithMetadata& batch) { |
| 2704 | if (batch.custom_metadata) { |
| 2705 | ss << batch.custom_metadata->ToString(); |
| 2706 | } else { |
| 2707 | ss << "nullptr"; |
| 2708 | } |
| 2709 | }; |
| 2710 | ss << "Custom metadata unequal: left = "; |
| 2711 | print_metadata(left); |
| 2712 | ss << "\nright = "; |
| 2713 | print_metadata(right); |
| 2714 | return Status::Invalid(ss.str()); |
| 2715 | } |
| 2716 | |
| 2717 | bool ok = true; |
| 2718 | if ((left.batch != nullptr) != (right.batch != nullptr)) { |
| 2719 | ok = false; |
| 2720 | } else if (left.batch) { |
| 2721 | ok &= left.batch->Equals(*right.batch, EqualOptions{}.nans_equal(true)); |
| 2722 | } |
| 2723 | if (ok) { |
| 2724 | return Status::OK(); |
| 2725 | } |
| 2726 | std::stringstream ss; |
| 2727 | PrettyPrintOptions options{}; |
| 2728 | options.show_field_metadata = true; |
| 2729 | options.show_schema_metadata = true; |
| 2730 | auto print_batch = [&](const RecordBatchWithMetadata& batch) { |
| 2731 | if (batch.batch) { |
| 2732 | ss << "\n"; |
| 2733 | ARROW_UNUSED(PrettyPrint(*batch.batch, options, &ss)); |
| 2734 | } else { |
| 2735 | ss << "nullptr"; |
| 2736 | } |
| 2737 | }; |
| 2738 | ss << "Batches unequal: left = "; |
| 2739 | print_batch(left); |
| 2740 | ss << "\nright = "; |
| 2741 | print_batch(right); |
| 2742 | return Status::Invalid(ss.str()); |
| 2743 | } |
| 2744 | |
| 2745 | Status CompareFuzzBatches(const std::vector<RecordBatchWithMetadata>& left, |
| 2746 | const std::vector<RecordBatchWithMetadata>& right) { |
no test coverage detected