Skip to content
Snippets Groups Projects
Unverified Commit 4f841029 authored by kyle.cao's avatar kyle.cao Committed by GitHub
Browse files

Fix filter bug (#446)

* fix filter bug

* Add test_multi_edges_with_filter

* modify error message

* fix test
parent 452335d9
No related branches found
No related tags found
No related merge requests found
......@@ -33,11 +33,11 @@ folly::Future<Status> FilterExecutor::execute() {
auto condition = filter->condition();
while (iter->valid()) {
auto val = condition->eval(ctx(iter.get()));
if (!val.isBool() && !val.isNull()) {
if (!val.empty() && !val.isBool() && !val.isNull()) {
return Status::Error("Internal Error: Wrong type result, "
"should be NULL type or BOOL type");
"the type should be NULL,EMPTY or BOOL");
}
if (val.isNull() || !val.getBool()) {
if (val.empty() || val.isNull() || !val.getBool()) {
iter->erase();
} else {
iter->next();
......
......@@ -566,6 +566,64 @@ class TestGoQuery(NebulaTestSuite):
}
self.check_out_of_order_result(resp, expected_data["rows"])
def test_multi_edges_with_filter(self):
stmt = '''GO FROM "Russell Westbrook" OVER serve, like WHERE serve.start_year > 2000 \
YIELD serve.start_year, like.likeness'''
resp = self.execute(stmt)
self.check_resp_succeeded(resp)
expected_data = {
"column_names": [],
"rows": [
[2008, T_EMPTY]
]
}
self.check_out_of_order_result(resp, expected_data["rows"])
stmt = '''GO FROM "Manu Ginobili" OVER like, teammate REVERSELY WHERE like.likeness > 90 YIELD like.likeness, \
teammate.start_year, $$.player.name'''
resp = self.execute(stmt)
self.check_resp_succeeded(resp)
expected_data = {
"column_names": [],
"rows": [
[95, T_EMPTY, "Tim Duncan"],
[95, T_EMPTY, "Tony Parker"],
[99, T_EMPTY, "Dejounte Murray"]
]
}
self.check_out_of_order_result(resp, expected_data["rows"])
stmt = '''GO FROM "Manu Ginobili" OVER * \
WHERE $$.player.age > 30 or $$.team.name not starts with "Rockets" \
YIELD DISTINCT $$.player.age, $$.player.name, $$.team.name'''
resp = self.execute(stmt)
self.check_resp_succeeded(resp)
expected_data = {
"column_names": [],
"rows": [
[T_EMPTY, T_EMPTY, "Spurs"],
[42, "Tim Duncan", T_EMPTY],
[36, "Tony Parker",T_EMPTY]
]
}
self.check_out_of_order_result(resp, expected_data["rows"])
stmt = '''GO FROM "Manu Ginobili" OVER like, teammate REVERSELY \
WHERE $$.player.age > 30 and $$.player.age < 40 \
YIELD DISTINCT $$.player.age, $$.player.name'''
resp = self.execute(stmt)
self.check_resp_succeeded(resp)
expected_data = {
"column_names": [],
"rows": [
[34, "Tiago Splitter"],
[36, "Tony Parker"]
]
}
self.check_out_of_order_result(resp, expected_data["rows"])
def test_reference_pipe_in_yieldandwhere(self):
stmt = '''GO FROM 'Tim Duncan', 'Chris Paul' OVER like \
YIELD $^.player.name AS name, like._dst AS id \
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment