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
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]
### Changed

### Added

### Removed

## [0.12.0]
### Changed
- *BREAKING* partiql-parser: Added a source location to `ParseError::UnexpectedEndOfInput`
- *BREAKING* partiql-ast: Changed the modelling of parsed literals.
- *BREAKING* partiql-logical: Changed the modelling of logical plan literals.
Expand Down Expand Up @@ -322,7 +329,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- PartiQL Playground proof of concept (POC)
- PartiQL CLI with REPL and query visualization features

[Unreleased]: https://github.com/partiql/partiql-lang-rust/compare/v0.11.0...HEAD
[Unreleased]: https://github.com/partiql/partiql-lang-rust/compare/v0.12.0...HEAD
[0.12.0]: https://github.com/partiql/partiql-lang-rust/releases/tag/v0.12.0
[0.11.0]: https://github.com/partiql/partiql-lang-rust/releases/tag/v0.11.0
[0.10.1]: https://github.com/partiql/partiql-lang-rust/releases/tag/v0.10.1
[0.10.0]: https://github.com/partiql/partiql-lang-rust/releases/tag/v0.10.0
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
authors = ["PartiQL Team <partiql-team@amazon.com>"]
homepage = "https://github.com/partiql/partiql-lang-rust"
repository = "https://github.com/partiql/partiql-lang-rust"
version = "0.11.0"
version = "0.12.0"
edition = "2021"

[workspace]
Expand Down
14 changes: 7 additions & 7 deletions extension/partiql-extension-csv/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ edition.workspace = true
bench = false

[dependencies]
partiql-value = { path = "../../partiql-value", version = "0.11.*" }
partiql-catalog = { path = "../../partiql-catalog", version = "0.11.*" }
partiql-logical = { path = "../../partiql-logical", version = "0.11.*" }
partiql-value = { path = "../../partiql-value", version = "0.12.*" }
partiql-catalog = { path = "../../partiql-catalog", version = "0.12.*" }
partiql-logical = { path = "../../partiql-logical", version = "0.12.*" }

csv = "1"

Expand All @@ -40,10 +40,10 @@ thiserror = "1.0"
delegate = "0.13"

[dev-dependencies]
partiql-parser = { path = "../../partiql-parser", version = "0.11.*" }
partiql-logical = { path = "../../partiql-logical", version = "0.11.*" }
partiql-logical-planner = { path = "../../partiql-logical-planner", version = "0.11.*" }
partiql-eval = { path = "../../partiql-eval", version = "0.11.*" }
partiql-parser = { path = "../../partiql-parser", version = "0.12.*" }
partiql-logical = { path = "../../partiql-logical", version = "0.12.*" }
partiql-logical-planner = { path = "../../partiql-logical-planner", version = "0.12.*" }
partiql-eval = { path = "../../partiql-eval", version = "0.12.*" }

insta = "1"

Expand Down
2 changes: 1 addition & 1 deletion extension/partiql-extension-ddl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ edition.workspace = true
bench = false

[dependencies]
partiql-types = { path = "../../partiql-types", version = "0.11.*" }
partiql-types = { path = "../../partiql-types", version = "0.12.*" }

thiserror = "1.0"
miette = { version = "7", features = ["fancy"] }
Expand Down
16 changes: 8 additions & 8 deletions extension/partiql-extension-ion-functions/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ edition.workspace = true
bench = false

[dependencies]
partiql-extension-ion = { path = "../partiql-extension-ion", version = "0.11.*" }
partiql-value = { path = "../../partiql-value", version = "0.11.*" }
partiql-catalog = { path = "../../partiql-catalog", version = "0.11.*" }
partiql-logical = { path = "../../partiql-logical", version = "0.11.*" }
partiql-extension-ion = { path = "../partiql-extension-ion", version = "0.12.*" }
partiql-value = { path = "../../partiql-value", version = "0.12.*" }
partiql-catalog = { path = "../../partiql-catalog", version = "0.12.*" }
partiql-logical = { path = "../../partiql-logical", version = "0.12.*" }

ordered-float = "5"
itertools = "0.14"
Expand All @@ -41,10 +41,10 @@ zstd = "0.13"
flate2 = "1.0"

[dev-dependencies]
partiql-parser = { path = "../../partiql-parser", version = "0.11.*" }
partiql-logical = { path = "../../partiql-logical", version = "0.11.*" }
partiql-logical-planner = { path = "../../partiql-logical-planner", version = "0.11.*" }
partiql-eval = { path = "../../partiql-eval", version = "0.11.*" }
partiql-parser = { path = "../../partiql-parser", version = "0.12.*" }
partiql-logical = { path = "../../partiql-logical", version = "0.12.*" }
partiql-logical-planner = { path = "../../partiql-logical-planner", version = "0.12.*" }
partiql-eval = { path = "../../partiql-eval", version = "0.12.*" }

