-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add validation for comparison operations (#505)
- Loading branch information
Showing
12 changed files
with
387 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
use partiql_ast_passes::error::AstTransformationError; | ||
use partiql_catalog::catalog::{Catalog, PartiqlCatalog}; | ||
use partiql_catalog::context::SystemContext; | ||
use partiql_eval as eval; | ||
use partiql_eval::env::basic::MapBindings; | ||
use partiql_eval::error::{EvalErr, PlanErr}; | ||
use partiql_eval::eval::{BasicContext, EvalPlan, EvalResult, Evaluated}; | ||
use partiql_eval::plan::EvaluationMode; | ||
use partiql_logical as logical; | ||
use partiql_parser::{Parsed, ParserError, ParserResult}; | ||
use partiql_value::{DateTime, Value}; | ||
use std::error::Error; | ||
use thiserror::Error; | ||
|
||
#[derive(Error, Debug)] | ||
pub enum TestError<'a> { | ||
#[error("Parse error: {0:?}")] | ||
Parse(ParserError<'a>), | ||
#[error("Lower error: {0:?}")] | ||
Lower(AstTransformationError), | ||
#[error("Plan error: {0:?}")] | ||
Plan(PlanErr), | ||
#[error("Evaluation error: {0:?}")] | ||
Eval(EvalErr), | ||
#[error("Other: {0:?}")] | ||
Other(Box<dyn Error>), | ||
} | ||
|
||
impl<'a> From<ParserError<'a>> for TestError<'a> { | ||
fn from(err: ParserError<'a>) -> Self { | ||
TestError::Parse(err) | ||
} | ||
} | ||
|
||
impl From<AstTransformationError> for TestError<'_> { | ||
fn from(err: AstTransformationError) -> Self { | ||
TestError::Lower(err) | ||
} | ||
} | ||
|
||
impl From<PlanErr> for TestError<'_> { | ||
fn from(err: PlanErr) -> Self { | ||
TestError::Plan(err) | ||
} | ||
} | ||
|
||
impl From<EvalErr> for TestError<'_> { | ||
fn from(err: EvalErr) -> Self { | ||
TestError::Eval(err) | ||
} | ||
} | ||
|
||
impl From<Box<dyn Error>> for TestError<'_> { | ||
fn from(err: Box<dyn Error>) -> Self { | ||
TestError::Other(err) | ||
} | ||
} | ||
|
||
#[track_caller] | ||
#[inline] | ||
pub fn parse(statement: &str) -> ParserResult<'_> { | ||
partiql_parser::Parser::default().parse(statement) | ||
} | ||
|
||
#[track_caller] | ||
#[inline] | ||
pub fn lower( | ||
catalog: &dyn Catalog, | ||
parsed: &Parsed<'_>, | ||
) -> Result<logical::LogicalPlan<logical::BindingsOp>, AstTransformationError> { | ||
let planner = partiql_logical_planner::LogicalPlanner::new(catalog); | ||
planner.lower(parsed) | ||
} | ||
|
||
#[track_caller] | ||
#[inline] | ||
pub fn compile( | ||
mode: EvaluationMode, | ||
catalog: &dyn Catalog, | ||
logical: logical::LogicalPlan<logical::BindingsOp>, | ||
) -> Result<EvalPlan, PlanErr> { | ||
let mut planner = eval::plan::EvaluatorPlanner::new(mode, catalog); | ||
planner.compile(&logical) | ||
} | ||
|
||
#[track_caller] | ||
#[inline] | ||
pub fn evaluate(mut plan: EvalPlan, bindings: MapBindings<Value>) -> EvalResult { | ||
let sys = SystemContext { | ||
now: DateTime::from_system_now_utc(), | ||
}; | ||
let ctx = BasicContext::new(bindings, sys); | ||
plan.execute_mut(&ctx) | ||
} | ||
|
||
#[track_caller] | ||
#[inline] | ||
pub fn eval_query_with_catalog<'a>( | ||
statement: &'a str, | ||
catalog: &dyn Catalog, | ||
mode: EvaluationMode, | ||
) -> Result<Evaluated, TestError<'a>> { | ||
let parsed = parse(statement)?; | ||
let lowered = lower(catalog, &parsed)?; | ||
let bindings = Default::default(); | ||
let plan = compile(mode, catalog, lowered)?; | ||
Ok(evaluate(plan, bindings)?) | ||
} | ||
|
||
#[track_caller] | ||
#[inline] | ||
pub fn eval_query(statement: &str, mode: EvaluationMode) -> Result<Evaluated, TestError<'_>> { | ||
let catalog = PartiqlCatalog::default(); | ||
eval_query_with_catalog(statement, &catalog, mode) | ||
} |
Oops, something went wrong.
3f9d17f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PartiQL (rust) Benchmark
arith_agg-avg
765428
ns/iter (± 17728
)757550
ns/iter (± 14135
)1.01
arith_agg-avg_distinct
858820
ns/iter (± 20625
)846820
ns/iter (± 4815
)1.01
arith_agg-count
814540
ns/iter (± 16330
)804760
ns/iter (± 17690
)1.01
arith_agg-count_distinct
852711
ns/iter (± 3888
)838944
ns/iter (± 3186
)1.02
arith_agg-min
819503
ns/iter (± 5160
)810775
ns/iter (± 2512
)1.01
arith_agg-min_distinct
856574
ns/iter (± 4490
)843615
ns/iter (± 11284
)1.02
arith_agg-max
827442
ns/iter (± 1701
)817235
ns/iter (± 5860
)1.01
arith_agg-max_distinct
864722
ns/iter (± 1752
)854241
ns/iter (± 29133
)1.01
arith_agg-sum
821912
ns/iter (± 11050
)810277
ns/iter (± 3458
)1.01
arith_agg-sum_distinct
857937
ns/iter (± 2288
)844957
ns/iter (± 23645
)1.02
arith_agg-avg-count-min-max-sum
968498
ns/iter (± 45038
)961188
ns/iter (± 5157
)1.01
arith_agg-avg-count-min-max-sum-group_by
1221287
ns/iter (± 4423
)1204105
ns/iter (± 13924
)1.01
arith_agg-avg-count-min-max-sum-group_by-group_as
1838260
ns/iter (± 4472
)1832649
ns/iter (± 9959
)1.00
arith_agg-avg_distinct-count_distinct-min_distinct-max_distinct-sum_distinct
1266617
ns/iter (± 22698
)1262413
ns/iter (± 14368
)1.00
arith_agg-avg_distinct-count_distinct-min_distinct-max_distinct-sum_distinct-group_by
1556324
ns/iter (± 8387
)1534439
ns/iter (± 28757
)1.01
arith_agg-avg_distinct-count_distinct-min_distinct-max_distinct-sum_distinct-group_by-group_as
2188553
ns/iter (± 5721
)2116623
ns/iter (± 6642
)1.03
parse-1
6102
ns/iter (± 28
)6042
ns/iter (± 15
)1.01
parse-15
50272
ns/iter (± 88
)49793
ns/iter (± 149
)1.01
parse-30
99654
ns/iter (± 3473
)93069
ns/iter (± 355
)1.07
compile-1
4225
ns/iter (± 22
)4169
ns/iter (± 45
)1.01
compile-15
32652
ns/iter (± 260
)31690
ns/iter (± 115
)1.03
compile-30
67918
ns/iter (± 193
)66238
ns/iter (± 456
)1.03
plan-1
69724
ns/iter (± 423
)66874
ns/iter (± 402
)1.04
plan-15
1094861
ns/iter (± 9322
)1055270
ns/iter (± 20019
)1.04
plan-30
2191116
ns/iter (± 13765
)2112655
ns/iter (± 10183
)1.04
eval-1
13197485
ns/iter (± 249211
)13247704
ns/iter (± 391970
)1.00
eval-15
89259168
ns/iter (± 934982
)95034828
ns/iter (± 947484
)0.94
eval-30
171668148
ns/iter (± 423756
)182929663
ns/iter (± 493150
)0.94
join
10085
ns/iter (± 421
)9839
ns/iter (± 47
)1.03
simple
2543
ns/iter (± 9
)2590
ns/iter (± 13
)0.98
simple-no
475
ns/iter (± 1
)474
ns/iter (± 2
)1.00
numbers
48
ns/iter (± 0
)48
ns/iter (± 0
)1
parse-simple
937
ns/iter (± 4
)820
ns/iter (± 31
)1.14
parse-ion
2733
ns/iter (± 8
)2667
ns/iter (± 7
)1.02
parse-group
7922
ns/iter (± 23
)8040
ns/iter (± 43
)0.99
parse-complex
20662
ns/iter (± 208
)21267
ns/iter (± 231
)0.97
parse-complex-fexpr
28614
ns/iter (± 227
)28958
ns/iter (± 102
)0.99
This comment was automatically generated by workflow using github-action-benchmark.