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
26 changes: 13 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[workspace]
members = [
"crates/core",
"crates/ir",
"crates/sketch",
"crates/plan",
"crates/lower",
Expand Down
2 changes: 1 addition & 1 deletion crates/e2e/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ version = "0.1.0"
edition = "2021"

[dependencies]
asap-control-core = { path = "../core" }
asap-ir = { path = "../ir" }
asap-control-lower = { path = "../lower" }
2 changes: 1 addition & 1 deletion crates/e2e/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
//! here derives or computes expected outputs.

pub mod fixtures {
use asap_control_core::intent_algebra::schema::{Column, DataType, Schema};
use asap_ir::intent_algebra::schema::{Column, DataType, Schema};

pub fn ts_col() -> Column {
Column::new("ts", DataType::Timestamp, false)
Expand Down
4 changes: 2 additions & 2 deletions crates/e2e/tests/aggregate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
//! Single-stat PromQL aggregates always get `output_names: [""]` (no alias)
//! and `having: None`.

use asap_control_core::intent_algebra::{AggIntent, QueryExpr, Source};
use asap_control_core::types::AccuracyTarget;
use asap_ir::intent_algebra::{AggIntent, QueryExpr, Source};
use asap_ir::types::AccuracyTarget;
use asap_control_lower::lower_promql;
use asap_e2e::fixtures::metric_schema;

Expand Down
4 changes: 2 additions & 2 deletions crates/e2e/tests/binary_op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

use std::time::Duration;

use asap_control_core::intent_algebra::{
use asap_ir::intent_algebra::{
AggIntent, ArithOp, BinaryOpKind, CompareOp, GroupSide, QueryExpr, Source, VectorGrouping,
VectorMatch, VectorMatchKind,
};
use asap_control_core::types::AccuracyTarget;
use asap_ir::types::AccuracyTarget;
use asap_control_lower::lower_promql;
use asap_e2e::fixtures::metric_schema;

Expand Down
4 changes: 2 additions & 2 deletions crates/e2e/tests/nested.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

use std::time::Duration;

use asap_control_core::intent_algebra::{
use asap_ir::intent_algebra::{
AggIntent, ArithOp, BinaryOpKind, CompareOp, L3Expr, L3Scalar, Predicate, QueryExpr, Source,
};
use asap_control_core::types::AccuracyTarget;
use asap_ir::types::AccuracyTarget;
use asap_control_lower::lower_promql;
use asap_e2e::fixtures::metric_schema;

Expand Down
4 changes: 2 additions & 2 deletions crates/e2e/tests/scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
//! predicate expression references them positionally.
//! Predicates are canonicalized alphabetically by label name at lowering time.

use asap_control_core::intent_algebra::{
use asap_ir::intent_algebra::{
CompareOp, L3Expr, L3Scalar, Predicate, QueryExpr, Source,
};
use asap_control_core::types::AccuracyTarget;
use asap_ir::types::AccuracyTarget;
use asap_control_lower::lower_promql;
use asap_e2e::fixtures::metric_schema;

Expand Down
4 changes: 2 additions & 2 deletions crates/e2e/tests/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
//! `Aggregate` or a `Project`. Per-series reductions (`rate`, `*_over_time`)
//! are label-preserving and keep the schema open.

use asap_control_core::types::AccuracyTarget;
use asap_ir::types::AccuracyTarget;
use asap_control_lower::lower_promql;

fn lower(q: &str) -> asap_control_core::intent_algebra::QueryExpr {
fn lower(q: &str) -> asap_ir::intent_algebra::QueryExpr {
lower_promql(q, AccuracyTarget::Exact).unwrap_or_else(|e| panic!("lower failed for {q:?}: {e}"))
}

Expand Down
4 changes: 2 additions & 2 deletions crates/e2e/tests/time_range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

use std::time::Duration;

use asap_control_core::intent_algebra::{AggIntent, QueryExpr, Source};
use asap_control_core::types::AccuracyTarget;
use asap_ir::intent_algebra::{AggIntent, QueryExpr, Source};
use asap_ir::types::AccuracyTarget;
use asap_control_lower::lower_promql;
use asap_e2e::fixtures::metric_schema;

Expand Down
2 changes: 1 addition & 1 deletion crates/core/Cargo.toml → crates/ir/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "asap-control-core"
name = "asap-ir"
version = "0.1.0"
edition = "2021"

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion crates/lower/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
asap-control-core = { path = "../core" }
asap-ir = { path = "../ir" }
# Private mirror of GreptimeTeam/promql-parser (Apache-2.0). `main` tracks
# upstream untouched; the `asap` branch carries our local grammar/function
# additions (see THIRD_PARTY.md).
Expand Down
4 changes: 2 additions & 2 deletions crates/lower/examples/topk_ir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// Lowers every topk-shaped query from the design discussion and prints the
// resulting L3 IR. Used for interactive exploration; not a test.

use asap_control_core::intent_algebra::schema::{Column, DataType, Schema};
use asap_control_core::types::AccuracyTarget;
use asap_ir::intent_algebra::schema::{Column, DataType, Schema};
use asap_ir::types::AccuracyTarget;
use asap_control_lower::{lower_promql, lower_sql, SqlCatalog};

fn col(name: &str, dtype: DataType) -> Column {
Expand Down
6 changes: 3 additions & 3 deletions crates/lower/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub enum LoweringError {
/// The workload's query language is not handled by this lowerer.
WrongLanguage(String),
/// The L2→L3 converter failed (name resolution against the bound schema).
Convert(asap_control_core::intent_algebra::ConvertError),
Convert(asap_ir::intent_algebra::ConvertError),

// ── SQL front end (DataFusion) ───────────────────────────────────────────
/// DataFusion failed to parse / plan the SQL query.
Expand Down Expand Up @@ -58,8 +58,8 @@ impl fmt::Display for LoweringError {

impl std::error::Error for LoweringError {}

impl From<asap_control_core::intent_algebra::ConvertError> for LoweringError {
fn from(e: asap_control_core::intent_algebra::ConvertError) -> Self {
impl From<asap_ir::intent_algebra::ConvertError> for LoweringError {
fn from(e: asap_ir::intent_algebra::ConvertError) -> Self {
Self::Convert(e)
}
}
Expand Down
10 changes: 5 additions & 5 deletions crates/lower/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
//! Both front ends end at the canonical intent algebra via the same L2→L3
//! [`convert_root`]: PromQL parses with `promql-parser`, SQL parses + plans with
//! DataFusion. Each emits the per-language
//! [`relational::QueryExpr`](asap_control_core::intent_algebra::relational); the
//! shared converter runs the [`Binder`](asap_control_core::intent_algebra::Binder)
//! [`relational::QueryExpr`](asap_ir::intent_algebra::relational); the
//! shared converter runs the [`Binder`](asap_ir::intent_algebra::Binder)
//! for positional name resolution and folds single-statistic sketchable
//! aggregates into canonical shapes.

pub mod error;
pub mod promql;
pub mod sql;

use asap_control_core::intent_algebra::{convert_root, QueryExpr};
use asap_control_core::types::AccuracyTarget;
use asap_control_core::workload::{QueryLanguage, QueryWorkload, SqlDialect};
use asap_ir::intent_algebra::{convert_root, QueryExpr};
use asap_ir::types::AccuracyTarget;
use asap_ir::workload::{QueryLanguage, QueryWorkload, SqlDialect};

pub use error::LoweringError;
pub use promql::PromqlLowerer;
Expand Down
8 changes: 4 additions & 4 deletions crates/lower/src/promql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//! - **L2 (per-language tree)** is built here: the walk interprets PromQL
//! semantics (range vectors, aggregate operators, label matchers) and emits
//! the language-flavored [`relational::QueryExpr`] the controller's L2→L3
//! converter ([`convert_root`](asap_control_core::intent_algebra::convert_root))
//! converter ([`convert_root`](asap_ir::intent_algebra::convert_root))
//! consumes. Canonicalisation (window-over-aggregate fold, GROUP-BY →
//! positional `Aggregate.by`, positional name binding) happens in that
//! converter, not here.
Expand Down Expand Up @@ -41,13 +41,13 @@ use promql_parser::parser::{
VectorSelector,
};

use asap_control_core::intent_algebra::query_expr::{
use asap_ir::intent_algebra::query_expr::{
BinaryOpKind, GroupSide, VectorGrouping, VectorMatch, VectorMatchKind,
};
use asap_control_core::intent_algebra::relational::{
use asap_ir::intent_algebra::relational::{
AggFunc, AggItem, L2SortKey, QueryExpr as L2, SourceSpec,
};
use asap_control_core::intent_algebra::{ArithOp, ColumnRef, CompareOp, L2Expr, L3Scalar};
use asap_ir::intent_algebra::{ArithOp, ColumnRef, CompareOp, L2Expr, L3Scalar};

use crate::error::LoweringError;

Expand Down
2 changes: 1 addition & 1 deletion crates/lower/src/sql/expr.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use datafusion::logical_expr::{BinaryExpr, Expr, Operator};

use asap_control_core::intent_algebra::{ArithOp, ColumnRef, CompareOp, L2Expr, L3Scalar};
use asap_ir::intent_algebra::{ArithOp, ColumnRef, CompareOp, L2Expr, L3Scalar};

use crate::error::LoweringError;

Expand Down
12 changes: 6 additions & 6 deletions crates/lower/src/sql/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
//!
//! Parses SQL via DataFusion (over the catalog's registered tables), then walks
//! the unoptimized `LogicalPlan` and emits the language-independent
//! [`relational::QueryExpr`](asap_control_core::intent_algebra::relational) that
//! [`convert_root`](asap_control_core::intent_algebra::convert_root) lowers to
//! [`relational::QueryExpr`](asap_ir::intent_algebra::relational) that
//! [`convert_root`](asap_ir::intent_algebra::convert_root) lowers to
//! canonical L3. Positional column identity, accuracy threading, and the
//! window-over-aggregate fold all happen in that converter — this front end
//! only interprets SQL semantics into the shared L2 algebra.
Expand All @@ -17,11 +17,11 @@ use datafusion::logical_expr::{
};
use datafusion::prelude::SessionContext;

use asap_control_core::intent_algebra::relational::{
use asap_ir::intent_algebra::relational::{
AggFunc, AggItem, L2ProjectItem, L2SortKey, QueryExpr as L2, SourceSpec,
};
use asap_control_core::intent_algebra::schema::Schema;
use asap_control_core::intent_algebra::{
use asap_ir::intent_algebra::schema::Schema;
use asap_ir::intent_algebra::{
ColumnRef, CompareOp, JoinKind, L2Expr, L3Scalar, SetOpKind, WindowFuncKind,
};

Expand All @@ -36,7 +36,7 @@ use self::expr::df_expr_to_l2;
use self::types::schema_to_arrow;

/// Lowers SQL strings to the Layer-2 [`relational::QueryExpr`] over a table
/// [`SqlCatalog`]. Call [`convert_root`](asap_control_core::intent_algebra::convert_root)
/// [`SqlCatalog`]. Call [`convert_root`](asap_ir::intent_algebra::convert_root)
/// on the result for canonical L3.
pub struct SqlLowerer<'a> {
catalog: &'a SqlCatalog,
Expand Down
4 changes: 2 additions & 2 deletions crates/lower/src/sql/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use datafusion::arrow::datatypes::{
};
use datafusion::common::ScalarValue;

use asap_control_core::intent_algebra::schema::{Column, DataType, Schema};
use asap_control_core::intent_algebra::L3Scalar;
use asap_ir::intent_algebra::schema::{Column, DataType, Schema};
use asap_ir::intent_algebra::L3Scalar;

use crate::error::LoweringError;

Expand Down
4 changes: 2 additions & 2 deletions crates/lower/tests/awesome_prometheus_alerts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
// `__GAP`-suffixed names intentionally SHOUT the documented divergences.
#![allow(non_snake_case)]

use asap_control_core::intent_algebra::{AggIntent, BinaryOpKind, CompareOp, QueryExpr};
use asap_control_core::types::AccuracyTarget;
use asap_ir::intent_algebra::{AggIntent, BinaryOpKind, CompareOp, QueryExpr};
use asap_ir::types::AccuracyTarget;
use asap_control_lower::{lower_promql, LoweringError};

const CORPUS: &str = include_str!("data/awesome_prometheus_alerts.txt");
Expand Down
4 changes: 2 additions & 2 deletions crates/lower/tests/promql_conformance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@

use std::time::Duration;

use asap_control_core::intent_algebra::{
use asap_ir::intent_algebra::{
AggIntent, ArithOp, BinaryOpKind, CompareOp, QueryExpr, Source,
};
use asap_control_core::types::AccuracyTarget;
use asap_ir::types::AccuracyTarget;
use asap_control_lower::{lower_promql, LoweringError};

// ── harness helpers ─────────────────────────────────────────────────────────────
Expand Down
2 changes: 1 addition & 1 deletion crates/lower/tests/promql_corpus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//! that is the guarantee. A coverage floor guards against a change silently
//! tanking how much of the corpus we can lower.

use asap_control_core::types::AccuracyTarget;
use asap_ir::types::AccuracyTarget;
use asap_control_lower::{lower_promql, LoweringError};

const DOCS: &str = include_str!("data/promql_corpus_docs.txt");
Expand Down
4 changes: 2 additions & 2 deletions crates/lower/tests/promql_equivalence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

#![allow(non_snake_case)]

use asap_control_core::intent_algebra::QueryExpr;
use asap_control_core::types::AccuracyTarget;
use asap_ir::intent_algebra::QueryExpr;
use asap_ir::types::AccuracyTarget;
use asap_control_lower::lower_promql;

fn lo(q: &str) -> QueryExpr {
Expand Down
10 changes: 5 additions & 5 deletions crates/lower/tests/promql_lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

use std::time::Duration;

use asap_control_core::intent_algebra::{
use asap_ir::intent_algebra::{
AggIntent, ArithOp, BinaryOpKind, CompareOp, L3Expr, L3Scalar, QueryExpr, Source,
};
use asap_control_core::types::AccuracyTarget;
use asap_control_core::workload::{
use asap_ir::types::AccuracyTarget;
use asap_ir::workload::{
BatchEntry, Query, QueryLanguage, QueryRequirements, QueryWorkload,
};

Expand Down Expand Up @@ -448,7 +448,7 @@ fn binary_op_with_on_grouping() {
panic!("expected BinaryOp, got {qe:?}");
};
let vm = vector_match.as_ref().expect("vector_match present");
use asap_control_core::intent_algebra::VectorMatchKind;
use asap_ir::intent_algebra::VectorMatchKind;
assert_eq!(vm.kind, VectorMatchKind::On);
assert_eq!(vm.labels, vec!["host".to_string()]);
}
Expand Down Expand Up @@ -666,7 +666,7 @@ fn batch_lowers_each_entry_and_reads_per_query_accuracy() {

#[test]
fn batch_rejects_non_promql_language() {
use asap_control_core::workload::SqlDialect;
use asap_ir::workload::SqlDialect;
let workload = QueryWorkload {
language: QueryLanguage::SQL(SqlDialect::DataFusionSQL),
query_batch: Some(vec![BatchEntry {
Expand Down
6 changes: 3 additions & 3 deletions crates/lower/tests/sql_lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
//! the relational L2 algebra, and the shared `convert_root` produces positional
//! canonical L3 (the same converter the PromQL path uses).

use asap_control_core::intent_algebra::schema::{Column, DataType, Schema};
use asap_control_core::intent_algebra::{
use asap_ir::intent_algebra::schema::{Column, DataType, Schema};
use asap_ir::intent_algebra::{
AggIntent, CompareOp, GroupKeys, JoinKind, L3Expr, QueryExpr, Source, WindowFuncKind,
};
use asap_control_core::types::AccuracyTarget;
use asap_ir::types::AccuracyTarget;
use asap_control_lower::{lower_sql, SqlCatalog};

fn col(name: &str, dtype: DataType) -> Column {
Expand Down
Loading
Loading