insta = "1"

Expand Down
6 changes: 3 additions & 3 deletions extension/partiql-extension-ion/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ edition.workspace = true
bench = false

[dependencies]
partiql-value = { path = "../../partiql-value", version = "0.11.*" }
partiql-common = { path = "../../partiql-common", version = "0.11.*" }
partiql-types = { path = "../../partiql-types", version = "0.11.*" }
partiql-value = { path = "../../partiql-value", version = "0.12.*" }
partiql-common = { path = "../../partiql-common", version = "0.12.*" }
partiql-types = { path = "../../partiql-types", version = "0.12.*" }

serde = { version = "1", features = ["derive"], optional = true }
typetag = { version = "0.2", optional = true }
Expand Down
4 changes: 2 additions & 2 deletions extension/partiql-extension-value-functions/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ edition.workspace = true
bench = false

[dependencies]
partiql-value = { path = "../../partiql-value", version = "0.11.*" }
partiql-catalog = { path = "../../partiql-catalog", version = "0.11.*" }
partiql-value = { path = "../../partiql-value", version = "0.12.*" }
partiql-catalog = { path = "../../partiql-catalog", version = "0.12.*" }

ordered-float = "5"
unicase = "2.6"
Expand Down
4 changes: 2 additions & 2 deletions extension/partiql-extension-visualize/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ edition.workspace = true
bench = false

[dependencies]
partiql-ast = { path = "../../partiql-ast", version = "0.11.*" }
partiql-logical = { path = "../../partiql-logical", version = "0.11.*" }
partiql-ast = { path = "../../partiql-ast", version = "0.12.*" }
partiql-logical = { path = "../../partiql-logical", version = "0.12.*" }

dot-writer = { version = "0.1", optional = true }
itertools = { version = "0.14", optional = true }
Expand Down
8 changes: 4 additions & 4 deletions partiql-ast-passes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ path = "src/lib.rs"
bench = false

[dependencies]
partiql-ast = { path = "../partiql-ast", version = "0.11.*" }
partiql-catalog = { path = "../partiql-catalog", version = "0.11.*" }
partiql-common = { path = "../partiql-common", version = "0.11.*" }
partiql-types = { path = "../partiql-types", version = "0.11.*" }
partiql-ast = { path = "../partiql-ast", version = "0.12.*" }
partiql-catalog = { path = "../partiql-catalog", version = "0.12.*" }
partiql-common = { path = "../partiql-common", version = "0.12.*" }
partiql-types = { path = "../partiql-types", version = "0.12.*" }

fnv = "1"
indexmap = "2"
Expand Down
4 changes: 2 additions & 2 deletions partiql-ast/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ path = "src/lib.rs"
bench = false

