()
| 636 | |
| 637 | #[test] |
| 638 | fn test_aggregation_edge_cases() { |
| 639 | let fixture = TestFixture::new().expect("Failed to create test fixture"); |
| 640 | // Setup fresh graph for this test to avoid interference |
| 641 | fixture |
| 642 | .setup_graph("test_aggregation_edge_cases") |
| 643 | .expect("Failed to setup graph"); |
| 644 | // Re-insert simple data since we have a fresh graph |
| 645 | fixture |
| 646 | .insert_simple_data() |
| 647 | .expect("Failed to insert simple data"); |
| 648 | |
| 649 | // Test aggregation on empty results |
| 650 | fixture.assert_first_value( |
| 651 | "MATCH (n:NonExistent) RETURN count(n) as count", |
| 652 | "count", |
| 653 | Value::Number(0.0), |
| 654 | ); |
| 655 | |
| 656 | let result = fixture.assert_query_succeeds("MATCH (n:NonExistent) RETURN sum(n.value) as sum"); |
| 657 | assert!(matches!( |
| 658 | result.rows[0].values.get("sum"), |
| 659 | Some(Value::Null) |
| 660 | )); |
| 661 | |
| 662 | // Test aggregation with null values |
| 663 | fixture.assert_query_succeeds( |
| 664 | "INSERT (test:AggTest {value: 10}), (test2:AggTest {value: null}), (test3:AggTest {value: 20})" |
| 665 | ); |
| 666 | |
| 667 | let result = fixture.assert_query_succeeds( |
| 668 | "MATCH (t:AggTest) |
| 669 | RETURN count(t) as total_nodes, |
| 670 | count(t.value) as non_null_values, |
| 671 | sum(t.value) as sum_values, |
| 672 | avg(t.value) as avg_values", |
| 673 | ); |
| 674 | |
| 675 | assert_eq!(result.rows.len(), 1); |
| 676 | // count(t) should be 3, count(t.value) should be 2 (nulls excluded) |
| 677 | |
| 678 | // Test aggregation with very large numbers |
| 679 | fixture.assert_query_succeeds("INSERT (big:BigValue {value: 999999999999999})"); |
| 680 | |
| 681 | fixture.assert_query_succeeds("MATCH (b:BigValue) RETURN sum(b.value) as big_sum"); |
| 682 | |
| 683 | // Test aggregation with very small numbers |
| 684 | fixture.assert_query_succeeds("INSERT (small:SmallValue {value: 0.000001})"); |
| 685 | |
| 686 | fixture.assert_query_succeeds("MATCH (s:SmallValue) RETURN sum(s.value) as small_sum"); |
| 687 | } |
| 688 | |
| 689 | #[test] |
| 690 | fn test_aggregation_column_order() { |
nothing calls this directly
no test coverage detected