Skip to content

Commit 303216a

Browse files
zzylolclaude
andcommitted
refactor(pass2): segment grids derive their coverage; tiling check replaces the declared proof
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW
1 parent e8cf937 commit 303216a

2 files changed

Lines changed: 33 additions & 24 deletions

File tree

‎crates/integration-tests/tests/planner_layering_example3.rs‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,12 @@ fn stage1_a_shared_segments_serve_all_five() {
236236
assert_eq!(estimates.len(), 5, "one estimate per query");
237237
for (estimate, statistic) in estimates {
238238
assert_eq!(statistic, SketchStatistic::Quantile { q: 0.99 });
239-
let merged = c
240-
.dag
241-
.producers(estimate)
242-
.into_iter()
243-
.any(|p| matches!(c.dag.payload(p), Operator::ASAP(ASAPOp::SummaryMerge { .. })));
239+
let merged = c.dag.producers(estimate).into_iter().any(|p| {
240+
matches!(
241+
c.dag.payload(p),
242+
Operator::ASAP(ASAPOp::SummaryMerge { .. })
243+
)
244+
});
244245
assert!(
245246
merged,
246247
"{}: estimate {estimate:?} does not read a merge",

‎crates/logical-optimizer/src/pass2/window_composition.rs‎

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
//! summary per segment of a grid that every window's boundaries lie on, and
2626
//! each query merges the segments its range covers.
2727
28-
use std::collections::{BTreeMap, BTreeSet, HashMap};
28+
use std::collections::{BTreeSet, HashMap};
2929
use std::rc::Rc;
3030
use std::time::Duration;
3131

@@ -546,10 +546,11 @@ mod tests {
546546
use super::*;
547547
use crate::pass1::logical_candidates::enumerate_local_logical_candidates;
548548
use crate::test_support::lower_promql;
549-
use std::ops::Bound;
550549
use asap_types::ir::schema::SketchAlgorithm;
551550
use asap_types::types::AccuracyTarget;
552551
use asap_types::workload::{Predictability, RepetitionInterval};
552+
use std::collections::BTreeMap;
553+
use std::ops::Bound;
553554

554555
fn every(ms: u32) -> RootDemand {
555556
RootDemand {
@@ -675,9 +676,12 @@ mod tests {
675676
let Some(NonASAPOp::Aggregate { child, .. }) = target.target.non_asap() else {
676677
panic!("aggregate")
677678
};
678-
let merged =
679-
tumbling_state(child, WindowForm::Tumbling { pane_ms: 60_000 }, kll_state(target))
680-
.unwrap();
679+
let merged = tumbling_state(
680+
child,
681+
WindowForm::Tumbling { pane_ms: 60_000 },
682+
kll_state(target),
683+
)
684+
.unwrap();
681685
let Operator::ASAP(ASAPOp::SummaryMerge { children }) = &merged.operator else {
682686
panic!("merge")
683687
};
@@ -766,16 +770,18 @@ mod tests {
766770
target: &crate::pass1::logical_candidates::LocalLogicalTarget,
767771
) -> impl Fn(Rc<OperatorNode>) -> Result<Rc<OperatorNode>, LogicalCandidateError> + '_ {
768772
move |input| {
769-
Ok(OperatorNode::new_shared(Operator::ASAP(ASAPOp::SummaryAgg {
770-
child: input,
771-
family: family(&target.alternatives[1], &GroupingStrategy::default()).unwrap(),
772-
input: asap_types::ir::schema::SummaryUpdate::column(
773-
asap_types::ir::scalar::ColumnRef::SampleValue,
774-
),
775-
reduction: asap_types::ir::operator::Reduction::PerEntity,
776-
grouping: GroupingStrategy::default(),
777-
filter: None,
778-
}))?)
773+
Ok(OperatorNode::new_shared(Operator::ASAP(
774+
ASAPOp::SummaryAgg {
775+
child: input,
776+
family: family(&target.alternatives[1], &GroupingStrategy::default()).unwrap(),
777+
input: asap_types::ir::schema::SummaryUpdate::column(
778+
asap_types::ir::scalar::ColumnRef::SampleValue,
779+
),
780+
reduction: asap_types::ir::operator::Reduction::PerEntity,
781+
grouping: GroupingStrategy::default(),
782+
filter: None,
783+
},
784+
))?)
779785
}
780786
}
781787

@@ -829,10 +835,12 @@ mod tests {
829835
merge(vec![pane(0, 60_000), pane(60_000, 60_000)]).unwrap();
830836
assert!(merge(vec![pane(0, 120_000), pane(60_000, 60_000)]).is_err());
831837
// Panes of 2m over a 5m window leave the oldest minute uncovered.
832-
assert!(
833-
tumbling_state(child, WindowForm::Tumbling { pane_ms: 120_000 }, kll_state(target))
834-
.is_err()
835-
);
838+
assert!(tumbling_state(
839+
child,
840+
WindowForm::Tumbling { pane_ms: 120_000 },
841+
kll_state(target)
842+
)
843+
.is_err());
836844
}
837845

838846
const YEAR_MS: u64 = 365 * 86_400_000;

0 commit comments

Comments
 (0)