()
| 1494 | |
| 1495 | #[test] |
| 1496 | fn test_enumerate_grouping_sets() -> Result<()> { |
| 1497 | let multi_cols = vec![col("col1"), col("col2"), col("col3")]; |
| 1498 | let simple_col = col("simple_col"); |
| 1499 | let cube = cube(multi_cols.clone()); |
| 1500 | let rollup = rollup(multi_cols.clone()); |
| 1501 | let grouping_set = grouping_set(vec![multi_cols]); |
| 1502 | |
| 1503 | // 1. col |
| 1504 | let sets = enumerate_grouping_sets(vec![simple_col.clone()])?; |
| 1505 | let result = format!("[{}]", expr_vec_fmt!(sets)); |
| 1506 | assert_eq!("[simple_col]", &result); |
| 1507 | |
| 1508 | // 2. cube |
| 1509 | let sets = enumerate_grouping_sets(vec![cube.clone()])?; |
| 1510 | let result = format!("[{}]", expr_vec_fmt!(sets)); |
| 1511 | assert_eq!("[CUBE (col1, col2, col3)]", &result); |
| 1512 | |
| 1513 | // 3. rollup |
| 1514 | let sets = enumerate_grouping_sets(vec![rollup.clone()])?; |
| 1515 | let result = format!("[{}]", expr_vec_fmt!(sets)); |
| 1516 | assert_eq!("[ROLLUP (col1, col2, col3)]", &result); |
| 1517 | |
| 1518 | // 4. col + cube |
| 1519 | let sets = enumerate_grouping_sets(vec![simple_col.clone(), cube.clone()])?; |
| 1520 | let result = format!("[{}]", expr_vec_fmt!(sets)); |
| 1521 | assert_eq!( |
| 1522 | "[GROUPING SETS (\ |
| 1523 | (simple_col), \ |
| 1524 | (simple_col, col1), \ |
| 1525 | (simple_col, col2), \ |
| 1526 | (simple_col, col1, col2), \ |
| 1527 | (simple_col, col3), \ |
| 1528 | (simple_col, col1, col3), \ |
| 1529 | (simple_col, col2, col3), \ |
| 1530 | (simple_col, col1, col2, col3))]", |
| 1531 | &result |
| 1532 | ); |
| 1533 | |
| 1534 | // 5. col + rollup |
| 1535 | let sets = enumerate_grouping_sets(vec![simple_col.clone(), rollup.clone()])?; |
| 1536 | let result = format!("[{}]", expr_vec_fmt!(sets)); |
| 1537 | assert_eq!( |
| 1538 | "[GROUPING SETS (\ |
| 1539 | (simple_col), \ |
| 1540 | (simple_col, col1), \ |
| 1541 | (simple_col, col1, col2), \ |
| 1542 | (simple_col, col1, col2, col3))]", |
| 1543 | &result |
| 1544 | ); |
| 1545 | |
| 1546 | // 6. col + grouping_set |
| 1547 | let sets = |
| 1548 | enumerate_grouping_sets(vec![simple_col.clone(), grouping_set.clone()])?; |
| 1549 | let result = format!("[{}]", expr_vec_fmt!(sets)); |
| 1550 | assert_eq!( |
| 1551 | "[GROUPING SETS (\ |
| 1552 | (simple_col, col1, col2, col3))]", |
| 1553 | &result |
nothing calls this directly
no test coverage detected
searching dependent graphs…