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
4 changes: 2 additions & 2 deletions crates/asap-aware-mapping/src/accuracy/reconciliation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//!
//! ## The gap this closes
//!
//! `asap_types::pre_asap::cse::share_common_sub_dags` (pre-ASAP CSE) only
//! `asap_types::ir::cse::share_common_sub_dags` (pre-ASAP CSE) only
//! ever merges two sub-DAGs that are *exactly* [`PartialEq`]-equal,
//! including their [`AggIntent`]'s `accuracy: AccuracyTarget` field. Two
//! otherwise-identical aggregates that differ *only* in how tight an
Expand Down Expand Up @@ -303,7 +303,7 @@ impl AccuracyReconciliationStrategy {
///
/// Also requires the candidate's own *output* schema to carry a provable
/// unique key ([`Schema::has_unique_key`]) — the exact legality gate
/// `pre_asap::cse::share_common_sub_dags` already applies to its own
/// `ir::cse::share_common_sub_dags` already applies to its own
/// sharing decisions, and [`crate::rollup::RollupStrategy`] already
/// reuses verbatim for the identical reason (see that module's
/// `is_legal_rollup_source` doc, point 4): a producer's output is only
Expand Down
2 changes: 1 addition & 1 deletion crates/asap-aware-mapping/src/explanation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ mod tests {

/// A sketch-applicable `Aggregate` reachable via two paths that CSE
/// collapses onto one `Rc` — the same `median(x) == median(x)` shape
/// `pre_asap::cse`'s own `single_query_shares_its_own_repeated_sub-DAG`
/// `ir::cse`'s own `single_query_shares_its_own_repeated_sub_dag`
/// test uses — must be reported once, not once per path: it is exactly
/// one [`crate::replacement::TargetSubDAGCandidates`], keyed by `Rc` pointer identity,
/// not one per path that reaches it.
Expand Down
10 changes: 5 additions & 5 deletions crates/asap-aware-mapping/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
//! It depends only on the IR crate, never on a front end — the layering
//! invariant (arrows point up) holds here too.
//!
//! Post-lowering **canonicalization** is *not* here: it landed in
//! `asap_types::pre_asap::canonicalize`, run inside the shared `resolve_root`
//! so every front end normalizes before the pre-ASAP IR leaves resolution
//! Post-lowering **canonicalization** is *not* here: it lives in
//! `asap_types::ir::canonicalize`, run inside `asap_frontend_common`'s shared
//! `resolve_root` so every front end normalizes before the IR leaves resolution
//! (issue #34, closed).
//!
//! ## Planning workflows
Expand Down Expand Up @@ -83,7 +83,7 @@
//! re-deriving it from an already-computed, strictly finer sibling
//! `Aggregate` over identical child IR instead of an independent pass
//! over the raw source — the cross-aggregate sibling of
//! `pre_asap::cse::share_common_sub_dags`'s identical-sub-DAG sharing.
//! `ir::cse::share_common_sub_dags`'s identical-sub-DAG sharing.
//! [`rollup::is_legal_rollup_source`] is the standalone legality predicate
//! other axes (e.g. issue #256's `GroupingStrategy`) are expected to
//! consult directly, so it and this module's `RollupStrategy` can never
Expand Down Expand Up @@ -115,7 +115,7 @@
//!
//! | Term | Meaning | Entry point |
//! |---|---|---|
//! | Schema resolution | Derive input schemas and resolve column names to positions | `asap_types::pre_asap::SchemaResolver::resolve_schema`, `resolve_root` |
//! | Schema resolution | Derive input schemas and resolve column names to positions | `asap_frontend_common::schema_resolver::SchemaResolver::resolve_schema`, `asap_frontend_common::resolve::resolve_root` |
//! | Realization | Enumerate ranked physical forms for one aggregate intent | `replacement::realizations_for_intent` |
//! | Replacement | Construct each candidate summary sub-DAG | [`replacement::ASAPStrategies`] |
//! | Search | Enumerate and compare alternatives across a workload | [`replacement::search_workload`] |
Expand Down
4 changes: 2 additions & 2 deletions crates/asap-aware-mapping/src/recurrence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1136,7 +1136,7 @@ mod tests {
/// Like `scan()`, plus a "job" label column to group by — CSE's
/// sharing legality gate requires a provable unique key
/// (`Schema::has_unique_key`), and an *ungrouped* aggregate's empty
/// `by` reports none (see `asap_types::pre_asap::cse`'s own "Legality"
/// `by` reports none (see `asap_types::ir::cse`'s own "Legality"
/// module docs); grouping by a label column gives `sum_agg()` below a
/// real one, matching the pattern
/// `replacement.rs`'s own CSE fixtures already use (`metric_scan`/`agg`
Expand Down Expand Up @@ -1437,7 +1437,7 @@ mod tests {

/// Issue #287 review (lower-priority item): a parent referencing the
/// same shared child twice (`BinaryOp{lhs: X, rhs: X}`, the same shape
/// `pre_asap::cse`'s own within-one-query sharing collapses onto one
/// `ir::cse`'s own within-one-query sharing collapses onto one
/// `Rc`) must credit that child with 2 contributions per repeating
/// root, matching how `TargetSubDAGCandidates::consumer_count` already counts that
/// exact structural occurrence twice — not 1, which a plain
Expand Down
10 changes: 5 additions & 5 deletions crates/asap-aware-mapping/src/replacement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
//! binds (single intent, no `HAVING`), every entry becomes its own bound
//! candidate.
//! - [`SharedSubDAGStrategy`] wraps
//! `asap_types::pre_asap::cse::share_common_sub_dags`'s sharing decision.
//! `asap_types::ir::cse::share_common_sub_dags`'s sharing decision.
//! Wherever a [`TargetSubDAG`] already has two or more consumers (i.e.
//! `share_common_sub_dags` already collapsed two or more workload
//! locations onto the same `Rc<OperatorNode>` — [`discover_targets`] below
Expand Down Expand Up @@ -144,7 +144,7 @@
//! 1. **Per-target candidates, not flat plans.** [`TargetSubDAGCandidates`]
//! stores the alternatives for one distinct [`TargetSubDAG`] (identified by
//! its own `Rc<OperatorNode>` pointer identity — the same currency
//! [`asap_types::pre_asap::cse::share_common_sub_dags`] already
//! [`asap_types::ir::cse::share_common_sub_dags`] already
//! established across the workload) holding every
//! [`ReplacementSubDAG`] alternative discovered for it. [`CandidateLogicalASAPDAGs`] is
//! a collection of these groups, keyed by `TargetSubDAG` — a candidate
Expand All @@ -153,8 +153,8 @@
//! targets are just two different entries in two different groups,
//! sharing every other node in the workload by construction (they *are*
//! the same `Rc`s — nothing was copied to make a second "plan").
//! 2. **Dedup by structural hash + `PartialEq`, reusing `pre_asap::cse`'s own
//! discipline.** [`asap_types::pre_asap::cse::structural_hash`] (made
//! 2. **Dedup by structural hash + `PartialEq`, reusing `ir::cse`'s own
//! discipline.** [`asap_types::ir::cse::structural_hash`] (made
//! `pub` for exactly this reuse) is only ever a candidate-narrowing
//! filter; [`TargetSubDAGCandidates::add_candidate`]'s actual duplicate check is
//! `OperatorNode`'s derived `PartialEq` — the same "hash is a filter,
Expand All @@ -175,7 +175,7 @@
//! line above stands for: every `TargetSubDAG` this pass discovers is one
//! iteration of that loop. It walks every workload root's whole DAG (the
//! same **relational-skeleton** operator-child scope
//! `asap_types::pre_asap::cse::share_common_sub_dags` itself uses — see
//! `asap_types::ir::cse::share_common_sub_dags` itself uses — see
//! that module's "Algorithm" section), discovering one `TargetSubDAG` per
//! distinct `Rc` and a *real* `consumer_count`: how many operator-child
//! positions anywhere in the workload reference that exact `Rc`, not just
Expand Down
4 changes: 2 additions & 2 deletions crates/asap-aware-mapping/src/rollup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
//! "Rolling up aggregations on a fine-grained group by to get a
//! coarse-grained group by (like AHA)," alongside "CSE across aggregations,
//! and group by key management" — this strategy is the *cross-aggregate*
//! sibling of `pre_asap::cse::share_common_sub_dags`'s *identical*-sub-DAG
//! sibling of `ir::cse::share_common_sub_dags`'s *identical*-sub-DAG
//! sharing: CSE shares two structurally-*equal* aggregates onto one `Rc`;
//! this strategy relates two structurally-*different* (differently grouped)
//! aggregates over the same shared source.
Expand Down Expand Up @@ -207,7 +207,7 @@ fn rollup_combinator(intent: &AggIntent, finer_measure_col: ColumnId) -> Option<
/// 4. `finer_output_schema` (the finer aggregate's own *output* schema, not
/// the shared child's) carries a provable unique key
/// ([`Schema::has_unique_key`]) — **the exact legality gate
/// `pre_asap::cse::share_common_sub_dags` already applies to its own
/// `ir::cse::share_common_sub_dags` already applies to its own
/// sharing decisions**, reused verbatim here rather than re-invented:
/// `share_common_sub_dags`'s own doc ("Legality: gated by
/// `Schema::unique_keys`") states a producer's output is only safely
Expand Down
4 changes: 2 additions & 2 deletions crates/asap-physical-operators/tests/blocking_resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use asap_physical_operators::{
};
use futures::{executor::block_on, FutureExt, StreamExt};
use planner_types::ir::Predicate;
use planner_types::ir::ScalarExpr as QueryExpr;
use planner_types::ir::ScalarExpr;
use planner_types::{
post_asap::{Field, FieldDataType},
pre_asap::{DataType, JoinKind, ScalarValue},
Expand Down Expand Up @@ -62,7 +62,7 @@ fn cross_join() -> Operator {
schema(1),
schema(1),
JoinKind::Cross,
&Predicate(QueryExpr::Literal(ScalarValue::Boolean(true))),
&Predicate(ScalarExpr::Literal(ScalarValue::Boolean(true))),
schema(2),
)
.unwrap()
Expand Down
24 changes: 12 additions & 12 deletions crates/asap-physical-operators/tests/physical_dag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use planner_types::ir::physical_export::{
use planner_types::ir::ASAPOp;
use planner_types::ir::BinaryOperator;
use planner_types::ir::NonASAPOp;
use planner_types::ir::ScalarExpr as QueryExpr;
use planner_types::ir::ScalarExpr;
use planner_types::{
post_asap::{ExactKind, ExactParams, Field, FieldDataType},
pre_asap::DataType,
Expand Down Expand Up @@ -889,11 +889,11 @@ fn planner_expressions_preserve_collection_and_nullable_types() {
},
false,
)]);
let access = QueryExpr::FunctionCall {
let access = ScalarExpr::FunctionCall {
name: "asap_element_access".into(),
args: vec![
QueryExpr::Column(0),
QueryExpr::Literal(ScalarValue::Utf8("count".into())),
ScalarExpr::Column(0),
ScalarExpr::Literal(ScalarValue::Utf8("count".into())),
],
};
let project = Operator::project(
Expand Down Expand Up @@ -926,11 +926,11 @@ fn planner_expressions_preserve_collection_and_nullable_types() {
.unwrap();
let projected = project.schema();
dag.add(1, vec![0], project).unwrap();
let predicate = QueryExpr::Compare {
let predicate = ScalarExpr::Compare {
semantics: planner_types::ir::ExprSemantics::Sql,
left: Box::new(QueryExpr::Column(0)),
left: Box::new(ScalarExpr::Column(0)),
op: CompareOpKind::Ge,
right: Box::new(QueryExpr::Literal(ScalarValue::Int64(1))),
right: Box::new(ScalarExpr::Literal(ScalarValue::Int64(1))),
};
dag.add(
2,
Expand All @@ -944,9 +944,9 @@ fn planner_expressions_preserve_collection_and_nullable_types() {
.unwrap();
let rows = run(&dag, 2, query());
assert!(matches!(rows.as_slice(),[row] if matches!(row.as_slice(),[Value::Int64(7)])));
let unknown = QueryExpr::FunctionCall {
let unknown = ScalarExpr::FunctionCall {
name: "unregistered_function".into(),
args: vec![QueryExpr::Column(0)],
args: vec![ScalarExpr::Column(0)],
};
assert!(CompiledExpression::compile(&unknown, &input_schema).is_err());
}
Expand All @@ -958,11 +958,11 @@ fn native_relational_join_kinds_preserve_unmatched_rows() {
use planner_types::pre_asap::{CompareOpKind, JoinKind};

let input = schema(&[("key", DataType::Int64, true)]);
let predicate = Predicate(QueryExpr::Compare {
let predicate = Predicate(ScalarExpr::Compare {
semantics: planner_types::ir::ExprSemantics::Sql,
left: Box::new(QueryExpr::Column(0)),
left: Box::new(ScalarExpr::Column(0)),
op: CompareOpKind::Eq,
right: Box::new(QueryExpr::Column(1)),
right: Box::new(ScalarExpr::Column(1)),
});
for (kind, count) in [
(JoinKind::Inner, 1),
Expand Down
28 changes: 14 additions & 14 deletions crates/asap-physical-operators/tests/physical_semantics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use futures::{executor::block_on, StreamExt};
use planner_types::ir::physical_export::{PhysicalASAPDAGNode, PhysicalASAPOperatorPayload};
use planner_types::ir::NonASAPOp;
use planner_types::ir::Predicate;
use planner_types::ir::ScalarExpr as QueryExpr;
use planner_types::ir::ScalarExpr;
use planner_types::{
post_asap::{Field, FieldDataType},
pre_asap::{CompareOpKind, DataType, JoinKind},
Expand Down Expand Up @@ -78,11 +78,11 @@ fn keys(rows: &[Vec<Value>]) -> Vec<Vec<Vec<u8>>> {
.collect()
}
fn eq_predicate() -> Predicate {
Predicate(QueryExpr::Compare {
Predicate(ScalarExpr::Compare {
semantics: planner_types::ir::ExprSemantics::Sql,
left: Box::new(QueryExpr::Column(0)),
left: Box::new(ScalarExpr::Column(0)),
op: CompareOpKind::Eq,
right: Box::new(QueryExpr::Column(1)),
right: Box::new(ScalarExpr::Column(1)),
})
}
fn join(left: Vec<Value>, right: Vec<Value>, kind: JoinKind, keyed: bool) -> Vec<Vec<Value>> {
Expand Down Expand Up @@ -340,7 +340,7 @@ fn aggregate_empty_and_all_null_follow_asap_contract() {
fn projection_rejects_expression_bound_to_another_schema() {
let original = schema(&[("a", DataType::Int64, false), ("b", DataType::Int64, false)]);
let current = schema(&[("a", DataType::Int64, false)]);
let expr = CompiledExpression::compile(&QueryExpr::Column(1), &original).unwrap();
let expr = CompiledExpression::compile(&ScalarExpr::Column(1), &original).unwrap();
assert!(Operator::project(current, vec![("b".into(), Expression::planner(expr))]).is_err());
}

Expand Down Expand Up @@ -415,11 +415,11 @@ fn planner_comparisons_handle_nan_without_execution_errors() {
CompareOpKind::Gt,
CompareOpKind::Ge,
] {
let expression = QueryExpr::Compare {
let expression = ScalarExpr::Compare {
semantics: planner_types::ir::ExprSemantics::Sql,
left: Box::new(QueryExpr::Column(0)),
left: Box::new(ScalarExpr::Column(0)),
op: op.clone(),
right: Box::new(QueryExpr::Column(1)),
right: Box::new(ScalarExpr::Column(1)),
};
let compiled = CompiledExpression::compile(&expression, &input).unwrap();
for row in [
Expand Down Expand Up @@ -483,11 +483,11 @@ fn mixed_numeric_comparisons_preserve_large_integer_precision() {
("a", DataType::Int64, false),
("b", DataType::Float64, false),
]);
let expr = QueryExpr::Compare {
let expr = ScalarExpr::Compare {
semantics: planner_types::ir::ExprSemantics::Sql,
left: Box::new(QueryExpr::Column(0)),
left: Box::new(ScalarExpr::Column(0)),
op: CompareOpKind::Gt,
right: Box::new(QueryExpr::Column(1)),
right: Box::new(ScalarExpr::Column(1)),
};
let compiled = CompiledExpression::compile(&expr, &input).unwrap();
for (a, b, expected) in [
Expand All @@ -508,11 +508,11 @@ fn boolean_truth_tables_agree_between_expression_paths() {
for and in [true, false] {
for a in [None, Some(false), Some(true)] {
for b in [None, Some(false), Some(true)] {
let parts = vec![QueryExpr::Column(0), QueryExpr::Column(1)];
let parts = vec![ScalarExpr::Column(0), ScalarExpr::Column(1)];
let planner = if and {
QueryExpr::BoolAnd(parts)
ScalarExpr::BoolAnd(parts)
} else {
QueryExpr::BoolOr(parts)
ScalarExpr::BoolOr(parts)
};
let native = if and {
Expression::And(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//! ranking, or workload Cartesian expansion. Placement variants are not listed.
mod common;
use common::compile_physical_asap_dag;
use planner_types::ir::OperatorNode as QueryExpr;
use planner_types::ir::OperatorNode;

use asap_aware_mapping::{
accuracy::{AccuracyEvidenceProvider, DefaultAccuracyModel, PropagationStats},
Expand All @@ -28,7 +28,7 @@ use std::rc::Rc;

struct Evidence;
impl AccuracyEvidenceProvider for Evidence {
fn topk_max_distinct_items(&self, _: &QueryExpr) -> Option<u64> {
fn topk_max_distinct_items(&self, _: &OperatorNode) -> Option<u64> {
Some(1000)
}
fn propagation_stats(
Expand Down Expand Up @@ -67,7 +67,7 @@ impl ReplacementStrategy for LogicalOnly {
}
}

fn lower(query: &str, accuracy: &AccuracyTarget) -> Rc<QueryExpr> {
fn lower(query: &str, accuracy: &AccuracyTarget) -> Rc<OperatorNode> {
let workload = PlanningWorkload {
query_workload: QueryWorkload {
language: QueryLanguage::PromQL,
Expand Down
Loading
Loading