Skip to content

Commit 1d70fb2

Browse files
zzylolclaude
andcommitted
refactor(pass2): shared segments check tiling; their coverage is derived by tumbling_state
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW
1 parent 3d3d67b commit 1d70fb2

3 files changed

Lines changed: 7 additions & 10 deletions

File tree

‎crates/integration-tests/tests/planner_layering_common/mod.rs‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -577,13 +577,10 @@ pub fn query_option(
577577

578578
/// Whether `dag` shares a summary build across queries: Pass 2's
579579
/// shared-segment rule (Q60), whose segments several queries merge.
580-
pub fn shares_segments(dag: &impl ExportedDag, query_roots: &[LogicalASAPNodeId]) -> bool {
581-
cross_query_nodes(dag, query_roots).into_iter().any(|id| {
582-
matches!(
583-
dag.payload(id),
584-
LogicalASAPOperatorPayload::SummaryAgg { .. }
585-
)
586-
})
580+
pub fn shares_segments(dag: &impl ExportedDag, query_roots: &[PhysicalASAPNodeId]) -> bool {
581+
cross_query_nodes(dag, query_roots)
582+
.into_iter()
583+
.any(|id| matches!(dag.payload(id), Operator::ASAP(ASAPOp::SummaryAgg { .. })))
587584
}
588585

589586
/// Nodes reachable from more than one query root.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ fn eh_options(run: &Run) -> BTreeMap<Materialization, (String, PhysicalASAPNodeI
100100

101101
/// The physical candidates of the shared-segment candidate (Q60), keyed by
102102
/// the materialization of its segments, with the newest segment's id.
103-
fn segment_options(run: &Run) -> BTreeMap<Materialization, (String, LogicalASAPNodeId)> {
103+
fn segment_options(run: &Run) -> BTreeMap<Materialization, (String, PhysicalASAPNodeId)> {
104104
let logical = run
105105
.logical
106106
.iter()
@@ -224,7 +224,7 @@ fn stage2_a_segments_are_built_once_for_all_consumers() {
224224
.dag
225225
.nodes
226226
.iter()
227-
.filter(|n| matches!(n.payload, LogicalASAPOperatorPayload::SummaryMerge))
227+
.filter(|n| matches!(n.payload, Operator::ASAP(ASAPOp::SummaryMerge { .. })))
228228
.count();
229229
assert_eq!(merges, 5, "{id}");
230230
if let Some(cost) = run.selection.costs.get(id) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ pub fn share_window_segments<Id: Clone>(
359359
let end = windows.iter().map(|w| bounds(w).1).max().unwrap_or(0);
360360
if width == 0
361361
|| (end - start) / width > MAX_PANES
362-
|| !windows.iter().all(|w| panes_cover_window(w, width))
362+
|| !windows.iter().all(|w| panes_tile_window(w, width))
363363
{
364364
continue;
365365
}

0 commit comments

Comments
 (0)