[dependencies]
partiql-common = { path = "../partiql-common", version = "0.11.*" }
partiql-common = { path = "../partiql-common", version = "0.12.*" }
indexmap = "2"
rust_decimal = { version = "1.36.0", default-features = false, features = ["std"] }
serde = { version = "1", features = ["derive"], optional = true }
Expand All @@ -39,4 +39,4 @@ serde = [

[dependencies.partiql-ast-macros]
path = "partiql-ast-macros"
version = "0.11.*"
version = "0.12.*"
8 changes: 4 additions & 4 deletions partiql-catalog/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ edition.workspace = true
bench = false

[dependencies]
partiql-common = { path = "../partiql-common", version = "0.11.*" }
partiql-value = { path = "../partiql-value", version = "0.11.*" }
partiql-logical = { path = "../partiql-logical", version = "0.11.*" }
partiql-types = { path = "../partiql-types", version = "0.11.*" }
partiql-common = { path = "../partiql-common", version = "0.12.*" }
partiql-value = { path = "../partiql-value", version = "0.12.*" }
partiql-logical = { path = "../partiql-logical", version = "0.12.*" }
partiql-types = { path = "../partiql-types", version = "0.12.*" }

thiserror = "1.0"
ordered-float = "5"
Expand Down
22 changes: 11 additions & 11 deletions partiql-conformance-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ bench = false

[build-dependencies]
miette = { version = "7", features = ["fancy"] }
partiql-conformance-test-generator = { path = "../partiql-conformance-test-generator", version = "0.11.*" }
partiql-conformance-test-generator = { path = "../partiql-conformance-test-generator", version = "0.12.*" }

[dependencies]
partiql-parser = { path = "../partiql-parser", version = "0.11.*" }
partiql-catalog = { path = "../partiql-catalog", version = "0.11.*" }
partiql-common = { path = "../partiql-common", version = "0.11.*" }
partiql-ast = { path = "../partiql-ast", version = "0.11.*" }
partiql-ast-passes = { path = "../partiql-ast-passes", version = "0.11.*" }
partiql-logical-planner = { path = "../partiql-logical-planner", version = "0.11.*" }
partiql-logical = { path = "../partiql-logical", version = "0.11.*" }
partiql-value = { path = "../partiql-value", version = "0.11.*" }
partiql-eval = { path = "../partiql-eval", version = "0.11.*" }
partiql-extension-ion = { path = "../extension/partiql-extension-ion", version = "0.11.*" }
partiql-parser = { path = "../partiql-parser", version = "0.12.*" }
partiql-catalog = { path = "../partiql-catalog", version = "0.12.*" }
partiql-common = { path = "../partiql-common", version = "0.12.*" }
partiql-ast = { path = "../partiql-ast", version = "0.12.*" }
partiql-ast-passes = { path = "../partiql-ast-passes", version = "0.12.*" }
partiql-logical-planner = { path = "../partiql-logical-planner", version = "0.12.*" }
partiql-logical = { path = "../partiql-logical", version = "0.12.*" }
partiql-value = { path = "../partiql-value", version = "0.12.*" }
partiql-eval = { path = "../partiql-eval", version = "0.12.*" }
partiql-extension-ion = { path = "../extension/partiql-extension-ion", version = "0.12.*" }

ion-rs_old = { version = "0.18", package = "ion-rs" }

Expand Down
16 changes: 8 additions & 8 deletions partiql-eval/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ edition.workspace = true
bench = false

[dependencies]
partiql-common = { path = "../partiql-common", version = "0.11.*" }
partiql-logical = { path = "../partiql-logical", version = "0.11.*" }
partiql-value = { path = "../partiql-value", version = "0.11.*" }
partiql-catalog = { path = "../partiql-catalog", version = "0.11.*" }
partiql-types = { path = "../partiql-types", version = "0.11.*" }
partiql-extension-ion = { path = "../extension/partiql-extension-ion", version = "0.11.*" }
partiql-common = { path = "../partiql-common", version = "0.12.*" }
partiql-logical = { path = "../partiql-logical", version = "0.12.*" }
partiql-value = { path = "../partiql-value", version = "0.12.*" }
partiql-catalog = { path = "../partiql-catalog", version = "0.12.*" }
partiql-types = { path = "../partiql-types", version = "0.12.*" }
partiql-extension-ion = { path = "../extension/partiql-extension-ion", version = "0.12.*" }
ion-rs_old = { version = "0.18", package = "ion-rs" }
lasso = "0.7"
petgraph = "0.7"
Expand All @@ -48,8 +48,8 @@ serde = { version = "1", features = ["derive"], optional = true }

[dev-dependencies]
criterion = "0.5"
partiql-parser = { path = "../partiql-parser", version = "0.11.*" }
partiql-logical-planner = { path = "../partiql-logical-planner", version = "0.11.*" }
partiql-parser = { path = "../partiql-parser", version = "0.12.*" }
partiql-logical-planner = { path = "../partiql-logical-planner", version = "0.12.*" }


[features]
Expand Down
20 changes: 10 additions & 10 deletions partiql-logical-planner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ edition.workspace = true
bench = false

[dependencies]
partiql-ast = { path = "../partiql-ast", version = "0.11.*" }
partiql-ast-passes = { path = "../partiql-ast-passes", version = "0.11.*" }
partiql-catalog = { path = "../partiql-catalog", version = "0.11.*" }
partiql-common = { path = "../partiql-common", version = "0.11.*" }
partiql-parser = { path = "../partiql-parser", version = "0.11.*" }
partiql-logical = { path = "../partiql-logical", version = "0.11.*" }
partiql-types = { path = "../partiql-types", version = "0.11.*" }
partiql-value = { path = "../partiql-value", version = "0.11.*" }
partiql-ast = { path = "../partiql-ast", version = "0.12.*" }
partiql-ast-passes = { path = "../partiql-ast-passes", version = "0.12.*" }
partiql-catalog = { path = "../partiql-catalog", version = "0.12.*" }
partiql-common = { path = "../partiql-common", version = "0.12.*" }
partiql-parser = { path = "../partiql-parser", version = "0.12.*" }
partiql-logical = { path = "../partiql-logical", version = "0.12.*" }
partiql-types = { path = "../partiql-types", version = "0.12.*" }
partiql-value = { path = "../partiql-value", version = "0.12.*" }

ordered-float = "5"
itertools = "0.14"
Expand All @@ -42,5 +42,5 @@ once_cell = "1"
thiserror = "1"

[dev-dependencies]
partiql-eval = { path = "../partiql-eval", version = "0.11.*" }
partiql-types = { path = "../partiql-types", version = "0.11.*" }
#partiql-eval = { path = "../partiql-eval", version = "0.12.*" }
partiql-types = { path = "../partiql-types", version = "0.12.*" }
114 changes: 0 additions & 114 deletions partiql-logical-planner/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,117 +38,3 @@ impl<'c> LogicalPlanner<'c> {
planner.lower_query(q)
}
}

