Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LabelScan with child reads data correctly after reset #1086

Merged
merged 1 commit into from
Apr 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/execution_plan/ops/op_node_by_label_scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,12 @@ static Record NodeByLabelScanConsumeFromChild(OpBase *opBase) {
/* depleted will be true in the following cases:
* 1. No iterator: GxB_MatrixTupleIter_next will fail and depleted will stay true. This scenario means
* that there was no consumption of a record from a child, otherwise there was an iterator.
* 2. Iterator depleted - For every child record the iterator finished the entire matrix scan and it needs to restart. */
while(depleted) {
* 2. Iterator depleted - For every child record the iterator finished the entire matrix scan and it needs to restart.
* The child record will be NULL if this is the op's first invocation or it has just been reset, in which case we
* should also enter this loop. */
while(depleted || op->child_record == NULL) {
// Try to get a record.
if(op->child_record) OpBase_DeleteRecord(op->child_record);
op->child_record = NULL;
op->child_record = OpBase_Consume(op->op.children[0]);
if(op->child_record == NULL) return NULL;

Expand Down
25 changes: 25 additions & 0 deletions tests/flow/test_path_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,3 +222,28 @@ def test10_verify_apply_results(self):
# Each source node should be returned exactly once.
expected_results = [['a'], ['b']]
self.env.assertEquals(result_set.result_set, expected_results)

def test11_unbound_path_filters(self):
# Build a graph with 2 nodes connected by 1 edge.
node0 = Node(node_id=0, label="L", properties={'x': 'a'})
node1 = Node(node_id=1, label="L", properties={'x': 'b'})
edge01 = Edge(src_node=node0, dest_node=node1, relation="R")
redis_graph.add_node(node0)
redis_graph.add_node(node1)
redis_graph.add_edge(edge01)
redis_graph.flush()

# Emit a query that uses an AntiSemiApply op to return values.
query = "MATCH (n:L) WHERE NOT (:L)-[]->() RETURN n.x ORDER BY n.x"
result_set = redis_graph.query(query)
# The WHERE filter evaluates to false, no results should be returned.
expected_result = []
self.env.assertEquals(result_set.result_set, expected_result)

# Emit a query that uses a SemiApply op to return values.
query = "MATCH (n:L) WHERE (:L)-[]->() RETURN n.x ORDER BY n.x"
result_set = redis_graph.query(query)
# The WHERE filter evaluates to true, all results should be returned.
expected_result = [['a'],
['b']]
self.env.assertEquals(result_set.result_set, expected_result)