Repository navigation
Commit 3fa5bc7
test: close five mutation-testing gaps in leaf expression pushdown guards (apache#25452)
## Which issue does this PR close?
- Part of apache#25451.
This PR closes 5 of the 14 real test gaps that the mutation run found.
It does not close the issue.
## Rationale for this change
`extract_leaf_expressions.rs` holds several guards that stop a rewrite
in one specific case. Each guard went in with a bug fix, and each fix
came with a plan snapshot test. A plan snapshot test asserts the shape
of one output plan. It does not assert that the guard makes its decision
for the reason the guard documents.
A `cargo-mutants` run over the file shows the result. Three guards let a
mutation through with no test failure:
| Function | Mutation that survived | Effect if this happened for real |
|---|---|---|
| `passthrough_column` | guard `col.name == alias.name` to `true` | A
renaming alias (`test.a AS b`) counts as a pass-through column. The
recovery projection that restores the name is then dropped, and the
rename is lost. |
| `is_pure_extraction_projection` | body to `true`, and the
`EXTRACTED_EXPR_PREFIX` guard to `true` | A projection that holds a
`__common_expr_1` alias is pushed down a second time. The expression is
re-extracted under a new alias that the parent cannot resolve. |
| `merge_would_duplicate_kept_expr` | `>` to `>=` | The guard fires on a
single reference site. Every merge into a child projection is then
blocked, and leaf extraction stops working over a projection. |
| `merge_would_duplicate_kept_expr` | `&&` to `\|\|` | Plain columns
count as reference sites. A merge that touches only plain columns is
blocked, although a plain column is cheap to duplicate. |
Each of these is a silent behaviour change. The suite stays green.
## What changes are included in this PR?
Three unit tests, one per function, in the existing `tests` module of
`datafusion/optimizer/src/extract_leaf_expressions.rs`. Each test calls
the guard directly and asserts both answers: the case where the guard
must fire, and the case where it must not. The file already uses this
style for `find_owning_input`.
- `test_passthrough_column_rejects_renaming_alias` covers a bare column,
a trivial rename that keeps the name, a rename that changes the name,
and an alias over a non-column expression.
- `test_is_pure_extraction_projection` covers a plan that is not a
projection, a columns-only projection, an extraction projection, a
projection that uses a `CommonSubexprEliminate` alias, and a projection
with a bare expression.
- `test_merge_would_duplicate_kept_expr_counts_only_kept_columns` covers
one reference site to a `KeepInPlace` column, two sites, one site plus a
pass-through reference, and two sites that reference a plain column
only. The pass-through case is the one that
apache#23655 reported.
The PR adds a small `keep_in_place_udf` test helper. It gives a
non-volatile `KeepInPlace` expression, which the existing `volatile_udf`
helper cannot.
There is no change to product code.
## What is the testing strategy for this PR?
This PR is tests only.
`cargo test --profile ci -p datafusion-optimizer` goes from 882 to 885
library tests. The 26 integration tests and 5 documentation tests are
unchanged. All pass.
To show that the new tests close the gaps, re-run `cargo-mutants` on the
three functions:
```bash
cargo mutants -p datafusion-optimizer \
-f 'datafusion/optimizer/src/extract_leaf_expressions.rs' \
-F 'passthrough_column|is_pure_extraction_projection|merge_would_duplicate_kept_expr' \
--profile ci --timeout 600 --jobs 2
```
| | Before | After |
|---|---|---|
| Caught | 16 | 21 |
| Missed | 5 | 0 |
| Unviable | 1 | 1 |
## Are there any user-facing changes?
No.
Note: the test for `merge_would_duplicate_kept_expr` becomes dead when
apache#25456 lands, because that PR
deletes the function. Whichever merges second drops that one test; the
other two tests apply unchanged.
Part of the leaf-pushdown EPIC:
apache#25459
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Fable 5.1 <[email protected]>1 parent 84b84e5 commit 3fa5bc7
1 file changed
Lines changed: 161 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3601 | 3601 | | |
3602 | 3602 | | |
3603 | 3603 | | |
| 3604 | + | |
| 3605 | + | |
| 3606 | + | |
| 3607 | + | |
| 3608 | + | |
| 3609 | + | |
| 3610 | + | |
| 3611 | + | |
| 3612 | + | |
| 3613 | + | |
| 3614 | + | |
| 3615 | + | |
| 3616 | + | |
| 3617 | + | |
| 3618 | + | |
| 3619 | + | |
| 3620 | + | |
| 3621 | + | |
| 3622 | + | |
| 3623 | + | |
| 3624 | + | |
| 3625 | + | |
| 3626 | + | |
| 3627 | + | |
| 3628 | + | |
| 3629 | + | |
| 3630 | + | |
| 3631 | + | |
| 3632 | + | |
| 3633 | + | |
| 3634 | + | |
| 3635 | + | |
| 3636 | + | |
| 3637 | + | |
| 3638 | + | |
| 3639 | + | |
| 3640 | + | |
| 3641 | + | |
| 3642 | + | |
| 3643 | + | |
| 3644 | + | |
| 3645 | + | |
| 3646 | + | |
| 3647 | + | |
| 3648 | + | |
| 3649 | + | |
| 3650 | + | |
| 3651 | + | |
| 3652 | + | |
| 3653 | + | |
| 3654 | + | |
| 3655 | + | |
| 3656 | + | |
| 3657 | + | |
| 3658 | + | |
| 3659 | + | |
| 3660 | + | |
| 3661 | + | |
| 3662 | + | |
| 3663 | + | |
| 3664 | + | |
| 3665 | + | |
| 3666 | + | |
| 3667 | + | |
| 3668 | + | |
| 3669 | + | |
| 3670 | + | |
| 3671 | + | |
| 3672 | + | |
| 3673 | + | |
| 3674 | + | |
| 3675 | + | |
| 3676 | + | |
| 3677 | + | |
| 3678 | + | |
| 3679 | + | |
| 3680 | + | |
| 3681 | + | |
| 3682 | + | |
| 3683 | + | |
| 3684 | + | |
| 3685 | + | |
| 3686 | + | |
| 3687 | + | |
| 3688 | + | |
| 3689 | + | |
| 3690 | + | |
| 3691 | + | |
| 3692 | + | |
| 3693 | + | |
| 3694 | + | |
| 3695 | + | |
| 3696 | + | |
| 3697 | + | |
| 3698 | + | |
| 3699 | + | |
| 3700 | + | |
| 3701 | + | |
| 3702 | + | |
| 3703 | + | |
| 3704 | + | |
| 3705 | + | |
| 3706 | + | |
| 3707 | + | |
| 3708 | + | |
| 3709 | + | |
| 3710 | + | |
| 3711 | + | |
| 3712 | + | |
| 3713 | + | |
| 3714 | + | |
| 3715 | + | |
| 3716 | + | |
| 3717 | + | |
| 3718 | + | |
| 3719 | + | |
| 3720 | + | |
| 3721 | + | |
| 3722 | + | |
| 3723 | + | |
| 3724 | + | |
| 3725 | + | |
| 3726 | + | |
| 3727 | + | |
| 3728 | + | |
| 3729 | + | |
| 3730 | + | |
| 3731 | + | |
| 3732 | + | |
| 3733 | + | |
| 3734 | + | |
| 3735 | + | |
| 3736 | + | |
| 3737 | + | |
| 3738 | + | |
| 3739 | + | |
| 3740 | + | |
| 3741 | + | |
| 3742 | + | |
| 3743 | + | |
| 3744 | + | |
| 3745 | + | |
| 3746 | + | |
| 3747 | + | |
| 3748 | + | |
| 3749 | + | |
| 3750 | + | |
| 3751 | + | |
| 3752 | + | |
| 3753 | + | |
| 3754 | + | |
| 3755 | + | |
| 3756 | + | |
| 3757 | + | |
| 3758 | + | |
| 3759 | + | |
| 3760 | + | |
| 3761 | + | |
| 3762 | + | |
| 3763 | + | |
| 3764 | + | |
3604 | 3765 | | |
0 commit comments