Add a Makefile target for plan viewer
This commit is contained in:
parent
6327920bf7
commit
362d5d1917
12
Makefile
12
Makefile
@ -99,6 +99,18 @@ export-fixtures: ## Regenerate plan JSON for every tools/exporter/examples/*.sce
|
||||
examples: export-fixtures ## Regenerate fixtures from scenarios and run them through plan-runner against their oracles.
|
||||
@cargo test -p plan-runner --test examples
|
||||
|
||||
VIEWER_PORT ?= 8000
|
||||
|
||||
.PHONY: viewer
|
||||
viewer: ## Serve the repository over HTTP for the plan viewer (override the port with VIEWER_PORT=...)
|
||||
@if ! command -v python3 >/dev/null 2>&1; then \
|
||||
echo "python3 not found. Enter the dev shell with 'make shell' (or 'nix develop') first."; \
|
||||
exit 1; \
|
||||
fi
|
||||
@echo "Plan viewer: http://localhost:$(VIEWER_PORT)/tools/plan-viewer/index.html"
|
||||
@echo "Example: http://localhost:$(VIEWER_PORT)/tools/plan-viewer/index.html?fixture=../../crates/plan-runner/fixtures/two_atom_join.json"
|
||||
@python3 -m http.server $(VIEWER_PORT)
|
||||
|
||||
.PHONY: shell
|
||||
shell: ## Enter the Nix dev shell defined in flake.nix
|
||||
@nix develop
|
||||
|
||||
@ -1,37 +1,18 @@
|
||||
# Plan Viewer
|
||||
## Query Plan Viewer
|
||||
|
||||
A static HTML viewer for `plan-runner` fixtures.
|
||||
It renders the plan DAG, the input facts, and the relation computed at every plan node, so a fixture can be inspected without reading raw JSON.
|
||||
A static HTML viewer for `plan-runner` JSON files (the fixtures).
|
||||
|
||||
## Usage
|
||||
### Usage
|
||||
|
||||
Open [`index.html`](index.html) in a browser, then drop a fixture from `crates/plan-runner/fixtures/` onto the page or pick one with the file input.
|
||||
Open [`index.html`](index.html) in a browser, then drop a JSON file from [`crates/plan-runner/fixtures/`](../../crates/plan-runner/fixtures) onto the page.
|
||||
|
||||
When the repository is served over HTTP, a fixture can also be loaded through a query parameter:
|
||||
Alternatively, you can run the commands below to serve the viewer locally:
|
||||
|
||||
```sh
|
||||
python3 -m http.server 8000
|
||||
# then open:
|
||||
# http://localhost:8000/tools/plan-viewer/index.html?fixture=../../crates/plan-runner/fixtures/two_atom_join.json
|
||||
make shell # Go into the Nix shells
|
||||
make viewer
|
||||
```
|
||||
|
||||
## What It Shows
|
||||
Then open the following URL in your browser (replace `two_atom_join.json` with the name of the plan you want to view)
|
||||
|
||||
- **Plan DAG**: one box per plan node, laid out left to right by join depth, with `L` and `R` labels on join inputs and the root node marked.
|
||||
Each box shows the node's output columns and row count.
|
||||
- **Selected Node**: a plain-language description of the operator, its output columns, and the full relation computed at that node.
|
||||
Wildcard columns (names starting with an underscore) are dimmed.
|
||||
- **Result Bindings**: the root relation projected to the fixture's `expected_bindings` columns, with a per-row check against the oracle and a list of any expected rows the plan did not produce.
|
||||
- **Input Facts**: one table per relation in the fixture's schema.
|
||||
|
||||
The header badge reports whether the evaluated bindings match the fixture's `expected_bindings` as a multiset, mirroring `plan_runner::verify`.
|
||||
|
||||
## Scope
|
||||
|
||||
The viewer re-implements the scan, semijoin, and natural join semantics of `crates/query-ops` and the execution order of `crates/plan-runner` in JavaScript, for display only.
|
||||
The Rust crates and their tests remain the correctness oracle; if the two ever disagree, the Rust behavior wins and the viewer has a bug.
|
||||
|
||||
Unsupported cases:
|
||||
|
||||
- plan node actions other than `scan` and `join`
|
||||
- fixtures without a `query` and `schema` block
|
||||
http://localhost:8000/tools/plan-viewer/index.html?fixture=../../crates/plan-runner/fixtures/two_atom_join.json
|
||||
|
||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user