From a602172e9c9f5782a0bd5c3b0012976e68647b11 Mon Sep 17 00:00:00 2001 From: dtenwolde Date: Mon, 3 Jul 2023 16:33:33 +0200 Subject: [PATCH 1/4] Dropping a non-existing property graph now correctly throws an error --- .../functions/tablefunctions/create_property_graph.cpp | 2 +- .../functions/tablefunctions/drop_property_graph.cpp | 8 ++++++-- test/sql/drop_property_graph.test | 10 ++++++++++ test/sql/shortest_path.test | 2 +- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/duckpgq/src/duckpgq/functions/tablefunctions/create_property_graph.cpp b/duckpgq/src/duckpgq/functions/tablefunctions/create_property_graph.cpp index 31c502cb..cee179ff 100644 --- a/duckpgq/src/duckpgq/functions/tablefunctions/create_property_graph.cpp +++ b/duckpgq/src/duckpgq/functions/tablefunctions/create_property_graph.cpp @@ -53,7 +53,7 @@ namespace duckdb { duckdb::unique_ptr CreatePropertyGraphFunction::CreatePropertyGraphBind(ClientContext &context, TableFunctionBindInput &input, vector &return_types, vector &names) { - names.emplace_back("success"); + names.emplace_back("status"); return_types.emplace_back(LogicalType::VARCHAR); auto lookup = context.registered_state.find("duckpgq"); if (lookup == context.registered_state.end()) { diff --git a/duckpgq/src/duckpgq/functions/tablefunctions/drop_property_graph.cpp b/duckpgq/src/duckpgq/functions/tablefunctions/drop_property_graph.cpp index eabdd462..b2a65895 100644 --- a/duckpgq/src/duckpgq/functions/tablefunctions/drop_property_graph.cpp +++ b/duckpgq/src/duckpgq/functions/tablefunctions/drop_property_graph.cpp @@ -8,7 +8,7 @@ namespace duckdb { TableFunctionBindInput &, vector &return_types, vector &names) { - names.emplace_back("success"); + names.emplace_back("status"); return_types.emplace_back(LogicalType::VARCHAR); auto lookup = context.registered_state.find("duckpgq"); if (lookup == context.registered_state.end()) { @@ -39,7 +39,11 @@ namespace duckdb { throw BinderException("Registered DuckPGQ state not found"); } auto duckpgq_state = (DuckPGQState *)lookup->second.get(); - duckpgq_state->registered_property_graphs.erase(pg_info->name); + auto registered_pg = duckpgq_state->registered_property_graphs.find(pg_info->name); + if (registered_pg == duckpgq_state->registered_property_graphs.end()) { + throw BinderException("Property graph %s does not exist.", pg_info->name); + } + duckpgq_state->registered_property_graphs.erase(registered_pg); } } diff --git a/test/sql/drop_property_graph.test b/test/sql/drop_property_graph.test index c15af292..ff9917b0 100644 --- a/test/sql/drop_property_graph.test +++ b/test/sql/drop_property_graph.test @@ -48,6 +48,16 @@ EDGE TABLES ( statement ok -DROP PROPERTY GRAPH pg; +statement error +-DROP PROPERTY GRAPH pg; +---- +Binder Error: Property graph pg does not exist + +statement error +-DROP PROPERTY GRAPH pgdoesntexist; +---- +Binder Error: Property graph pgdoesntexist does not exist + statement error -SELECT study.id FROM GRAPH_TABLE (pg diff --git a/test/sql/shortest_path.test b/test/sql/shortest_path.test index 87c3f77e..bbd1acb7 100644 --- a/test/sql/shortest_path.test +++ b/test/sql/shortest_path.test @@ -55,7 +55,7 @@ query II ---- Daniel VU -# Returns erroreous results https://github.com/cwida/duckpgq-extension/issues/9 +# Returns erroneous results https://github.com/cwida/duckpgq-extension/issues/9 #query II #-FROM GRAPH_TABLE (pg # MATCH From ef676e65924ab092a7e9fd1d29b3017fb45db354 Mon Sep 17 00:00:00 2001 From: dtenwolde Date: Tue, 4 Jul 2023 10:20:26 +0200 Subject: [PATCH 2/4] Adding order by Reverted planner logic to align with DuckDB --- .../functions/tablefunctions/drop_property_graph.cpp | 1 + test/sql/basic_match.test | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/duckpgq/src/duckpgq/functions/tablefunctions/drop_property_graph.cpp b/duckpgq/src/duckpgq/functions/tablefunctions/drop_property_graph.cpp index b2a65895..d51e023f 100644 --- a/duckpgq/src/duckpgq/functions/tablefunctions/drop_property_graph.cpp +++ b/duckpgq/src/duckpgq/functions/tablefunctions/drop_property_graph.cpp @@ -44,6 +44,7 @@ namespace duckdb { throw BinderException("Property graph %s does not exist.", pg_info->name); } duckpgq_state->registered_property_graphs.erase(registered_pg); + } } diff --git a/test/sql/basic_match.test b/test/sql/basic_match.test index 8d98abaf..7b2adcb5 100644 --- a/test/sql/basic_match.test +++ b/test/sql/basic_match.test @@ -179,13 +179,14 @@ FROM GRAPH_TABLE (pg MATCH (a:Person)-[k:Knows]->(b:Person)-[k2:Knows]->(c:Person)-[k3:Knows]->(a:Person) COLUMNS (a.name as a_name, b.name as b_name, c.name as c_name) - ) study; + ) study +ORDER BY study.a_name; ---- -Peter Daniel Tavneet -Peter Daniel Gabor Daniel Tavneet Peter -Gabor Peter Daniel Daniel Gabor Peter +Gabor Peter Daniel +Peter Daniel Gabor +Peter Daniel Tavneet Tavneet Peter Daniel statement error From 31fdee6b56f72b11587048861044785bdf49adfd Mon Sep 17 00:00:00 2001 From: dtenwolde Date: Tue, 4 Jul 2023 10:20:28 +0200 Subject: [PATCH 3/4] Adding order by Reverted planner logic to align with DuckDB --- duckdb-pgq | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/duckdb-pgq b/duckdb-pgq index 895d8053..7d68352f 160000 --- a/duckdb-pgq +++ b/duckdb-pgq @@ -1 +1 @@ -Subproject commit 895d80537efd47746bcdce7b99a8eb8672ab6a97 +Subproject commit 7d68352f0cf03bf1389c8398b1df6c92101c52c8 From 9db0f6f479186c05c00e901d50ffcbd745020a0c Mon Sep 17 00:00:00 2001 From: dtenwolde Date: Tue, 4 Jul 2023 11:30:22 +0200 Subject: [PATCH 4/4] Updating with order --- test/sql/basic_match.test | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/sql/basic_match.test b/test/sql/basic_match.test index 8d642844..fa18f002 100644 --- a/test/sql/basic_match.test +++ b/test/sql/basic_match.test @@ -180,10 +180,10 @@ FROM GRAPH_TABLE (pg (a:Person)-[k:Knows]->(b:Person)-[k2:Knows]->(c:Person)-[k3:Knows]->(a:Person) COLUMNS (a.name as a_name, b.name as b_name, c.name as c_name) ) study -ORDER BY study.a_name; +ORDER BY study.a_name, study.b_name, study.c_name; ---- -Daniel Tavneet Peter Daniel Gabor Peter +Daniel Tavneet Peter Gabor Peter Daniel Peter Daniel Gabor Peter Daniel Tavneet