-
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.
Allow ORDER BY to 'see' projection names (#443)
- Loading branch information
Showing
5 changed files
with
173 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,112 @@ | ||
#[cfg(test)] | ||
mod tests { | ||
use partiql_ast_passes::error::AstTransformationError; | ||
use partiql_catalog::{Catalog, PartiqlCatalog}; | ||
use partiql_eval as eval; | ||
use partiql_eval::env::basic::MapBindings; | ||
use partiql_eval::error::{EvalErr, PlanErr}; | ||
use partiql_eval::eval::{EvalPlan, EvalResult, Evaluated}; | ||
use partiql_eval::plan::EvaluationMode; | ||
use partiql_logical as logical; | ||
use partiql_parser::{Parsed, ParserError, ParserResult}; | ||
use partiql_value::Value; | ||
use thiserror::Error; | ||
|
||
#[derive(Error, Debug)] | ||
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), | ||
} | ||
|
||
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) | ||
} | ||
} | ||
|
||
#[track_caller] | ||
#[inline] | ||
fn parse(statement: &str) -> ParserResult { | ||
partiql_parser::Parser::default().parse(statement) | ||
} | ||
|
||
#[track_caller] | ||
#[inline] | ||
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] | ||
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] | ||
fn evaluate(mut plan: EvalPlan, bindings: MapBindings<Value>) -> EvalResult { | ||
plan.execute_mut(bindings) | ||
} | ||
|
||
#[track_caller] | ||
#[inline] | ||
fn eval(statement: &str, mode: EvaluationMode) -> Result<Evaluated, TestError<'_>> { | ||
let catalog = PartiqlCatalog::default(); | ||
|
||
let parsed = parse(statement)?; | ||
let lowered = lower(&catalog, &parsed)?; | ||
let bindings = Default::default(); | ||
let plan = compile(mode, &catalog, lowered)?; | ||
Ok(evaluate(plan, bindings)?) | ||
} | ||
|
||
#[test] | ||
fn todo() {} | ||
fn order_by_count() { | ||
let query = "select foo, count(1) as n from | ||
<< | ||
{ 'foo': 'foo' }, | ||
{ 'foo': 'bar' }, | ||
{ 'foo': 'qux' }, | ||
{ 'foo': 'bar' }, | ||
{ 'foo': 'baz' }, | ||
{ 'foo': 'bar' }, | ||
{ 'foo': 'baz' } | ||
>> group by foo order by n desc"; | ||
|
||
let res = eval(query, EvaluationMode::Permissive); | ||
assert!(res.is_ok()); | ||
} | ||
} |
05d3fc8
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
762950
ns/iter (± 5108
)763583
ns/iter (± 3390
)1.00
arith_agg-avg_distinct
848481
ns/iter (± 10112
)848959
ns/iter (± 3747
)1.00
arith_agg-count
806134
ns/iter (± 14060
)804209
ns/iter (± 29915
)1.00
arith_agg-count_distinct
841558
ns/iter (± 3359
)841379
ns/iter (± 2663
)1.00
arith_agg-min
814702
ns/iter (± 5147
)811458
ns/iter (± 12162
)1.00
arith_agg-min_distinct
845150
ns/iter (± 23113
)848553
ns/iter (± 2675
)1.00
arith_agg-max
819597
ns/iter (± 5641
)822782
ns/iter (± 2645
)1.00
arith_agg-max_distinct
857070
ns/iter (± 8162
)859345
ns/iter (± 2350
)1.00
arith_agg-sum
811700
ns/iter (± 4935
)811349
ns/iter (± 3125
)1.00
arith_agg-sum_distinct
845651
ns/iter (± 3480
)849049
ns/iter (± 4051
)1.00
arith_agg-avg-count-min-max-sum
964272
ns/iter (± 8929
)959853
ns/iter (± 3200
)1.00
arith_agg-avg-count-min-max-sum-group_by
1208187
ns/iter (± 11106
)1257292
ns/iter (± 8831
)0.96
arith_agg-avg-count-min-max-sum-group_by-group_as
1810359
ns/iter (± 20019
)1809821
ns/iter (± 24568
)1.00
arith_agg-avg_distinct-count_distinct-min_distinct-max_distinct-sum_distinct
1245624
ns/iter (± 10761
)1226070
ns/iter (± 12413
)1.02
arith_agg-avg_distinct-count_distinct-min_distinct-max_distinct-sum_distinct-group_by
1537157
ns/iter (± 21402
)1562560
ns/iter (± 8900
)0.98
arith_agg-avg_distinct-count_distinct-min_distinct-max_distinct-sum_distinct-group_by-group_as
2109521
ns/iter (± 15943
)2142416
ns/iter (± 9792
)0.98
parse-1
4302
ns/iter (± 69
)4249
ns/iter (± 15
)1.01
parse-15
39811
ns/iter (± 222
)38868
ns/iter (± 402
)1.02
parse-30
79992
ns/iter (± 499
)75578
ns/iter (± 10744
)1.06
compile-1
4462
ns/iter (± 21
)4355
ns/iter (± 26
)1.02
compile-15
32043
ns/iter (± 180
)32542
ns/iter (± 178
)0.98
compile-30
64769
ns/iter (± 271
)66497
ns/iter (± 420
)0.97
plan-1
65654
ns/iter (± 458
)65369
ns/iter (± 217
)1.00
plan-15
1020884
ns/iter (± 27825
)1016409
ns/iter (± 38498
)1.00
plan-30
2042760
ns/iter (± 17083
)2052512
ns/iter (± 13028
)1.00
eval-1
13009758
ns/iter (± 289446
)13391126
ns/iter (± 150215
)0.97
eval-15
86227676
ns/iter (± 929942
)85921655
ns/iter (± 2375249
)1.00
eval-30
165768763
ns/iter (± 809202
)164438426
ns/iter (± 2221754
)1.01
join
9723
ns/iter (± 96
)9623
ns/iter (± 492
)1.01
simple
2498
ns/iter (± 10
)2451
ns/iter (± 17
)1.02
simple-no
435
ns/iter (± 1
)437
ns/iter (± 3
)1.00
numbers
57
ns/iter (± 0
)58
ns/iter (± 3
)0.98
parse-simple
618
ns/iter (± 2
)624
ns/iter (± 2
)0.99
parse-ion
1890
ns/iter (± 8
)1802
ns/iter (± 16
)1.05
parse-group
5822
ns/iter (± 23
)5628
ns/iter (± 11
)1.03
parse-complex
14946
ns/iter (± 184
)14538
ns/iter (± 46
)1.03
parse-complex-fexpr
21988
ns/iter (± 77
)21356
ns/iter (± 70
)1.03
This comment was automatically generated by workflow using github-action-benchmark.