()
| 674 | use super::*; |
| 675 | #[test] |
| 676 | fn test_make_map_with_null_maps() { |
| 677 | // Test that NULL map values (entire map is NULL) are correctly handled |
| 678 | // This test directly calls make_map_batch with a List containing NULL elements |
| 679 | // |
| 680 | // Background: On main branch, the code would fail with "map key cannot be null" |
| 681 | // because it couldn't distinguish between: |
| 682 | // - NULL map (entire map is NULL) - should be allowed |
| 683 | // - null key within a map - should be rejected |
| 684 | |
| 685 | // Build keys array: [['a'], NULL, ['b']] |
| 686 | // The middle NULL represents an entire NULL map, not a null key |
| 687 | let mut key_builder = |
| 688 | arrow::array::ListBuilder::new(arrow::array::StringBuilder::new()); |
| 689 | |
| 690 | // First map: ['a'] |
| 691 | key_builder.values().append_value("a"); |
| 692 | key_builder.append(true); |
| 693 | |
| 694 | // Second map: NULL (entire map is NULL) |
| 695 | key_builder.append(false); |
| 696 | |
| 697 | // Third map: ['b'] |
| 698 | key_builder.values().append_value("b"); |
| 699 | key_builder.append(true); |
| 700 | |
| 701 | let keys_array = Arc::new(key_builder.finish()); |
| 702 | |
| 703 | // Build values array: [[1], [2], [3]] |
| 704 | let mut value_builder = |
| 705 | arrow::array::ListBuilder::new(arrow::array::Int32Builder::new()); |
| 706 | |
| 707 | value_builder.values().append_value(1); |
| 708 | value_builder.append(true); |
| 709 | |
| 710 | value_builder.values().append_value(2); |
| 711 | value_builder.append(true); |
| 712 | |
| 713 | value_builder.values().append_value(3); |
| 714 | value_builder.append(true); |
| 715 | |
| 716 | let values_array = Arc::new(value_builder.finish()); |
| 717 | |
| 718 | // Call make_map_batch - should succeed |
| 719 | let result = make_map_batch(&[ |
| 720 | ColumnarValue::Array(keys_array), |
| 721 | ColumnarValue::Array(values_array), |
| 722 | ]); |
| 723 | |
| 724 | assert!(result.is_ok(), "Should handle NULL maps correctly"); |
| 725 | |
| 726 | // Verify the result |
| 727 | let map_array = match result.unwrap() { |
| 728 | ColumnarValue::Array(arr) => arr, |
| 729 | _ => panic!("Expected Array result"), |
| 730 | }; |
| 731 | |
| 732 | assert_eq!(map_array.len(), 3, "Should have 3 maps"); |
| 733 | assert!(!map_array.is_null(0), "First map should not be NULL"); |
nothing calls this directly
no test coverage detected
searching dependent graphs…