Skip to content

Commit

Permalink
Add error handling and check output of test
Browse files Browse the repository at this point in the history
  • Loading branch information
Dtenwolde committed Nov 14, 2024
1 parent 990276d commit cc805f2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/core/functions/scalar/iterativelength.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
18 changes: 15 additions & 3 deletions src/core/functions/scalar/shortest_path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int32_t>();
int64_t v_size = args.data[1].GetValue(0).GetValue<int64_t>();

int64_t *v = (int64_t *)duckpgq_state->csr_list[id]->v;
vector<int64_t> &e = duckpgq_state->csr_list[id]->e;
vector<int64_t> &edge_ids = duckpgq_state->csr_list[id]->edge_ids;
auto *v = (int64_t *)csr->v;
vector<int64_t> &e = csr->e;
vector<int64_t> &edge_ids = csr->edge_ids;

auto &src = args.data[2];
auto &target = args.data[3];
Expand Down
10 changes: 7 additions & 3 deletions test/sql/path_finding/edgeless_graph.test
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);
COLUMNS (n1.id, edges(p) AS path_edges)
);
----
1 []
2 []
3 []

0 comments on commit cc805f2

Please sign in to comment.