#[cfg(test)]
mod tests {
use assert_matches::assert_matches;
use partiql_ast_passes::error::AstTransformationError;
use partiql_catalog::catalog::PartiqlCatalog;
use partiql_catalog::context::SystemContext;

use partiql_eval::env::basic::MapBindings;
use partiql_eval::eval::BasicContext;

use partiql_eval::plan;
use partiql_eval::plan::EvaluationMode;

use crate::LogicalPlanner;
use partiql_logical as logical;
use partiql_logical::{BindingsOp, LogicalPlan};
use partiql_parser::{Parsed, Parser};
use partiql_value::{bag, tuple, DateTime, Value};

#[track_caller]
fn parse(text: &str) -> Parsed<'_> {
Parser::default().parse(text).unwrap()
}

#[track_caller]
fn lower(
parsed: &Parsed<'_>,
) -> Result<logical::LogicalPlan<logical::BindingsOp>, AstTransformationError> {
let catalog = PartiqlCatalog::default();
let planner = LogicalPlanner::new(&catalog);
planner.lower(parsed)
}

#[track_caller]
fn evaluate(logical: LogicalPlan<BindingsOp>, bindings: MapBindings<Value>) -> Value {
let catalog = PartiqlCatalog::default();
let mut planner = plan::EvaluatorPlanner::new(EvaluationMode::Permissive, &catalog);
let mut plan = planner.compile(&logical).expect("Expect no plan error");
println!("{}", plan.to_dot_graph());
let sys = SystemContext {
now: DateTime::from_system_now_utc(),
};
let ctx = BasicContext::new(bindings, sys);
if let Ok(out) = plan.execute_mut(&ctx) {
out.result
} else {
Value::Missing
}
}

#[track_caller]
fn evaluate_query(query: &str) -> Value {
let parsed = parse(query);
let lowered = lower(&parsed).expect("Expect no lower error");
evaluate(lowered, Default::default())
}

fn data_customer() -> MapBindings<Value> {
fn customer_tuple(id: i64, first_name: &str, balance: i64) -> Value {
tuple![("id", id), ("firstName", first_name), ("balance", balance),].into()
}

let customer_val = bag![
customer_tuple(5, "jason", 100),
customer_tuple(4, "sisko", 0),
customer_tuple(3, "jason", -30),
customer_tuple(2, "miriam", 20),
customer_tuple(1, "miriam", 10),
];

let mut bindings = MapBindings::default();
bindings.insert("customer", customer_val.into());
bindings
}

#[test]
pub fn test() {
// Plan for `SELECT DISTINCT firstName, (firstName || firstName) AS doubleName FROM customer WHERE balance > 0`
let query = "\
SELECT DISTINCT firstName, (firstName || firstName) AS doubleName \
FROM customer \
WHERE balance > 0";
let parsed = parse(query);
let lowered = lower(&parsed).expect("Expect no lower error");
let out = evaluate(lowered, data_customer());

println!("{:?}", &out);
assert_matches!(out, Value::Bag(bag) => {
let expected = bag![
tuple![("firstName", "jason"), ("doubleName", "jasonjason")],
tuple![("firstName", "miriam"), ("doubleName", "miriammiriam")],
];
assert_eq!(*bag, expected);
});
}

#[test]
pub fn test_5() {
let out = evaluate_query("5");
println!("{:?}", &out);
assert_matches!(out, Value::Integer(5));
}

#[test]
pub fn test_from_5() {
let out = evaluate_query("SELECT * FROM 5");
println!("{:?}", &out);
assert_matches!(out, Value::Bag(bag) => {
let expected = bag![tuple![("_1", 5)]];
assert_eq!(*bag, expected);
});
}
}
Loading
Loading