Skip to content

Commit

Permalink
LabelScan with child reads data correctly after reset (RedisGraph#1086)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreylovitz committed Apr 30, 2020
1 parent d022617 commit 8bd07b1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
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)

0 comments on commit 8bd07b1

Please sign in to comment.