diff --git a/src/core/functions/scalar/iterativelength.cpp b/src/core/functions/scalar/iterativelength.cpp index a6899d7a..a195c67c 100644 --- a/src/core/functions/scalar/iterativelength.cpp +++ b/src/core/functions/scalar/iterativelength.cpp @@ -53,7 +53,7 @@ static void IterativeLengthFunction(DataChunk &args, ExpressionState &state, "Need to initialize CSR before doing shortest path"); } - if (!(csr_entry->second->initialized_v && csr_entry->second->initialized_e)) { + if (!csr_entry->second->initialized_v) { throw ConstraintException( "Need to initialize CSR before doing shortest path"); } diff --git a/src/core/functions/scalar/shortest_path.cpp b/src/core/functions/scalar/shortest_path.cpp index 3a9d592f..b70f35e9 100644 --- a/src/core/functions/scalar/shortest_path.cpp +++ b/src/core/functions/scalar/shortest_path.cpp @@ -56,12 +56,24 @@ static void ShortestPathFunction(DataChunk &args, ExpressionState &state, auto duckpgq_state = GetDuckPGQState(info.context); D_ASSERT(duckpgq_state->csr_list[info.csr_id]); + auto csr_entry = duckpgq_state->csr_list.find(info.csr_id); + if (csr_entry == duckpgq_state->csr_list.end()) { + throw ConstraintException("Invalid ID"); + } + auto &csr = csr_entry->second; + + + if (!csr->initialized_v) { + throw ConstraintException( + "Need to initialize CSR before doing shortest path"); + } + int32_t id = args.data[0].GetValue(0).GetValue(); int64_t v_size = args.data[1].GetValue(0).GetValue(); - int64_t *v = (int64_t *)duckpgq_state->csr_list[id]->v; - vector &e = duckpgq_state->csr_list[id]->e; - vector &edge_ids = duckpgq_state->csr_list[id]->edge_ids; + auto *v = (int64_t *)csr->v; + vector &e = csr->e; + vector &edge_ids = csr->edge_ids; auto &src = args.data[2]; auto &target = args.data[3]; diff --git a/test/sql/path_finding/edgeless_graph.test b/test/sql/path_finding/edgeless_graph.test index ab341e70..ec613d71 100644 --- a/test/sql/path_finding/edgeless_graph.test +++ b/test/sql/path_finding/edgeless_graph.test @@ -21,8 +21,12 @@ statement ok LABEL E ); -statement ok +query II -FROM GRAPH_TABLE(testgraph MATCH p = ANY SHORTEST (n1:N)-[e:E]-> * (n2:N) - COLUMNS (edges(p) AS path_edges) -); \ No newline at end of file + COLUMNS (n1.id, edges(p) AS path_edges) +); +---- +1 [] +2 [] +3 [] \ No newline at end of file