@@ -23,6 +23,7 @@ use petgraph::visit::EdgeRef;
23
23
use unicase:: UniCase ;
24
24
25
25
use crate :: eval:: evaluable:: { EvalType , Evaluable } ;
26
+ use crate :: plan:: EvaluationMode ;
26
27
27
28
pub ( crate ) mod eval_expr_wrapper;
28
29
pub mod evaluable;
@@ -31,11 +32,14 @@ pub mod expr;
31
32
/// Represents a PartiQL evaluation query plan which is a plan that can be evaluated to produce
32
33
/// a result. The plan uses a directed `petgraph::StableGraph`.
33
34
#[ derive( Debug ) ]
34
- pub struct EvalPlan ( pub StableGraph < Box < dyn Evaluable > , u8 , Directed > ) ;
35
+ pub struct EvalPlan {
36
+ mode : EvaluationMode ,
37
+ plan_graph : StableGraph < Box < dyn Evaluable > , u8 , Directed > ,
38
+ }
35
39
36
40
impl Default for EvalPlan {
37
41
fn default ( ) -> Self {
38
- Self :: new ( )
42
+ Self :: new ( EvaluationMode :: Permissive , Default :: default ( ) )
39
43
}
40
44
}
41
45
@@ -48,13 +52,16 @@ fn err_illegal_state(msg: impl AsRef<str>) -> EvalErr {
48
52
49
53
impl EvalPlan {
50
54
/// Creates a new evaluation plan.
51
- fn new ( ) -> Self {
52
- EvalPlan ( StableGraph :: < Box < dyn Evaluable > , u8 , Directed > :: new ( ) )
55
+ pub fn new (
56
+ mode : EvaluationMode ,
57
+ plan_graph : StableGraph < Box < dyn Evaluable > , u8 , Directed > ,
58
+ ) -> Self {
59
+ EvalPlan { mode, plan_graph }
53
60
}
54
61
55
62
#[ inline]
56
63
fn plan_graph ( & mut self ) -> & mut StableGraph < Box < dyn Evaluable > , u8 > {
57
- & mut self . 0
64
+ & mut self . plan_graph
58
65
}
59
66
60
67
#[ inline]
@@ -73,7 +80,7 @@ impl EvalPlan {
73
80
// that all v ∈ V \{v0} are reachable from v0. Note that this is the definition of trees
74
81
// without the condition |E| = |V | − 1. Hence, all trees are DAGs.
75
82
// Reference: https://link.springer.com/article/10.1007/s00450-009-0061-0
76
- let ops = toposort ( & self . 0 , None ) . map_err ( |e| EvalErr {
83
+ let ops = toposort ( & self . plan_graph , None ) . map_err ( |e| EvalErr {
77
84
errors : vec ! [ EvaluationError :: InvalidEvaluationPlan ( format!(
78
85
"Malformed evaluation plan detected: {e:?}"
79
86
) ) ] ,
@@ -101,7 +108,7 @@ impl EvalPlan {
101
108
result = Some ( src. evaluate ( ctx) ) ;
102
109
103
110
// return on first evaluation error
104
- if ctx. has_errors ( ) {
111
+ if ctx. has_errors ( ) && self . mode == EvaluationMode :: Strict {
105
112
return Err ( EvalErr {
106
113
errors : ctx. errors ( ) ,
107
114
} ) ;
@@ -127,7 +134,7 @@ impl EvalPlan {
127
134
}
128
135
129
136
pub fn to_dot_graph ( & self ) -> String {
130
- format ! ( "{:?}" , Dot :: with_config( & self . 0 , & [ ] ) )
137
+ format ! ( "{:?}" , Dot :: with_config( & self . plan_graph , & [ ] ) )
131
138
}
132
139
}
133
140
0 commit comments