Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions crates/frontend-promql/tests/histogram_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ fn quantile_kind(qe: &QueryExpr) -> &'static str {
_ => None,
})
.or_else(|| walk(child)),
QueryExpr::Window { child, .. }
| QueryExpr::TimeRange { child, .. }
QueryExpr::TimeRange { child, .. }
| QueryExpr::Filter { child, .. }
| QueryExpr::Sort { child, .. }
| QueryExpr::Limit { child, .. }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ fn intents(e: &QueryExpr) -> Vec<AggIntent> {
out.extend(aggs.iter().cloned());
go(child, out);
}
QueryExpr::Window { child, .. }
| QueryExpr::TimeRange { child, .. }
QueryExpr::TimeRange { child, .. }
| QueryExpr::TimeShift { child, .. }
| QueryExpr::Filter { child, .. }
| QueryExpr::Sort { child, .. }
Expand Down
13 changes: 5 additions & 8 deletions crates/frontend-promql/tests/promql_conformance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ fn collect(e: &QueryExpr, out: &mut Vec<AggIntent>) {
out.extend(aggs.iter().cloned());
collect(child, out);
}
QueryExpr::Window { child, .. }
| QueryExpr::TimeRange { child, .. }
QueryExpr::TimeRange { child, .. }
| QueryExpr::TimeShift { child, .. }
| QueryExpr::Filter { child, .. }
| QueryExpr::Sort { child, .. }
Expand Down Expand Up @@ -112,8 +111,7 @@ fn first_scan(e: &QueryExpr) -> (String, usize) {
};
(name, predicates.len())
}
QueryExpr::Window { child, .. }
| QueryExpr::TimeRange { child, .. }
QueryExpr::TimeRange { child, .. }
| QueryExpr::TimeShift { child, .. }
| QueryExpr::Aggregate { child, .. }
| QueryExpr::Filter { child, .. }
Expand Down Expand Up @@ -211,8 +209,8 @@ fn name_regex_matcher_is_rejected__GAP() {

#[test]
fn range_vector_selector_is_time_range() {
// SEMANTICS: `[5m]` turns an instant vector into a range vector.
// In L3 this is a dedicated `TimeRange` node (not a streaming `Window`).
// SEMANTICS: `[5m]` turns an instant vector into a range vector,
// represented in L3 as a dedicated `TimeRange` node.
let qe = ok("node_cpu_seconds_total[5m]");
let QueryExpr::TimeRange { range, .. } = &qe else {
panic!("expected TimeRange for a range-vector selector, got {qe:?}");
Expand Down Expand Up @@ -2010,8 +2008,7 @@ fn first_relabel(e: &QueryExpr) -> &QueryExpr {
QueryExpr::Aggregate { child, .. }
| QueryExpr::Filter { child, .. }
| QueryExpr::TimeRange { child, .. }
| QueryExpr::TimeShift { child, .. }
| QueryExpr::Window { child, .. } => first_relabel(child),
| QueryExpr::TimeShift { child, .. } => first_relabel(child),
other => panic!("no Relabel reachable from {other:?}"),
}
}
Expand Down
7 changes: 2 additions & 5 deletions crates/frontend-promql/tests/promql_lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,7 @@ fn collect_intents(e: &QueryExpr, out: &mut Vec<AggIntent>) {
out.extend(aggs.iter().cloned());
collect_intents(child, out);
}
QueryExpr::Window { child, .. }
| QueryExpr::TimeRange { child, .. }
QueryExpr::TimeRange { child, .. }
| QueryExpr::Filter { child, .. }
| QueryExpr::Sort { child, .. }
| QueryExpr::Limit { child, .. } => collect_intents(child, out),
Expand All @@ -539,7 +538,6 @@ fn scan_columns(e: &QueryExpr) -> Vec<String> {
match e {
QueryExpr::Scan { schema, .. } => schema.columns.iter().map(|c| c.name.clone()).collect(),
QueryExpr::Aggregate { child, .. }
| QueryExpr::Window { child, .. }
| QueryExpr::TimeRange { child, .. }
| QueryExpr::Filter { child, .. }
| QueryExpr::Sort { child, .. }
Expand Down Expand Up @@ -666,8 +664,7 @@ fn scan_schema_carries_ts_value_and_group_keys() {
fn find_scan(n: &QueryExpr) -> &QueryExpr {
match n {
QueryExpr::Scan { .. } => n,
QueryExpr::Window { child, .. }
| QueryExpr::TimeRange { child, .. }
QueryExpr::TimeRange { child, .. }
| QueryExpr::Aggregate { child, .. }
| QueryExpr::Filter { child, .. } => find_scan(child),
other => panic!("unexpected node {other:?}"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ fn intents(e: &QueryExpr) -> Vec<AggIntent> {
out.extend(aggs.iter().cloned());
go(child, out);
}
QueryExpr::Window { child, .. }
| QueryExpr::TimeRange { child, .. }
QueryExpr::TimeRange { child, .. }
| QueryExpr::TimeShift { child, .. }
| QueryExpr::Filter { child, .. }
| QueryExpr::Sort { child, .. }
Expand Down
2 changes: 0 additions & 2 deletions crates/frontend-sql/tests/netflow/netflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ fn first_aggregate(qe: &QueryExpr) -> Option<(&GroupKeys, &Vec<AggIntent>)> {
} => Some((reduction.expect_reduce(), aggs)),
QueryExpr::Project { child, .. }
| QueryExpr::Filter { child, .. }
| QueryExpr::Window { child, .. }
| QueryExpr::Distinct { child, .. }
| QueryExpr::Sort { child, .. }
| QueryExpr::Limit { child, .. }
Expand Down Expand Up @@ -263,7 +262,6 @@ fn visit(qe: &QueryExpr, f: &mut impl FnMut(&QueryExpr)) {
QueryExpr::Project { child, .. }
| QueryExpr::Filter { child, .. }
| QueryExpr::Aggregate { child, .. }
| QueryExpr::Window { child, .. }
| QueryExpr::TimeRange { child, .. }
| QueryExpr::Sort { child, .. }
| QueryExpr::Limit { child, .. }
Expand Down
5 changes: 0 additions & 5 deletions crates/frontend-sql/tests/sql_lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ fn find_aggregate(qe: &QueryExpr) -> Option<(&GroupKeys, &Vec<AggIntent>)> {
} => Some((reduction.expect_reduce(), aggs)),
QueryExpr::Project { child, .. }
| QueryExpr::Filter { child, .. }
| QueryExpr::Window { child, .. }
| QueryExpr::Distinct { child, .. }
| QueryExpr::Sort { child, .. }
| QueryExpr::Limit { child, .. }
Expand Down Expand Up @@ -101,7 +100,6 @@ fn find_join(qe: &QueryExpr) -> Option<&QueryExpr> {
QueryExpr::Project { child, .. }
| QueryExpr::Filter { child, .. }
| QueryExpr::Aggregate { child, .. }
| QueryExpr::Window { child, .. }
| QueryExpr::Distinct { child, .. }
| QueryExpr::Sort { child, .. }
| QueryExpr::Limit { child, .. }
Expand All @@ -116,7 +114,6 @@ fn find_filter(qe: &QueryExpr) -> Option<&QueryExpr> {
QueryExpr::Filter { .. } => Some(qe),
QueryExpr::Project { child, .. }
| QueryExpr::Aggregate { child, .. }
| QueryExpr::Window { child, .. }
| QueryExpr::Distinct { child, .. }
| QueryExpr::Sort { child, .. }
| QueryExpr::Limit { child, .. }
Expand Down Expand Up @@ -656,7 +653,6 @@ fn find_windowfunc(qe: &QueryExpr) -> Option<&QueryExpr> {
QueryExpr::Project { child, .. }
| QueryExpr::Filter { child, .. }
| QueryExpr::Aggregate { child, .. }
| QueryExpr::Window { child, .. }
| QueryExpr::Distinct { child, .. }
| QueryExpr::Sort { child, .. }
| QueryExpr::Limit { child, .. }
Expand Down Expand Up @@ -727,7 +723,6 @@ fn all_intents(qe: &QueryExpr) -> Vec<AggIntent> {
}
QueryExpr::Project { child, .. }
| QueryExpr::Filter { child, .. }
| QueryExpr::Window { child, .. }
| QueryExpr::Distinct { child, .. }
| QueryExpr::Sort { child, .. }
| QueryExpr::Limit { child, .. }
Expand Down
16 changes: 0 additions & 16 deletions crates/ir/src/dag_export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,22 +237,6 @@ fn build(expr: &QueryExpr, nodes: &mut Vec<DagNode>) -> u32 {
vec![c],
)
}
QueryExpr::Window {
kind,
size,
slide,
child,
} => {
let c = build(child, nodes);
let detail = serde_json::json!({ "kind": kind, "size": size, "slide": slide });
push_node(
nodes,
"Window",
format!("Window({kind:?})"),
detail,
vec![c],
)
}
QueryExpr::Distinct { cols, child } => {
let c = build(child, nodes);
let detail = serde_json::json!({ "cols": cols });
Expand Down
2 changes: 1 addition & 1 deletion crates/ir/src/intent_algebra/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ pub use query_expr::{
aggregate_output_schema, AtModifier, BinaryOpKind, DataModel, GroupKeys, GroupSide,
InfoMatcher, JoinKind, Predicate, ProjectItem, QueryExpr, QueryExprError, Reduction,
SampleKind, SetOpKind, SortKey, Source, TimeShift, VectorGrouping, VectorMatch,
VectorMatchKind, WindowFuncKind, WindowKind,
VectorMatchKind, WindowFuncKind,
};
pub use schema::{Column, ColumnId, DataType, Schema};
60 changes: 1 addition & 59 deletions crates/ir/src/intent_algebra/query_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,47 +151,6 @@ impl<'de> Deserialize<'de> for GroupKeys {
}
}

/// Lifecycle / flush semantics of a streaming time window.
///
/// `Copy`/`Default`/`Hash`/`Display`/`FromStr` and `#[serde(rename_all =
/// "snake_case")]` (matching this file's `WindowFuncKind` neighbor) were
/// added so a downstream backend's own `WindowType`-shaped serving-time
/// enum (data-plane accumulator config: `Tumbling` default,
/// `"window_type": "tumbling"` wire format, string round-trip via
/// `Display`/`FromStr`) could be retired in favor of this type directly,
/// rather than keeping two independently-maintained enums in sync by hand.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)]
#[serde(rename_all = "snake_case")]
pub enum WindowKind {
#[default]
Tumbling,
Sliding,
Session,
}

impl std::fmt::Display for WindowKind {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
WindowKind::Tumbling => write!(f, "tumbling"),
WindowKind::Sliding => write!(f, "sliding"),
WindowKind::Session => write!(f, "session"),
}
}
}

impl std::str::FromStr for WindowKind {
type Err = String;

fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.to_lowercase().as_str() {
"tumbling" => Ok(WindowKind::Tumbling),
"sliding" => Ok(WindowKind::Sliding),
"session" => Ok(WindowKind::Session),
_ => Err(format!("Unknown window kind: '{s}'")),
}
}
}

/// Which data model a `Source` / `AggIntent` operates over.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum DataModel {
Expand Down Expand Up @@ -582,16 +541,6 @@ pub enum QueryExpr {
child: Box<QueryExpr>,
},

/// ψ — tumbling / sliding / session window over the time axis. Window
/// over Aggregate is the canonical windowed-aggregate shape.
Window {
kind: WindowKind,
size: Duration,
#[serde(default)]
slide: Option<Duration>,
child: Box<QueryExpr>,
},

/// δ — SQL `DISTINCT` / row deduplication. Positional like every other L3
/// column reference; empty = dedup on all columns (`SELECT DISTINCT *`).
Distinct {
Expand Down Expand Up @@ -665,8 +614,7 @@ pub enum QueryExpr {

/// Temporal range selection — "look back `range` of history for this
/// computation." Used for all range-vector functions: `rate`, `increase`,
/// `*_over_time`. The range is distinct from both a streaming `Window`
/// (which is for query-repetition) and a row-level `Filter`.
/// `*_over_time`. The range is distinct from a row-level `Filter`.
///
/// Structural marker: an `Aggregate` whose direct child is a `TimeRange`
/// is a *per-series* reduction (label-preserving); one whose child is a
Expand Down Expand Up @@ -721,12 +669,6 @@ impl QueryExpr {
match self {
QueryExpr::Scan { schema, .. } => Ok(schema.clone()),

// ψ — streaming window (tumbling / sliding / session) for query
// repetition. Does not change the column schema; passes through.
// Per-series range reductions (`rate`, `*_over_time`) now use the
// `TimeRange` node instead, so this arm is a simple pass-through.
QueryExpr::Window { child, .. } => child.output_schema(),

QueryExpr::Aggregate {
reduction,
aggs,
Expand Down
1 change: 0 additions & 1 deletion crates/l2/src/canonicalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ fn children_mut(expr: &mut QueryExpr) -> Vec<&mut QueryExpr> {
| Filter { child, .. }
| Project { child, .. }
| Aggregate { child, .. }
| Window { child, .. }
| Distinct { child, .. }
| Subquery { child, .. }
| TimeRange { child, .. }
Expand Down
5 changes: 0 additions & 5 deletions crates/lower/src/bin/variant_coverage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const ALL_VARIANTS: &[&str] = &[
"Filter",
"Project",
"Aggregate",
"Window",
"Distinct",
"Merge",
"Join",
Expand Down Expand Up @@ -81,10 +80,6 @@ fn walk(e: &QueryExpr, seen: &mut BTreeSet<&'static str>) {
seen.insert("Aggregate");
walk(child, seen);
}
QueryExpr::Window { child, .. } => {
seen.insert("Window");
walk(child, seen);
}
QueryExpr::Distinct { child, .. } => {
seen.insert("Distinct");
walk(child, seen);
Expand Down
Loading