Skip to content

Commit

Permalink
Merge pull request #150 from cwida/148-edge-table-not-found-in-weakly…
Browse files Browse the repository at this point in the history
…_connected_component-function

Improved error messages for incorrect labels
  • Loading branch information
Dtenwolde committed Sep 13, 2024
2 parents 93a49ea + a84c676 commit 13613dd
Show file tree
Hide file tree
Showing 4 changed files with 319 additions and 305 deletions.
2 changes: 1 addition & 1 deletion duckdb-pgq
4 changes: 2 additions & 2 deletions src/core/utils/duckpgq_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ CreatePropertyGraphInfo* GetPropertyGraphInfo(const shared_ptr<DuckPGQState> &du

// Function to validate the source node and edge table
shared_ptr<PropertyGraphTable> ValidateSourceNodeAndEdgeTable(CreatePropertyGraphInfo *pg_info, const std::string &node_table, const std::string &edge_table) {
auto source_node_pg_entry = pg_info->GetTable(node_table);
auto source_node_pg_entry = pg_info->GetTable(node_table, true, true);
if (!source_node_pg_entry->is_vertex_table) {
throw Exception(ExceptionType::INVALID, node_table + " is an edge table, expected a vertex table");
}
auto edge_pg_entry = pg_info->GetTable(edge_table);
auto edge_pg_entry = pg_info->GetTable(edge_table, true, false);
if (edge_pg_entry->is_vertex_table) {
throw Exception(ExceptionType::INVALID, edge_table + " is a vertex table, expected an edge table");
}
Expand Down
60 changes: 4 additions & 56 deletions test/sql/scalar/local_clustering_coefficient.test
Original file line number Diff line number Diff line change
Expand Up @@ -68,58 +68,6 @@ EDGE TABLES (
DESTINATION KEY ( dst ) REFERENCES Student ( id )
);



#
#query II
#WITH cte1 AS (
# SELECT CREATE_CSR_EDGE(
# 0,
# (SELECT count(a.id) FROM Student a),
# CAST (
# (SELECT sum(CREATE_CSR_VERTEX(
# 0,
# (SELECT count(a.id) FROM Student a),
# sub.dense_id,
# sub.cnt)
# ) * 2
# FROM (
# SELECT dense_id, count(*) as cnt FROM (
# SELECT dense_id, outgoing_edge, incoming_edge
# FROM (
# SELECT a.rowid AS dense_id, k.src AS outgoing_edge, k.dst AS incoming_edge
# FROM Student a
# JOIN Know k ON k.src = a.id
# UNION ALL
# SELECT a.rowid AS dense_id, k.dst AS outgoing_edge, k.src AS incoming_edge
# FROM Student a
# JOIN know k on k.dst = a.id)
# GROUP BY dense_id, outgoing_edge, incoming_edge)
# GROUP BY dense_id) sub
# )
# AS BIGINT),
# src,
# dst,
# edge) as temp FROM (
# select src, dst, any_value(edge) as edge FROM (
# select a.rowid as src, c.rowid as dst, k.rowid as edge FROM Know k
# JOIN Student a on a.id = k.src
# JOIN Student c on c.id = k.dst
# UNION ALL
# select a.rowid as src, c.rowid as dst, k.rowid as edge FROM Know k
# JOIN Student a on a.id = k.dst
# JOIN Student c on c.id = k.src)
# GROUP BY src, dst)
#) SELECT __x.temp + local_clustering_coefficient(0, a.rowid) as lcc, a.name
# FROM (select count(cte1.temp) * 0 as temp from cte1) __x, Student a
# ORDER BY lcc DESC;
#----
#1.0 Daniel
#1.0 Tavneet
#1.0 Gabor
#0.5 Peter
#0.0 David

query II
select id, local_clustering_coefficient from local_clustering_coefficient(pg, student, know);
----
Expand All @@ -146,22 +94,22 @@ Invalid Error: Property graph pgdoesnotexist not found
statement error
select local_clustering_coefficient from local_clustering_coefficient(pg, a, know), student a where a.id = lcc.id;
----
Invalid Error: Table a not found in property graph pg
Invalid Error: Label 'a' not found. Did you mean the vertex label 'foo'?

statement error
select local_clustering_coefficient from local_clustering_coefficient(pg, student, b), student a where a.id = lcc.id;
----
Invalid Error: Table b not found in property graph pg
Invalid Error: Label 'b' not found. Did you mean the edge label 'know'?

statement error
select local_clustering_coefficient from local_clustering_coefficient(pg, foo, student), student a where a.id = lcc.id;
----
Invalid Error: student is a vertex table, expected an edge table
Invalid Error: Exact label 'student' found, but it is not a edge table.

statement error
select local_clustering_coefficient from local_clustering_coefficient(pg, student, foo), student a where a.id = lcc.id;
----
Invalid Error: foo is a vertex table, expected an edge table
Invalid Error: Exact label 'foo' found, but it is not a edge table.

statement ok
import database 'duckdb-pgq/data/SNB0.003';
Expand Down
Loading

0 comments on commit 13613dd

Please sign in to comment.