clusterd-test-driver: add explain verb to assert optimized plan shape - #37141
Conversation
3c46acd to
7dc1ed8
Compare
Per review (DAlperin): a script using `optimize` asserts only the result, so optimizer or lowering drift could silently change the plan under test. `explain` renders the lowered LIR plan (the `EXPLAIN PHYSICAL PLAN` form, via a no-catalog `DummyHumanizer` so ids are `u<n>` and columns `#n`) as its golden, submitting nothing. It takes the dataflow either inline (the same body as `create-dataflow`) or by reference: `explain ref=<name>` renders a dataflow a prior `create-dataflow name=<name>` declared, without repeating its body. `join.spec` declares the join, then `explain ref=join` asserts the differential-join plan alongside the count. The multi-object render separates objects with blank lines, so the `.spec` format gains the `datadriven` doubled-`----` block form, emitted automatically by `REWRITE`. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
7dc1ed8 to
3ca052e
Compare
QA LLM Review1. MEDIUM --
|
|
Confirmed, and fixed in #38483 (this PR had already merged). Reproduced the divergence: with Posted by Claude Code on behalf of @antiguru |
`ExplainConfig::default()` derives `redacted` from `mz_ore::assert::soft_assertions_enabled()`, which follows `debug_assertions` unless `MZ_SOFT_ASSERTIONS` overrides it. The `HeadlessDriver` mzcompose service sets no such override and its image is built at mzbuild's release-like profile, so `explain` rendered goldens with literals anonymized to a block character there, while `cargo test` and `run-local.py`'s default `PROFILE=dev` rendered them verbatim. A golden written under one would not match the other, and any plan carrying a literal would assert a redaction instead of the constant. Pinning `redacted: false` makes the render depend only on the plan. No test covers it: every configuration the crate's unit tests run in already has soft assertions on, so an assertion on the rendered text holds with or without the pin, and the only way to make one bite is to flip the process-global `SOFT_ASSERTIONS` atomic from inside the test. Reported by def- on MaterializeInc#37141 and MaterializeInc#38483. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Follow-up to #37141, addressing def-'s review that landed after the merge. `ExplainConfig::default()` derives `redacted` from `mz_ore::assert::soft_assertions_enabled()`, which follows `debug_assertions` unless `MZ_SOFT_ASSERTIONS` overrides it. The `HeadlessDriver` mzcompose service sets no such override and its image is a plain `cargo-build` pre-image at mzbuild's release-like profile, so `explain` rendered goldens with literals anonymized to a block character there, while `cargo test` and `run-local.py`'s default `PROFILE=dev` rendered them verbatim. A golden written under one would not match the other, and any plan carrying a literal would assert a redaction instead of the constant. Nothing differs today because `join.spec`'s plan holds only ids, `Arrange`/`Stream` nodes, and column keys. Pinning `redacted: false` makes the render depend only on the plan and not on how the binary was built. Confirmed by hand: with the pin removed and `MZ_SOFT_ASSERTIONS=0`, a plan carrying a literal renders `map=(█)`. No test covers this. Every configuration the crate's unit tests run in already has soft assertions on, so an assertion on the rendered text holds with or without the pin, and the only way to make one bite is to flip the process-global `SOFT_ASSERTIONS` atomic from inside the test. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Follow-up to #37008 (now merged), addressing DAlperin's review on
join.spec: a script usingoptimizeasserts only the result, so optimizer or lowering drift could silently change the plan under test.explainrenders the lowered LIR plan (theEXPLAIN PHYSICAL PLANform, via a no-catalogDummyHumanizerso ids areu<n>and columns#n) as its golden, submitting nothing. It takes the dataflow either inline (thecreate-dataflowbody) or by reference —explain ref=<name>renders a dataflow a priorcreate-dataflow name=<name>declared, without repeating its body.join.specdeclares the join, thenexplain ref=joinasserts the differential-join plan alongside the count.The multi-object render separates objects with blank lines, so the
.specformat gains thedatadrivendoubled-----block form, emitted automatically byREWRITE.🤖 Generated with Claude Code