Repository navigation
Commit 8ced299
feat(planner): --planner saved reads RQE trees and writes rqe_configs (#888)
* feat(asap-common): RQE expression tree type and validation
Add `asap_types::rqe_expr`: a serde type for RQE expression trees (rqe
leaves, agg, binary, scalar nodes), a `validate` check run at load, and
`leaves` / `output_labels` helpers.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011gKTCAEz3sJ1Hzde16xxU1
* feat(planner): --planner saved reads RQE trees and writes rqe_configs
An e2e query's optional `expr` (an RQE expression tree, validated at load)
now names the plan RQEs it reads. Each tree leaf becomes one more optimizer
item and Raqe, served by its plan pick like a text leaf, and gets an entry
in a new `rqe_configs` section of the inference config: RQE id -> the
aggregations it reads and, for an exact roll-up, the query-time stage that
regroups to the RQE's grouping. `query_configs` are unchanged; a table
without trees converts as before and writes no `rqe_configs`.
A query may have only a tree: its language is that of the metrics its
leaves read (records -> SQL). The engine's `InferenceConfig` loads
`rqe_configs` (empty when absent); nothing reads it yet.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011gKTCAEz3sJ1Hzde16xxU1
* feat(asap-common): per-bucket top-k (`topk_by`) on RQE leaves
An RQE leaf may name `topk_by` labels: like PromQL `topk by (...)`, a
top-k leaf then ranks its input independently within each value
combination of those labels, while `grouping` stays its output labels.
Absent, the whole input is one bucket. Validation allows `topk_by` only
on `topk_by_value` leaves, non-empty and within `grouping`.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011gKTCAEz3sJ1Hzde16xxU1
* feat(planner): plan a top-k RQE leaf by its `topk_by` buckets
A top-k leaf's optimizer item now carries its `topk_by` labels as
`topk_by_labels`, as a PromQL `topk by (...)` query's does, so its Raqe
is grouped by the buckets (the plan's top-k RQE grouping) and its heap
is one per bucket, keyed by the remaining labels. Without `topk_by` the
Raqe is a single bucket and can't share the deployment of a
`topk by (...)` query.
Tests run the pilot random workload (seed-862/workload-01-pilot) and its
saved plans: `topk by (region, service)` leaves read the same heaps as
their PromQL queries.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011gKTCAEz3sJ1Hzde16xxU1
* fix(asap-common): tighten RQE tree validation
Require every subtree that feeds the result (root, agg operand, one side
of each binary op) to read at least one RQE leaf; allow a repeated leaf id
only for identical leaves; reject duplicate labels in grouping, by and
topk_by; reject an empty id or metric and a zero lookback. Document that
label lists are sets matched by name.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011gKTCAEz3sJ1Hzde16xxU1
* fix(planner): saved-plan RQE checks per review; add --expr-only
- Compare a query's `rqes` with its tree's leaves as sets.
- Allow one RQE leaf at several repeat intervals: each interval is a
Raqe, and the interval-independent rqe_configs entry is written once.
Different leaves under one id are still refused.
- Name a query in errors by its text, else its tree's RQE ids.
- Compute and check a query's RQE ids once.
- Check a tree's leaves read one kind of metric without dedup().
- Describe the e2e-tables fixture instead of citing its PR.
- --expr-only (with --planner saved) plans only the e2e queries that
have an RQE tree; the others (e.g. rate) get no deployment.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011gKTCAEz3sJ1Hzde16xxU1
* style(asap-common): state behaviour in duplicate-label test comment
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011gKTCAEz3sJ1Hzde16xxU1
* fix(planner): require rqes with text; --expr-only plans tree leaves only
- A query with `promql`/`sql` must name its `rqes`: text leaves map to
plan RQEs by `rqes`, never by the tree's leaf order. Only a tree-only
query may omit them.
- `--expr-only` no longer plans query text: it writes only the tree
leaves' deployments and `rqe_configs`, and no `query_configs`.
- `leaf_item` drops the lookback check `RqeExpr::validate` owns, and
shares one metric lookup (`leaf_metric`) with `is_sql`.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011gKTCAEz3sJ1Hzde16xxU1
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>1 parent dd574c7 commit 8ced299
30 files changed
Lines changed: 2325 additions & 173 deletions
File tree
- asap-common/dependencies/rs/asap_types/src
- asap-planner-rs
- src
- optimizer
- tests
- test_data/saved_plan
- asap-query-engine
- src
- engines/simple_engine
- tests
- test_utilities
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
24 | 32 | | |
25 | 33 | | |
26 | 34 | | |
27 | 35 | | |
28 | 36 | | |
| 37 | + | |
| 38 | + | |
29 | 39 | | |
30 | 40 | | |
31 | 41 | | |
| |||
42 | 52 | | |
43 | 53 | | |
44 | 54 | | |
| 55 | + | |
45 | 56 | | |
46 | 57 | | |
47 | 58 | | |
| |||
75 | 86 | | |
76 | 87 | | |
77 | 88 | | |
| 89 | + | |
78 | 90 | | |
79 | 91 | | |
80 | 92 | | |
81 | 93 | | |
82 | 94 | | |
| 95 | + | |
83 | 96 | | |
84 | 97 | | |
85 | 98 | | |
| |||
263 | 276 | | |
264 | 277 | | |
265 | 278 | | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
299 | 282 | | |
300 | | - | |
301 | | - | |
302 | | - | |
| 283 | + | |
303 | 284 | | |
304 | 285 | | |
305 | 286 | | |
| |||
316 | 297 | | |
317 | 298 | | |
318 | 299 | | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
319 | 385 | | |
320 | 386 | | |
321 | 387 | | |
322 | 388 | | |
323 | 389 | | |
| 390 | + | |
324 | 391 | | |
325 | 392 | | |
326 | 393 | | |
| |||
390 | 457 | | |
391 | 458 | | |
392 | 459 | | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
393 | 535 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
59 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
60 | 71 | | |
61 | 72 | | |
62 | 73 | | |
| |||
152 | 163 | | |
153 | 164 | | |
154 | 165 | | |
155 | | - | |
| 166 | + | |
156 | 167 | | |
157 | 168 | | |
158 | 169 | | |
| |||
523 | 534 | | |
524 | 535 | | |
525 | 536 | | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
526 | 600 | | |
0 commit comments