Skip to content

Commit

Permalink
minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
BingqingLyu committed Aug 21, 2023
1 parent 6616b75 commit a7880b2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
5 changes: 5 additions & 0 deletions docs/interactive_engine/tinkerpop/supported_gremlin_steps.md
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,11 @@ gremlin> g.V().as("a").where(expr("@a.name == \"marko\" || (@a.age > 10)"))
gremlin> g.V().where(expr("@.age isNull")).values("name")
==>ripple
==>lop
gremlin> g.V().where(expr("!(@.age isNull)")).values("name")
==>marko
==>vadas
==>josh
==>peter
gremlin> g.V().select(expr("@.name"))
==>marko
==>vadas
Expand Down
25 changes: 13 additions & 12 deletions interactive_engine/executor/ir/graph_proxy/src/utils/expr/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,26 +239,25 @@ impl Evaluator {
let first = _first.unwrap();
let second = _second.unwrap();
let third = _third.unwrap();

if let InnerOpr::Logical(logical) = third {
// to deal with two unary operators cases, e.g., !(!true), !(a isNull) etc.
if common_pb::Logical::Not.eq(logical) || common_pb::Logical::Isnull.eq(logical) {
if let InnerOpr::Logical(inner_logical) = second {
let first = match first.eval(context) {
Ok(first) => Ok(first),
Err(err) => match err {
ExprEvalError::GetNoneFromContext => Ok(Object::None),
_ => Err(err),
},
};
let mut outer_first = Ok(apply_logical(inner_logical, first?.as_borrow(), None)?);
let mut inner_first = first.eval(context);
if common_pb::Logical::Isnull.eq(inner_logical) {
match outer_first {
Err(ExprEvalError::GetNoneFromContext) => outer_first = Ok(Object::None),
match inner_first {
Err(ExprEvalError::GetNoneFromContext) => inner_first = Ok(Object::None),
_ => {}
}
}
let mut first = Ok(apply_logical(inner_logical, inner_first?.as_borrow(), None)?);
if common_pb::Logical::Isnull.eq(logical) {
match first {
Err(ExprEvalError::GetNoneFromContext) => first = Ok(Object::None),
_ => {}
}
}
return Ok(apply_logical(logical, outer_first?.as_borrow(), None)?);
return Ok(apply_logical(logical, first?.as_borrow(), None)?);
}
}
let a = first.eval(context)?;
Expand Down Expand Up @@ -980,6 +979,7 @@ mod tests {
"@0.hobbies == null", // false
"true isNull", // false
"false isNull", // false
"!true isNull", // i.e., !(true isNull), false
"@1.hobbies isNull && @1.age == 26", // true
];
let expected: Vec<Object> = vec![
Expand All @@ -990,6 +990,7 @@ mod tests {
object!(false),
object!(false),
object!(false),
object!(false),
object!(true),
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -513,10 +513,7 @@ pub enum PEvaluator {
impl EvalPred for PEvaluator {
fn eval_bool<E: Element, C: Context<E>>(&self, context: Option<&C>) -> ExprEvalResult<bool> {
let result = match self {
PEvaluator::Predicates(pred) => {
println!("eval by predicates {:?}", pred);
pred.eval_bool(context)
}
PEvaluator::Predicates(pred) => pred.eval_bool(context),
PEvaluator::General(eval) => eval.eval_bool(context),
};
match result {
Expand Down

0 comments on commit a7880b2

Please sign in to comment.