Skip to content

Commit

Permalink
fix(interactive): Fix bug of IS_NULL check for edge property (#4386)
Browse files Browse the repository at this point in the history
Fix #4384
  • Loading branch information
zhanglei1949 authored Dec 25, 2024
1 parent c38dd7d commit 9699556
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions flex/engines/graph_db/runtime/adhoc/expr_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ RTAny UnaryLogicalExpr::eval_edge(const LabelTriplet& label, vid_t src,
if (logic_ == common::Logical::NOT) {
return RTAny::from_bool(
!expr_->eval_edge(label, src, dst, data, idx).as_bool());
} else if (logic_ == common::Logical::ISNULL) {
return RTAny::from_bool(
expr_->eval_edge(label, src, dst, data, idx, 0).is_null());
}
LOG(FATAL) << "not support" << static_cast<int>(logic_);
return RTAny::from_bool(false);
Expand Down
4 changes: 4 additions & 0 deletions flex/engines/graph_db/runtime/common/rt_any.cc
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ RTAny::RTAny(const Any& val) {
} else if (val.type == PropertyType::Bool()) {
type_ = RTAnyType::kBoolValue;
value_.b_val = val.AsBool();
} else if (val.type == PropertyType::Empty()) {
type_ = RTAnyType::kNull;
} else {
LOG(FATAL) << "Any value: " << val.to_string()
<< ", type = " << val.type.type_enum;
Expand Down Expand Up @@ -355,6 +357,8 @@ std::string_view RTAny::as_string() const {
return value_.str_val;
} else if (type_ == RTAnyType::kUnknown) {
return std::string_view();
} else if (type_ == RTAnyType::kNull) {
return std::string_view();
} else {
LOG(FATAL) << "unexpected type" << static_cast<int>(type_.type_enum_);
return std::string_view();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,4 +399,10 @@ public static QueryContext get_movie_query28_test() {
List<String> expected = Arrays.asList("Record<{typeA: \"Person\", typeC: \"Movie\"}>");
return new QueryContext(query, expected);
}

public static QueryContext get_movie_query29_test() {
String query = "MATCH(a)-[r]->(b) where r.rating is null return count(r) as count;";
List<String> expected = Arrays.asList("Record<{count: 249}>");
return new QueryContext(query, expected);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,13 @@ public void run_movie_query28_test() {
Assert.assertEquals(testQuery.getExpectedResult().toString(), result.list().toString());
}

@Test
public void run_movie_query29_test() {
QueryContext testQuery = MovieQueries.get_movie_query29_test();
Result result = session.run(testQuery.getQuery());
Assert.assertEquals(testQuery.getExpectedResult().toString(), result.list().toString());
}

@AfterClass
public static void afterClass() {
if (session != null) {
Expand Down

0 comments on commit 9699556

Please sign in to comment.