From 150ff7d90b4488986809faa6c5872adc47a55416 Mon Sep 17 00:00:00 2001 From: dtenwolde Date: Fri, 7 Jun 2024 13:27:09 +0200 Subject: [PATCH 1/9] Allow multiple graph tables inside single query --- src/duckpgq_extension.cpp | 14 +- src/functions/tablefunctions/match.cpp | 12 +- src/include/duckpgq_extension.hpp | 8 +- test/sql/multiple_graph_table.test | 171 +++++++++++++++++++++++ test/sql/multiple_graph_table_error.test | 45 ------ 5 files changed, 191 insertions(+), 59 deletions(-) create mode 100644 test/sql/multiple_graph_table.test delete mode 100644 test/sql/multiple_graph_table_error.test diff --git a/src/duckpgq_extension.cpp b/src/duckpgq_extension.cpp index a8de89da..35c46eaa 100644 --- a/src/duckpgq_extension.cpp +++ b/src/duckpgq_extension.cpp @@ -89,7 +89,7 @@ ParserExtensionParseResult duckpgq_parse(ParserExtensionInfo *info, : query); if (parser.statements.size() != 1) { throw Exception(ExceptionType::PARSER, - "More than 1 statement detected, please only give one."); + "More than one statement detected, please only give one."); } return ParserExtensionParseResult(make_uniq_base( std::move(parser.statements[0]))); @@ -119,15 +119,11 @@ void duckpgq_find_match_function(TableRef *table_ref, // Handle TableFunctionRef case auto function = dynamic_cast(table_function_ref->function.get()); - if (function->function_name == "duckpgq_match") { - if (duckpgq_state.transform_expression != nullptr) { - throw Exception(ExceptionType::INVALID, - "Multiple graph tables in a single query are not supported yet"); - } - duckpgq_state.transform_expression = - std::move(std::move(function->children[0])); - function->children.pop_back(); + if (function->function_name != "duckpgq_match") { + return; } + duckpgq_state.transform_expression.push_back(std::move(function->children[0])); + function->children.pop_back(); } else if (auto join_ref = dynamic_cast(table_ref)) { // Handle JoinRef case duckpgq_find_match_function(join_ref->left.get(), duckpgq_state); diff --git a/src/functions/tablefunctions/match.cpp b/src/functions/tablefunctions/match.cpp index cd93baef..d1ebf0f3 100644 --- a/src/functions/tablefunctions/match.cpp +++ b/src/functions/tablefunctions/match.cpp @@ -943,11 +943,9 @@ PGQMatchFunction::MatchBindReplace(ClientContext &context, dynamic_cast(duckpgq_state_entry->second.get()); auto ref = dynamic_cast( - duckpgq_state->transform_expression.get()); + duckpgq_state->transform_expression[0].get()); auto pg_table = duckpgq_state->GetPropertyGraph(ref->pg_name); - auto data = make_uniq(); - vector> conditions; auto select_node = make_uniq(); @@ -1040,8 +1038,16 @@ PGQMatchFunction::MatchBindReplace(ClientContext &context, auto subquery = make_uniq(); subquery->node = std::move(select_node); + if (ref->alias == "unnamed_graphtable") { + if (duckpgq_state->unnamed_graphtable_index > 1) { + ref->alias = "unnamed_graphtable" + + std::to_string(duckpgq_state->unnamed_graphtable_index); + } + duckpgq_state->unnamed_graphtable_index++; + } auto result = make_uniq(std::move(subquery), ref->alias); + duckpgq_state->transform_expression.erase(duckpgq_state->transform_expression.begin()); return std::move(result); } } // namespace duckdb diff --git a/src/include/duckpgq_extension.hpp b/src/include/duckpgq_extension.hpp index bec5ff6c..d9fe0e04 100644 --- a/src/include/duckpgq_extension.hpp +++ b/src/include/duckpgq_extension.hpp @@ -79,7 +79,8 @@ class DuckPGQState : public ClientContextState { void QueryEnd() override { parse_data.reset(); - transform_expression = nullptr; + transform_expression.clear(); + unnamed_graphtable_index = 1; // Reset the index for (const auto &csr_id : csr_to_delete) { csr_list.erase(csr_id); } @@ -105,7 +106,10 @@ class DuckPGQState : public ClientContextState { public: unique_ptr parse_data; - unique_ptr transform_expression; + vector> transform_expression; + + int32_t unnamed_graphtable_index = 1; // Used to generate unique names for + // unnamed graph tables //! Property graphs that are registered std::unordered_map> registered_property_graphs; diff --git a/test/sql/multiple_graph_table.test b/test/sql/multiple_graph_table.test new file mode 100644 index 00000000..59dfd0e7 --- /dev/null +++ b/test/sql/multiple_graph_table.test @@ -0,0 +1,171 @@ +# name: test/sql/multiple_graph_table.test +# group: [duckpgq] + +require duckpgq + +statement ok +CREATE TABLE Student(id BIGINT, name VARCHAR);INSERT INTO Student VALUES (0, 'Daniel'), (1, 'Tavneet'), (2, 'Gabor'), (3, 'Peter'), (4, 'David'); + +statement ok +CREATE TABLE know(src BIGINT, dst BIGINT, createDate BIGINT);INSERT INTO know VALUES (0,1, 10), (0,2, 11), (0,3, 12), (3,0, 13), (1,2, 14), (1,3, 15), (2,3, 16), (4,3, 17); + +statement ok +CREATE TABLE School(name VARCHAR, Id BIGINT, Kind VARCHAR);INSERT INTO School VALUES ('VU', 0, 'University'), ('UVA', 1, 'University'); + +statement ok +CREATE TABLE StudyAt(personId BIGINT, schoolId BIGINT);INSERT INTO StudyAt VALUES (0, 0), (1, 0), (2, 1), (3, 1), (4, 1); + +statement ok +-CREATE PROPERTY GRAPH pg +VERTEX TABLES ( + Student, + School + ) +EDGE TABLES ( + know SOURCE KEY ( src ) REFERENCES Student ( id ) + DESTINATION KEY ( dst ) REFERENCES Student ( id ), + studyAt SOURCE KEY ( personId ) REFERENCES Student ( id ) + DESTINATION KEY ( SchoolId ) REFERENCES School ( id ) + ); + +query II +-select a.id, b.id FROM GRAPH_TABLE(pg MATCH (a:student)) a, GRAPH_TABLE(pg MATCH (b:student)) b; +---- +0 0 +0 1 +0 2 +0 3 +0 4 +1 0 +1 1 +1 2 +1 3 +1 4 +2 0 +2 1 +2 2 +2 3 +2 4 +3 0 +3 1 +3 2 +3 3 +3 4 +4 0 +4 1 +4 2 +4 3 +4 4 + +query II +-select unnamed_graphtable.id, unnamed_graphtable2.id FROM GRAPH_TABLE(pg MATCH (a:student)), GRAPH_TABLE(pg MATCH (b:student)); +---- +0 0 +0 1 +0 2 +0 3 +0 4 +1 0 +1 1 +1 2 +1 3 +1 4 +2 0 +2 1 +2 2 +2 3 +2 4 +3 0 +3 1 +3 2 +3 3 +3 4 +4 0 +4 1 +4 2 +4 3 +4 4 + + +query IIII +-select a.id, a.name, unnamed_graphtable.id, unnamed_graphtable.name FROM GRAPH_TABLE(pg MATCH (a:student)) a, GRAPH_TABLE(pg MATCH (b:student)-[r:know]->(c:student)); +---- +0 Daniel 1 Tavneet +0 Daniel 2 Gabor +0 Daniel 3 Peter +0 Daniel 0 Daniel +0 Daniel 2 Gabor +0 Daniel 3 Peter +0 Daniel 3 Peter +0 Daniel 3 Peter +1 Tavneet 1 Tavneet +1 Tavneet 2 Gabor +1 Tavneet 3 Peter +1 Tavneet 0 Daniel +1 Tavneet 2 Gabor +1 Tavneet 3 Peter +1 Tavneet 3 Peter +1 Tavneet 3 Peter +2 Gabor 1 Tavneet +2 Gabor 2 Gabor +2 Gabor 3 Peter +2 Gabor 0 Daniel +2 Gabor 2 Gabor +2 Gabor 3 Peter +2 Gabor 3 Peter +2 Gabor 3 Peter +3 Peter 1 Tavneet +3 Peter 2 Gabor +3 Peter 3 Peter +3 Peter 0 Daniel +3 Peter 2 Gabor +3 Peter 3 Peter +3 Peter 3 Peter +3 Peter 3 Peter +4 David 1 Tavneet +4 David 2 Gabor +4 David 3 Peter +4 David 0 Daniel +4 David 2 Gabor +4 David 3 Peter +4 David 3 Peter +4 David 3 Peter + + +query II +-select unnamed_subquery.id, unnamed_graphtable.id +FROM GRAPH_TABLE(pg MATCH (a:student)), (select 1 as id); +---- +1 0 +1 1 +1 2 +1 3 +1 4 + +statement ok +CREATE TABLE cities ( +name VARCHAR, +lat DECIMAL, +lon DECIMAL +); + +statement ok +CREATE TABLE cities_are_adjacent ( +city1name VARCHAR, +city2name VARCHAR +); + +statement ok +-CREATE PROPERTY GRAPH citymap +VERTEX TABLES ( +cities PROPERTIES (name,lat,lon) LABEL city +) +EDGE TABLES ( +cities_are_adjacent SOURCE KEY ( city1name ) REFERENCES cities ( name ) +DESTINATION KEY ( city2name ) REFERENCES cities ( name ) +LABEL adjacent +); + +statement ok +-select * from GRAPH_TABLE (citymap MATCH (s:city)-[r:adjacent]->(t:city)) g1, GRAPH_TABLE (citymap MATCH (s:city)-[r:adjacent]->(t:city)) g2; + diff --git a/test/sql/multiple_graph_table_error.test b/test/sql/multiple_graph_table_error.test deleted file mode 100644 index eb04b3c0..00000000 --- a/test/sql/multiple_graph_table_error.test +++ /dev/null @@ -1,45 +0,0 @@ -# name: test/sql/sqlpgq/multiple_graph_table_error.test -# group: [duckpgq] - -require duckpgq - -statement ok -CREATE TABLE cities ( -name VARCHAR, -lat DECIMAL, -lon DECIMAL -); - -statement ok -CREATE TABLE cities_are_adjacent ( -city1name VARCHAR, -city2name VARCHAR -); - -statement ok --CREATE PROPERTY GRAPH citymap -VERTEX TABLES ( -cities PROPERTIES (name,lat,lon) LABEL city -) -EDGE TABLES ( -cities_are_adjacent SOURCE KEY ( city1name ) REFERENCES cities ( name ) -DESTINATION KEY ( city2name ) REFERENCES cities ( name ) -LABEL adjacent -); - -statement error --select * from GRAPH_TABLE (citymap MATCH (s:city)-[r:adjacent]->(t:city)) g1, GRAPH_TABLE (citymap MATCH (s:city)-[r:adjacent]->(t:city)) g2; ----- -Invalid Error: Multiple graph tables in a single query are not supported yet - -statement ok --FROM GRAPH_TABLE (citymap MATCH (s:city)-[r:adjacent]->(t:city)) g1; - -statement ok --FROM GRAPH_TABLE (citymap MATCH (s:city)-[r:adjacent]->(t:city)) g1; - -statement error --select * from GRAPH_TABLE (citymap MATCH (s:city)-[r:adjacent]->(t:city)) g1, GRAPH_TABLE (citymap MATCH (s:city)-[r:adjacent]->(t:city)) g2; ----- -Invalid Error: Multiple graph tables in a single query are not supported yet - From 24c66450755c6f31a6d8091c5b541f323abcce7f Mon Sep 17 00:00:00 2001 From: dtenwolde Date: Fri, 7 Jun 2024 13:39:22 +0200 Subject: [PATCH 2/9] Install package --- extension-ci-tools | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extension-ci-tools b/extension-ci-tools index 30c4e754..e2bedbe0 160000 --- a/extension-ci-tools +++ b/extension-ci-tools @@ -1 +1 @@ -Subproject commit 30c4e7549b08394d5a0e9f0219a09a58cac57c35 +Subproject commit e2bedbe03d9a0c1c8f06ece9fa65f901423a8124 From ed0dd45fccf24d790bd454a00c55c1d26e23d785 Mon Sep 17 00:00:00 2001 From: dtenwolde Date: Fri, 7 Jun 2024 13:52:48 +0200 Subject: [PATCH 3/9] Add --fix-missing flag instead of installing other package --- extension-ci-tools | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extension-ci-tools b/extension-ci-tools index e2bedbe0..945b3b35 160000 --- a/extension-ci-tools +++ b/extension-ci-tools @@ -1 +1 @@ -Subproject commit e2bedbe03d9a0c1c8f06ece9fa65f901423a8124 +Subproject commit 945b3b35dd3e4cb3a431d4ef2e3ce7cf82fe18a9 From f5ba8487717e6ea65ecc26219063850fbd6a75e4 Mon Sep 17 00:00:00 2001 From: dtenwolde Date: Fri, 7 Jun 2024 17:04:04 +0200 Subject: [PATCH 4/9] Trying with index --- src/functions/tablefunctions/match.cpp | 4 ++-- src/include/duckpgq_extension.hpp | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/functions/tablefunctions/match.cpp b/src/functions/tablefunctions/match.cpp index d1ebf0f3..caf4bff6 100644 --- a/src/functions/tablefunctions/match.cpp +++ b/src/functions/tablefunctions/match.cpp @@ -943,7 +943,8 @@ PGQMatchFunction::MatchBindReplace(ClientContext &context, dynamic_cast(duckpgq_state_entry->second.get()); auto ref = dynamic_cast( - duckpgq_state->transform_expression[0].get()); + duckpgq_state->transform_expression[duckpgq_state->match_index].get()); + duckpgq_state->match_index++; auto pg_table = duckpgq_state->GetPropertyGraph(ref->pg_name); vector> conditions; @@ -1047,7 +1048,6 @@ PGQMatchFunction::MatchBindReplace(ClientContext &context, } auto result = make_uniq(std::move(subquery), ref->alias); - duckpgq_state->transform_expression.erase(duckpgq_state->transform_expression.begin()); return std::move(result); } } // namespace duckdb diff --git a/src/include/duckpgq_extension.hpp b/src/include/duckpgq_extension.hpp index d9fe0e04..bd41c137 100644 --- a/src/include/duckpgq_extension.hpp +++ b/src/include/duckpgq_extension.hpp @@ -80,6 +80,7 @@ class DuckPGQState : public ClientContextState { void QueryEnd() override { parse_data.reset(); transform_expression.clear(); + match_index = 0; // Reset the index unnamed_graphtable_index = 1; // Reset the index for (const auto &csr_id : csr_to_delete) { csr_list.erase(csr_id); @@ -107,7 +108,7 @@ class DuckPGQState : public ClientContextState { unique_ptr parse_data; vector> transform_expression; - + int32_t match_index = 0; int32_t unnamed_graphtable_index = 1; // Used to generate unique names for // unnamed graph tables From 421b95b786cbf4db562e505c1601685659dc9819 Mon Sep 17 00:00:00 2001 From: dtenwolde Date: Mon, 17 Jun 2024 12:23:20 +0200 Subject: [PATCH 5/9] Change to a map --- src/duckpgq_extension.cpp | 7 ++++++- src/functions/tablefunctions/match.cpp | 5 ++--- src/include/duckpgq/functions/tablefunctions/match.hpp | 2 ++ src/include/duckpgq_extension.hpp | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/duckpgq_extension.cpp b/src/duckpgq_extension.cpp index 35c46eaa..1b00bb7b 100644 --- a/src/duckpgq_extension.cpp +++ b/src/duckpgq_extension.cpp @@ -12,6 +12,8 @@ #include "duckdb/parser/tableref/table_function_ref.hpp" #include "duckdb/parser/expression/function_expression.hpp" +#include "duckdb/parser/expression/constant_expression.hpp" + #include "duckdb/parser/parsed_data/create_scalar_function_info.hpp" #include "duckdb/parser/parsed_data/create_table_function_info.hpp" #include "duckdb/parser/query_node/select_node.hpp" @@ -122,8 +124,11 @@ void duckpgq_find_match_function(TableRef *table_ref, if (function->function_name != "duckpgq_match") { return; } - duckpgq_state.transform_expression.push_back(std::move(function->children[0])); + int32_t match_index = duckpgq_state.match_index++; + duckpgq_state.transform_expression[match_index] = std::move(function->children[0]); function->children.pop_back(); + auto function_identifier = make_uniq(Value::CreateValue(match_index)); + function->children.push_back(std::move(function_identifier)); } else if (auto join_ref = dynamic_cast(table_ref)) { // Handle JoinRef case duckpgq_find_match_function(join_ref->left.get(), duckpgq_state); diff --git a/src/functions/tablefunctions/match.cpp b/src/functions/tablefunctions/match.cpp index caf4bff6..201ea235 100644 --- a/src/functions/tablefunctions/match.cpp +++ b/src/functions/tablefunctions/match.cpp @@ -941,10 +941,9 @@ PGQMatchFunction::MatchBindReplace(ClientContext &context, auto duckpgq_state_entry = context.registered_state.find("duckpgq"); auto duckpgq_state = dynamic_cast(duckpgq_state_entry->second.get()); - + auto match_index = bind_input.inputs[0].GetValue(); auto ref = dynamic_cast( - duckpgq_state->transform_expression[duckpgq_state->match_index].get()); - duckpgq_state->match_index++; + duckpgq_state->transform_expression[match_index].get()); auto pg_table = duckpgq_state->GetPropertyGraph(ref->pg_name); vector> conditions; diff --git a/src/include/duckpgq/functions/tablefunctions/match.hpp b/src/include/duckpgq/functions/tablefunctions/match.hpp index c2f050e8..c154ab14 100644 --- a/src/include/duckpgq/functions/tablefunctions/match.hpp +++ b/src/include/duckpgq/functions/tablefunctions/match.hpp @@ -20,7 +20,9 @@ struct PGQMatchFunction : public TableFunction { public: PGQMatchFunction() { name = "duckpgq_match"; + arguments.push_back(LogicalType::INTEGER); bind_replace = MatchBindReplace; + // bind = MatchBind; } struct MatchBindData : public TableFunctionData { diff --git a/src/include/duckpgq_extension.hpp b/src/include/duckpgq_extension.hpp index bd41c137..aae43a93 100644 --- a/src/include/duckpgq_extension.hpp +++ b/src/include/duckpgq_extension.hpp @@ -107,7 +107,7 @@ class DuckPGQState : public ClientContextState { public: unique_ptr parse_data; - vector> transform_expression; + unordered_map> transform_expression; int32_t match_index = 0; int32_t unnamed_graphtable_index = 1; // Used to generate unique names for // unnamed graph tables From 39197350b9d50b694cac7380bc19c931163c3dff Mon Sep 17 00:00:00 2001 From: dtenwolde Date: Mon, 17 Jun 2024 13:00:01 +0200 Subject: [PATCH 6/9] Remove ambiguity from test --- test/sql/multiple_graph_table.test | 113 ++++++++++++----------------- 1 file changed, 47 insertions(+), 66 deletions(-) diff --git a/test/sql/multiple_graph_table.test b/test/sql/multiple_graph_table.test index 59dfd0e7..6102ecef 100644 --- a/test/sql/multiple_graph_table.test +++ b/test/sql/multiple_graph_table.test @@ -87,73 +87,54 @@ query II 4 4 -query IIII --select a.id, a.name, unnamed_graphtable.id, unnamed_graphtable.name FROM GRAPH_TABLE(pg MATCH (a:student)) a, GRAPH_TABLE(pg MATCH (b:student)-[r:know]->(c:student)); ----- -0 Daniel 1 Tavneet -0 Daniel 2 Gabor -0 Daniel 3 Peter -0 Daniel 0 Daniel -0 Daniel 2 Gabor -0 Daniel 3 Peter -0 Daniel 3 Peter -0 Daniel 3 Peter -1 Tavneet 1 Tavneet -1 Tavneet 2 Gabor -1 Tavneet 3 Peter -1 Tavneet 0 Daniel -1 Tavneet 2 Gabor -1 Tavneet 3 Peter -1 Tavneet 3 Peter -1 Tavneet 3 Peter -2 Gabor 1 Tavneet -2 Gabor 2 Gabor -2 Gabor 3 Peter -2 Gabor 0 Daniel -2 Gabor 2 Gabor -2 Gabor 3 Peter -2 Gabor 3 Peter -2 Gabor 3 Peter -3 Peter 1 Tavneet -3 Peter 2 Gabor -3 Peter 3 Peter -3 Peter 0 Daniel -3 Peter 2 Gabor -3 Peter 3 Peter -3 Peter 3 Peter -3 Peter 3 Peter -4 David 1 Tavneet -4 David 2 Gabor -4 David 3 Peter -4 David 0 Daniel -4 David 2 Gabor -4 David 3 Peter -4 David 3 Peter -4 David 3 Peter - - -query II --select unnamed_subquery.id, unnamed_graphtable.id -FROM GRAPH_TABLE(pg MATCH (a:student)), (select 1 as id); +query IIIIII +-select a.id, a.name, unnamed_graphtable.b_id, unnamed_graphtable.b_name, unnamed_graphtable.C_id, unnamed_graphtable.c_name +FROM GRAPH_TABLE(pg MATCH (a:student)) a, + GRAPH_TABLE(pg + MATCH (b:student)-[r:know]->(c:student) + COLUMNS (b.id as b_id, b.name as b_name, c.name as c_name, c.id as c_id) + ); ---- -1 0 -1 1 -1 2 -1 3 -1 4 - -statement ok -CREATE TABLE cities ( -name VARCHAR, -lat DECIMAL, -lon DECIMAL -); - -statement ok -CREATE TABLE cities_are_adjacent ( -city1name VARCHAR, -city2name VARCHAR -); +0 Daniel 0 Daniel 1 Tavneet +0 Daniel 0 Daniel 2 Gabor +0 Daniel 0 Daniel 3 Peter +0 Daniel 3 Peter 0 Daniel +0 Daniel 1 Tavneet 2 Gabor +0 Daniel 1 Tavneet 3 Peter +0 Daniel 2 Gabor 3 Peter +0 Daniel 4 David 3 Peter +1 Tavneet 0 Daniel 1 Tavneet +1 Tavneet 0 Daniel 2 Gabor +1 Tavneet 0 Daniel 3 Peter +1 Tavneet 3 Peter 0 Daniel +1 Tavneet 1 Tavneet 2 Gabor +1 Tavneet 1 Tavneet 3 Peter +1 Tavneet 2 Gabor 3 Peter +1 Tavneet 4 David 3 Peter +2 Gabor 0 Daniel 1 Tavneet +2 Gabor 0 Daniel 2 Gabor +2 Gabor 0 Daniel 3 Peter +2 Gabor 3 Peter 0 Daniel +2 Gabor 1 Tavneet 2 Gabor +2 Gabor 1 Tavneet 3 Peter +2 Gabor 2 Gabor 3 Peter +2 Gabor 4 David 3 Peter +3 Peter 0 Daniel 1 Tavneet +3 Peter 0 Daniel 2 Gabor +3 Peter 0 Daniel 3 Peter +3 Peter 3 Peter 0 Daniel +3 Peter 1 Tavneet 2 Gabor +3 Peter 1 Tavneet 3 Peter +3 Peter 2 Gabor 3 Peter +3 Peter 4 David 3 Peter +4 David 0 Daniel 1 Tavneet +4 David 0 Daniel 2 Gabor +4 David 0 Daniel 3 Peter +4 David 3 Peter 0 Daniel +4 David 1 Tavneet 2 Gabor +4 David 1 Tavneet 3 Peter +4 David 2 Gabor 3 Peter +4 David 4 David 3 Peter statement ok -CREATE PROPERTY GRAPH citymap From 62994321eb08d26ea123272792ef4121bca6f53c Mon Sep 17 00:00:00 2001 From: dtenwolde Date: Mon, 17 Jun 2024 15:04:27 +0200 Subject: [PATCH 7/9] Add test that I accidentally removed --- test/sql/multiple_graph_table.test | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/sql/multiple_graph_table.test b/test/sql/multiple_graph_table.test index 6102ecef..c27f2a4a 100644 --- a/test/sql/multiple_graph_table.test +++ b/test/sql/multiple_graph_table.test @@ -136,6 +136,30 @@ FROM GRAPH_TABLE(pg MATCH (a:student)) a, 4 David 2 Gabor 3 Peter 4 David 4 David 3 Peter +query II +-select unnamed_subquery.id, unnamed_graphtable.id +FROM GRAPH_TABLE(pg MATCH (a:student)), (select 1 as id); +---- +1 0 +1 1 +1 2 +1 3 +1 4 + +statement ok +CREATE TABLE cities ( +name VARCHAR, +lat DECIMAL, +lon DECIMAL +); + +statement ok +CREATE TABLE cities_are_adjacent ( +city1name VARCHAR, +city2name VARCHAR +); + + statement ok -CREATE PROPERTY GRAPH citymap VERTEX TABLES ( From f5eb7f20de57f14abae8fac45f2b860ea4cafff6 Mon Sep 17 00:00:00 2001 From: dtenwolde Date: Mon, 17 Jun 2024 16:02:03 +0200 Subject: [PATCH 8/9] Make format-fix --- src/duckpgq_extension.cpp | 19 +++-- src/functions/scalar/csr_creation.cpp | 9 +- src/functions/scalar/reachability.cpp | 3 +- .../tablefunctions/create_property_graph.cpp | 82 +++++++++++-------- .../describe_property_graph.cpp | 44 ++++++---- .../tablefunctions/drop_property_graph.cpp | 7 +- src/functions/tablefunctions/match.cpp | 39 +++++---- src/include/duckpgq/compressed_sparse_row.hpp | 25 +++--- .../describe_property_graph.hpp | 13 ++- .../functions/tablefunctions/match.hpp | 3 +- src/include/duckpgq_extension.hpp | 6 +- 11 files changed, 142 insertions(+), 108 deletions(-) diff --git a/src/duckpgq_extension.cpp b/src/duckpgq_extension.cpp index 1b00bb7b..bb0147e0 100644 --- a/src/duckpgq_extension.cpp +++ b/src/duckpgq_extension.cpp @@ -91,10 +91,11 @@ ParserExtensionParseResult duckpgq_parse(ParserExtensionInfo *info, : query); if (parser.statements.size() != 1) { throw Exception(ExceptionType::PARSER, - "More than one statement detected, please only give one."); + "More than one statement detected, please only give one."); } - return ParserExtensionParseResult(make_uniq_base( - std::move(parser.statements[0]))); + return ParserExtensionParseResult( + make_uniq_base( + std::move(parser.statements[0]))); } BoundStatement duckpgq_bind(ClientContext &context, Binder &binder, @@ -125,9 +126,11 @@ void duckpgq_find_match_function(TableRef *table_ref, return; } int32_t match_index = duckpgq_state.match_index++; - duckpgq_state.transform_expression[match_index] = std::move(function->children[0]); + duckpgq_state.transform_expression[match_index] = + std::move(function->children[0]); function->children.pop_back(); - auto function_identifier = make_uniq(Value::CreateValue(match_index)); + auto function_identifier = + make_uniq(Value::CreateValue(match_index)); function->children.push_back(std::move(function_identifier)); } else if (auto join_ref = dynamic_cast(table_ref)) { // Handle JoinRef case @@ -142,7 +145,8 @@ duckpgq_handle_statement(SQLStatement *statement, DuckPGQState &duckpgq_state) { const auto select_statement = dynamic_cast(statement); const auto select_node = dynamic_cast(select_statement->node.get()); - const auto describe_node = dynamic_cast(select_node->from_table.get()); + const auto describe_node = + dynamic_cast(select_node->from_table.get()); if (describe_node) { ParserExtensionPlanResult result; result.function = DescribePropertyGraphFunction(); @@ -193,7 +197,8 @@ duckpgq_handle_statement(SQLStatement *statement, DuckPGQState &duckpgq_state) { } throw Exception(ExceptionType::NOT_IMPLEMENTED, - StatementTypeToString(statement->type) + "has not been implemented yet for DuckPGQ queries"); + StatementTypeToString(statement->type) + + "has not been implemented yet for DuckPGQ queries"); } ParserExtensionPlanResult diff --git a/src/functions/scalar/csr_creation.cpp b/src/functions/scalar/csr_creation.cpp index 96539339..60cc9107 100644 --- a/src/functions/scalar/csr_creation.cpp +++ b/src/functions/scalar/csr_creation.cpp @@ -36,7 +36,8 @@ static void CsrInitializeVertex(DuckPGQState &context, int32_t id, csr->initialized_v = true; context.csr_list[id] = std::move(csr); } catch (std::bad_alloc const &) { - throw Exception(ExceptionType::INTERNAL, "Unable to initialize vector of size for csr vertex table " + throw Exception(ExceptionType::INTERNAL, + "Unable to initialize vector of size for csr vertex table " "representation"); } @@ -55,7 +56,8 @@ static void CsrInitializeEdge(DuckPGQState &context, int32_t id, int64_t v_size, csr_entry->second->e.resize(e_size, 0); csr_entry->second->edge_ids.resize(e_size, 0); } catch (std::bad_alloc const &) { - throw Exception(ExceptionType::INTERNAL, "Unable to initialize vector of size for csr edge table " + throw Exception(ExceptionType::INTERNAL, + "Unable to initialize vector of size for csr edge table " "representation"); } for (auto i = 1; i < v_size + 2; i++) { @@ -82,7 +84,8 @@ static void CsrInitializeWeight(DuckPGQState &context, int32_t id, throw NotImplementedException("Unrecognized weight type detected."); } } catch (std::bad_alloc const &) { - throw Exception(ExceptionType::INTERNAL, "Unable to initialize vector of size for csr weight table " + throw Exception(ExceptionType::INTERNAL, + "Unable to initialize vector of size for csr weight table " "representation"); } diff --git a/src/functions/scalar/reachability.cpp b/src/functions/scalar/reachability.cpp index 5c6443fb..1408bd60 100644 --- a/src/functions/scalar/reachability.cpp +++ b/src/functions/scalar/reachability.cpp @@ -245,7 +245,8 @@ static void ReachabilityFunction(DataChunk &args, ExpressionState &state, break; } default: - throw Exception(ExceptionType::INTERNAL, "Unknown reachability mode encountered"); + throw Exception(ExceptionType::INTERNAL, + "Unknown reachability mode encountered"); } } else { exit_early = BfsWithoutArray(exit_early, csr, input_size, seen, visit, diff --git a/src/functions/tablefunctions/create_property_graph.cpp b/src/functions/tablefunctions/create_property_graph.cpp index 36ecac49..7f1ecd9d 100644 --- a/src/functions/tablefunctions/create_property_graph.cpp +++ b/src/functions/tablefunctions/create_property_graph.cpp @@ -9,15 +9,17 @@ void CreatePropertyGraphFunction::CheckPropertyGraphTableLabels( const shared_ptr &pg_table, TableCatalogEntry &table) { if (!pg_table->discriminator.empty()) { if (!table.ColumnExists(pg_table->discriminator)) { - throw Exception(ExceptionType::INVALID, "Column " + pg_table->discriminator + - " not found in table " + pg_table->table_name); + throw Exception(ExceptionType::INVALID, + "Column " + pg_table->discriminator + + " not found in table " + pg_table->table_name); } auto &column = table.GetColumn(pg_table->discriminator); if (!(column.GetType() == LogicalType::BIGINT || column.GetType() == LogicalType::INTEGER)) { - throw Exception(ExceptionType::INVALID, "The discriminator column " + - pg_table->discriminator + " of table " + - pg_table->table_name + " should be of type BIGINT or INTEGER"); + throw Exception(ExceptionType::INVALID, + "The discriminator column " + pg_table->discriminator + + " of table " + pg_table->table_name + + " should be of type BIGINT or INTEGER"); } } } @@ -31,8 +33,9 @@ void CreatePropertyGraphFunction::CheckPropertyGraphTableColumns( if (pg_table->all_columns) { for (auto &except_column : pg_table->except_columns) { if (!table.ColumnExists(except_column)) { - throw Exception(ExceptionType::INVALID, "Except column " + except_column + - " not found in table " + pg_table->table_name); + throw Exception(ExceptionType::INVALID, + "Except column " + except_column + + " not found in table " + pg_table->table_name); } } @@ -52,13 +55,13 @@ void CreatePropertyGraphFunction::CheckPropertyGraphTableColumns( for (auto &column : pg_table->column_names) { if (!table.ColumnExists(column)) { throw Exception(ExceptionType::INVALID, "Column " + column + - " not found in table " + pg_table->table_name); + " not found in table " + + pg_table->table_name); } } } -unique_ptr -CreatePropertyGraphFunction::CreatePropertyGraphBind( +unique_ptr CreatePropertyGraphFunction::CreatePropertyGraphBind( ClientContext &context, TableFunctionBindInput &input, vector &return_types, vector &names) { names.emplace_back("Success"); @@ -83,21 +86,24 @@ CreatePropertyGraphFunction::CreatePropertyGraphBind( if (pg_table != duckpgq_state->registered_property_graphs.end() && info->on_conflict == OnCreateConflict::ERROR_ON_CONFLICT) { - throw Exception(ExceptionType::INVALID, "Property graph table with name " + info->property_graph_name + " already exists"); + throw Exception(ExceptionType::INVALID, "Property graph table with name " + + info->property_graph_name + + " already exists"); } auto &catalog = Catalog::GetCatalog(context, info->catalog); case_insensitive_set_t v_table_names; for (auto &vertex_table : info->vertex_tables) { try { - auto &table = catalog.GetEntry(context, info->schema, - vertex_table->table_name); - - CheckPropertyGraphTableColumns(vertex_table, table); - CheckPropertyGraphTableLabels(vertex_table, table); - } catch (Exception &) { - throw Exception(ExceptionType::INVALID, vertex_table->table_name + " does not exist"); - } + auto &table = catalog.GetEntry( + context, info->schema, vertex_table->table_name); + + CheckPropertyGraphTableColumns(vertex_table, table); + CheckPropertyGraphTableLabels(vertex_table, table); + } catch (Exception &) { + throw Exception(ExceptionType::INVALID, + vertex_table->table_name + " does not exist"); + } v_table_names.insert(vertex_table->table_name); if (vertex_table->hasTableNameAlias()) { @@ -108,42 +114,53 @@ CreatePropertyGraphFunction::CreatePropertyGraphBind( for (auto &edge_table : info->edge_tables) { try { auto &table = catalog.GetEntry(context, info->schema, - edge_table->table_name); + edge_table->table_name); CheckPropertyGraphTableColumns(edge_table, table); CheckPropertyGraphTableLabels(edge_table, table); for (auto &fk : edge_table->source_fk) { if (!table.ColumnExists(fk)) { - throw Exception(ExceptionType::INVALID,"Foreign key " + fk + " does not exist in table " + edge_table->table_name); + throw Exception(ExceptionType::INVALID, + "Foreign key " + fk + " does not exist in table " + + edge_table->table_name); } } for (auto &fk : edge_table->destination_fk) { if (!table.ColumnExists(fk)) { - throw Exception(ExceptionType::INVALID,"Foreign key " + fk + " does not exist in table " + edge_table->table_name); + throw Exception(ExceptionType::INVALID, + "Foreign key " + fk + " does not exist in table " + + edge_table->table_name); } } - } catch(const Exception &) { - throw Exception(ExceptionType::INVALID, edge_table->table_name + " does not exist"); + } catch (const Exception &) { + throw Exception(ExceptionType::INVALID, + edge_table->table_name + " does not exist"); } if (v_table_names.find(edge_table->source_reference) == v_table_names.end()) { - throw Exception(ExceptionType::INVALID, "Referenced vertex table " + edge_table->source_reference + " does not exist."); + throw Exception(ExceptionType::INVALID, "Referenced vertex table " + + edge_table->source_reference + + " does not exist."); } auto &pk_source_table = catalog.GetEntry( context, info->schema, edge_table->source_reference); for (auto &pk : edge_table->source_pk) { if (!pk_source_table.ColumnExists(pk)) { - throw Exception(ExceptionType::INVALID, "Primary key " + pk + " does not exist in table " + edge_table->source_reference); + throw Exception(ExceptionType::INVALID, + "Primary key " + pk + " does not exist in table " + + edge_table->source_reference); } } if (v_table_names.find(edge_table->source_reference) == v_table_names.end()) { - throw Exception(ExceptionType::INVALID, "Referenced vertex table " + edge_table->source_reference + " does not exist"); + throw Exception(ExceptionType::INVALID, "Referenced vertex table " + + edge_table->source_reference + + " does not exist"); } auto &pk_destination_table = catalog.GetEntry( @@ -151,11 +168,11 @@ CreatePropertyGraphFunction::CreatePropertyGraphBind( for (auto &pk : edge_table->destination_pk) { if (!pk_destination_table.ColumnExists(pk)) { - throw Exception(ExceptionType::INVALID,"Primary key " + pk + " does not exist in table " + edge_table->destination_reference); + throw Exception(ExceptionType::INVALID, + "Primary key " + pk + " does not exist in table " + + edge_table->destination_reference); } } - - } return make_uniq(info); } @@ -173,10 +190,11 @@ void CreatePropertyGraphFunction::CreatePropertyGraphFunc( auto pg_info = bind_data.create_pg_info; auto lookup = context.registered_state.find("duckpgq"); if (lookup == context.registered_state.end()) { - throw Exception(ExceptionType::INVALID,"Registered DuckPGQ state not found"); + throw Exception(ExceptionType::INVALID, + "Registered DuckPGQ state not found"); } auto duckpgq_state = (DuckPGQState *)lookup->second.get(); duckpgq_state->registered_property_graphs[pg_info->property_graph_name] = - pg_info->Copy(); + pg_info->Copy(); } }; // namespace duckdb diff --git a/src/functions/tablefunctions/describe_property_graph.cpp b/src/functions/tablefunctions/describe_property_graph.cpp index 7e494def..58383343 100644 --- a/src/functions/tablefunctions/describe_property_graph.cpp +++ b/src/functions/tablefunctions/describe_property_graph.cpp @@ -29,10 +29,13 @@ DescribePropertyGraphFunction::DescribePropertyGraphBind( auto pg_table = duckpgq_state->registered_property_graphs.find(show_ref->table_name); - if (pg_table == duckpgq_state->registered_property_graphs.end() ) { - throw Exception(ExceptionType::INVALID, "Property graph " + show_ref->table_name + " does not exist."); + if (pg_table == duckpgq_state->registered_property_graphs.end()) { + throw Exception(ExceptionType::INVALID, "Property graph " + + show_ref->table_name + + " does not exist."); } - auto property_graph = dynamic_cast(pg_table->second.get()); + auto property_graph = + dynamic_cast(pg_table->second.get()); names.emplace_back("table_name"); return_types.emplace_back(LogicalType::VARCHAR); @@ -57,7 +60,6 @@ DescribePropertyGraphFunction::DescribePropertyGraphBind( names.emplace_back("sub_labels"); return_types.emplace_back(LogicalType::LIST(LogicalType::VARCHAR)); - return make_uniq(property_graph); } @@ -76,7 +78,7 @@ void DescribePropertyGraphFunction::DescribePropertyGraphFunc( } auto pg_info = bind_data.describe_pg_info; idx_t vector_idx = 0; - for (const auto& vertex_table : pg_info->vertex_tables) { + for (const auto &vertex_table : pg_info->vertex_tables) { output.SetValue(0, vector_idx, Value(vertex_table->table_name)); output.SetValue(1, vector_idx, Value(vertex_table->main_label)); output.SetValue(2, vector_idx, Value(vertex_table->is_vertex_table)); @@ -89,49 +91,55 @@ void DescribePropertyGraphFunction::DescribePropertyGraphFunc( if (!vertex_table->discriminator.empty()) { output.SetValue(9, vector_idx, Value(vertex_table->discriminator)); vector sub_labels; - for (const auto& label : vertex_table->sub_labels) { + for (const auto &label : vertex_table->sub_labels) { sub_labels.push_back(Value(label)); } - output.SetValue(10, vector_idx, Value::LIST(LogicalType::VARCHAR, sub_labels)); + output.SetValue(10, vector_idx, + Value::LIST(LogicalType::VARCHAR, sub_labels)); } else { output.SetValue(9, vector_idx, Value()); output.SetValue(10, vector_idx, Value()); } vector_idx++; } - for (const auto& edge_table : pg_info->edge_tables) { + for (const auto &edge_table : pg_info->edge_tables) { output.SetValue(0, vector_idx, Value(edge_table->table_name)); output.SetValue(1, vector_idx, Value(edge_table->main_label)); output.SetValue(2, vector_idx, Value(edge_table->is_vertex_table)); output.SetValue(3, vector_idx, Value(edge_table->source_reference)); vector source_pk_list; - for (const auto& col : edge_table->source_pk) { + for (const auto &col : edge_table->source_pk) { source_pk_list.push_back(Value(col)); } - output.SetValue(4, vector_idx, Value::LIST(LogicalType::VARCHAR,source_pk_list)); + output.SetValue(4, vector_idx, + Value::LIST(LogicalType::VARCHAR, source_pk_list)); vector source_fk_list; - for (const auto& col : edge_table->source_fk) { + for (const auto &col : edge_table->source_fk) { source_fk_list.push_back(Value(col)); } - output.SetValue(5, vector_idx, Value::LIST(LogicalType::VARCHAR,source_fk_list)); + output.SetValue(5, vector_idx, + Value::LIST(LogicalType::VARCHAR, source_fk_list)); output.SetValue(6, vector_idx, Value(edge_table->destination_reference)); vector destination_pk_list; - for (const auto& col : edge_table->destination_pk) { + for (const auto &col : edge_table->destination_pk) { destination_pk_list.push_back(Value(col)); } - output.SetValue(7, vector_idx, Value::LIST(LogicalType::VARCHAR,destination_pk_list)); + output.SetValue(7, vector_idx, + Value::LIST(LogicalType::VARCHAR, destination_pk_list)); vector destination_fk_list; - for (const auto& col : edge_table->destination_fk) { + for (const auto &col : edge_table->destination_fk) { destination_fk_list.push_back(Value(col)); } - output.SetValue(8, vector_idx, Value::LIST(LogicalType::VARCHAR,destination_fk_list)); + output.SetValue(8, vector_idx, + Value::LIST(LogicalType::VARCHAR, destination_fk_list)); if (!edge_table->discriminator.empty()) { output.SetValue(9, vector_idx, Value(edge_table->discriminator)); vector sub_labels; - for (const auto& label : edge_table->sub_labels) { + for (const auto &label : edge_table->sub_labels) { sub_labels.push_back(Value(label)); } - output.SetValue(10, vector_idx, Value::LIST(LogicalType::VARCHAR, sub_labels)); + output.SetValue(10, vector_idx, + Value::LIST(LogicalType::VARCHAR, sub_labels)); } else { output.SetValue(9, vector_idx, Value()); output.SetValue(10, vector_idx, Value()); diff --git a/src/functions/tablefunctions/drop_property_graph.cpp b/src/functions/tablefunctions/drop_property_graph.cpp index b001bced..26a96eeb 100644 --- a/src/functions/tablefunctions/drop_property_graph.cpp +++ b/src/functions/tablefunctions/drop_property_graph.cpp @@ -43,10 +43,11 @@ void DropPropertyGraphFunction::DropPropertyGraphFunc( throw BinderException("Registered DuckPGQ state not found"); } auto duckpgq_state = (DuckPGQState *)lookup->second.get(); - auto registered_pg = - duckpgq_state->registered_property_graphs.find(pg_info->property_graph_name); + auto registered_pg = duckpgq_state->registered_property_graphs.find( + pg_info->property_graph_name); if (registered_pg == duckpgq_state->registered_property_graphs.end()) { - throw BinderException("Property graph %s does not exist.", pg_info->property_graph_name); + throw BinderException("Property graph %s does not exist.", + pg_info->property_graph_name); } duckpgq_state->registered_property_graphs.erase(registered_pg); } diff --git a/src/functions/tablefunctions/match.cpp b/src/functions/tablefunctions/match.cpp index 201ea235..68b57330 100644 --- a/src/functions/tablefunctions/match.cpp +++ b/src/functions/tablefunctions/match.cpp @@ -33,8 +33,10 @@ PGQMatchFunction::FindGraphTable(const string &label, CreatePropertyGraphInfo &pg_table) { const auto graph_table_entry = pg_table.label_map.find(label); if (graph_table_entry == pg_table.label_map.end()) { - throw Exception(ExceptionType::BINDER, "The label " + label + - " is not registered in property graph " + pg_table.property_graph_name); + throw Exception(ExceptionType::BINDER, + "The label " + label + + " is not registered in property graph " + + pg_table.property_graph_name); } return graph_table_entry->second; @@ -376,8 +378,10 @@ void PGQMatchFunction::EdgeTypeAny( edge_left_ref->table_name = edge_table->table_name; src_dst_select_node->from_table = std::move(edge_left_ref); auto src_dst_children = vector>(); - src_dst_children.push_back(make_uniq(edge_table->source_fk[0], edge_table->table_name)); - src_dst_children.push_back(make_uniq(edge_table->destination_fk[0], edge_table->table_name)); + src_dst_children.push_back(make_uniq( + edge_table->source_fk[0], edge_table->table_name)); + src_dst_children.push_back(make_uniq( + edge_table->destination_fk[0], edge_table->table_name)); src_dst_children.push_back(make_uniq()); src_dst_select_node->select_list = std::move(src_dst_children); @@ -393,8 +397,8 @@ void PGQMatchFunction::EdgeTypeAny( dst_src_children.push_back(make_uniq( edge_table->destination_fk[0], edge_table->table_name)); - dst_src_children.push_back(make_uniq(edge_table->source_fk[0], - edge_table->table_name)); + dst_src_children.push_back(make_uniq( + edge_table->source_fk[0], edge_table->table_name)); dst_src_children.push_back(make_uniq()); dst_src_select_node->select_list = std::move(dst_src_children); @@ -407,7 +411,8 @@ void PGQMatchFunction::EdgeTypeAny( union_node->right = std::move(dst_src_select_node); auto union_select = make_uniq(); union_select->node = std::move(union_node); - // (SELECT src, dst, * from edge_table UNION ALL SELECT dst, src, * from edge_table) + // (SELECT src, dst, * from edge_table UNION ALL SELECT dst, src, * from + // edge_table) auto union_subquery = make_uniq(std::move(union_select)); union_subquery->alias = edge_binding; if (from_clause) { @@ -630,7 +635,8 @@ unique_ptr PGQMatchFunction::CreatePathFindingFunction( return final_list; } -void PGQMatchFunction::AddEdgeJoins(const shared_ptr &edge_table, +void PGQMatchFunction::AddEdgeJoins( + const shared_ptr &edge_table, const shared_ptr &previous_vertex_table, const shared_ptr &next_vertex_table, PGQMatchType edge_type, const string &edge_binding, @@ -904,9 +910,8 @@ void PGQMatchFunction::ProcessPathList( } else { alias_map[edge_element->variable_binding] = edge_table->source_reference; - AddEdgeJoins(edge_table, previous_vertex_table, - next_vertex_table, edge_element->match_type, - edge_element->variable_binding, + AddEdgeJoins(edge_table, previous_vertex_table, next_vertex_table, + edge_element->match_type, edge_element->variable_binding, previous_vertex_element->variable_binding, next_vertex_element->variable_binding, conditions, alias_map, extra_alias_counter, from_clause); @@ -916,19 +921,19 @@ void PGQMatchFunction::ProcessPathList( auto edge_table = FindGraphTable(edge_element->label, pg_table); CheckInheritance(edge_table, edge_element, conditions); // check aliases - AddEdgeJoins(edge_table, previous_vertex_table, - next_vertex_table, edge_element->match_type, - edge_element->variable_binding, + AddEdgeJoins(edge_table, previous_vertex_table, next_vertex_table, + edge_element->match_type, edge_element->variable_binding, previous_vertex_element->variable_binding, - next_vertex_element->variable_binding, conditions, - alias_map, extra_alias_counter, from_clause); + next_vertex_element->variable_binding, conditions, alias_map, + extra_alias_counter, from_clause); // Check the edge type // If (a)-[b]->(c) -> b.src = a.id AND b.dst = c.id // If (a)<-[b]-(c) -> b.dst = a.id AND b.src = c.id // If (a)-[b]-(c) -> (b.src = a.id AND b.dst = c.id) // FROM (src, dst, * from b UNION ALL dst, src, * from b) // If (a)<-[b]->(c) -> (b.src = a.id AND b.dst = c.id) AND - // (b.dst = a.id AND b.src = c.id) + // (b.dst = a.id AND b.src + //= c.id) } previous_vertex_element = next_vertex_element; previous_vertex_table = next_vertex_table; diff --git a/src/include/duckpgq/compressed_sparse_row.hpp b/src/include/duckpgq/compressed_sparse_row.hpp index a9a442da..8c9b751c 100644 --- a/src/include/duckpgq/compressed_sparse_row.hpp +++ b/src/include/duckpgq/compressed_sparse_row.hpp @@ -6,24 +6,21 @@ namespace duckdb { class CSR { public: - CSR() { - } - ~CSR() { - delete[] v; - } + CSR() {} + ~CSR() { delete[] v; } - atomic *v; + atomic *v; - vector e; - vector edge_ids; + vector e; + vector edge_ids; - vector w; - vector w_double; + vector w; + vector w_double; - bool initialized_v = false; - bool initialized_e = false; - bool initialized_w = false; + bool initialized_v = false; + bool initialized_e = false; + bool initialized_w = false; - size_t vsize; + size_t vsize; }; } // namespace duckdb diff --git a/src/include/duckpgq/functions/tablefunctions/describe_property_graph.hpp b/src/include/duckpgq/functions/tablefunctions/describe_property_graph.hpp index d01a0d1a..eeca85d1 100644 --- a/src/include/duckpgq/functions/tablefunctions/describe_property_graph.hpp +++ b/src/include/duckpgq/functions/tablefunctions/describe_property_graph.hpp @@ -33,18 +33,17 @@ class DescribePropertyGraphFunction : public TableFunction { bool done = false; }; - static unique_ptr - DescribePropertyGraphBind(ClientContext &context, TableFunctionBindInput &input, - vector &return_types, - vector &names); + static unique_ptr DescribePropertyGraphBind( + ClientContext &context, TableFunctionBindInput &input, + vector &return_types, vector &names); static unique_ptr DescribePropertyGraphInit(ClientContext &context, - TableFunctionInitInput &input); + TableFunctionInitInput &input); static void DescribePropertyGraphFunc(ClientContext &context, - TableFunctionInput &data_p, - DataChunk &output); + TableFunctionInput &data_p, + DataChunk &output); }; } // namespace duckdb \ No newline at end of file diff --git a/src/include/duckpgq/functions/tablefunctions/match.hpp b/src/include/duckpgq/functions/tablefunctions/match.hpp index c154ab14..eb4e50ea 100644 --- a/src/include/duckpgq/functions/tablefunctions/match.hpp +++ b/src/include/duckpgq/functions/tablefunctions/match.hpp @@ -130,8 +130,7 @@ struct PGQMatchFunction : public TableFunction { const string &prev_binding, const string &next_binding, vector> &conditions, unordered_map &alias_map, - int32_t &extra_alias_counter, - unique_ptr &from_clause); + int32_t &extra_alias_counter, unique_ptr &from_clause); static void ProcessPathList( vector> &path_pattern, diff --git a/src/include/duckpgq_extension.hpp b/src/include/duckpgq_extension.hpp index aae43a93..770fdcf9 100644 --- a/src/include/duckpgq_extension.hpp +++ b/src/include/duckpgq_extension.hpp @@ -64,9 +64,7 @@ struct DuckPGQParseData : ParserExtensionParseData { statement->Copy()); } - string ToString() const override { - return statement->ToString(); - }; + string ToString() const override { return statement->ToString(); }; explicit DuckPGQParseData(unique_ptr statement) : statement(std::move(statement)) {} @@ -80,7 +78,7 @@ class DuckPGQState : public ClientContextState { void QueryEnd() override { parse_data.reset(); transform_expression.clear(); - match_index = 0; // Reset the index + match_index = 0; // Reset the index unnamed_graphtable_index = 1; // Reset the index for (const auto &csr_id : csr_to_delete) { csr_list.erase(csr_id); From 4ae5ec20d9fe18a27b6ef151ce7682d1d0e97206 Mon Sep 17 00:00:00 2001 From: dtenwolde Date: Tue, 18 Jun 2024 09:29:14 +0200 Subject: [PATCH 9/9] Remove comment --- src/include/duckpgq/functions/tablefunctions/match.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/include/duckpgq/functions/tablefunctions/match.hpp b/src/include/duckpgq/functions/tablefunctions/match.hpp index eb4e50ea..ed2da4ec 100644 --- a/src/include/duckpgq/functions/tablefunctions/match.hpp +++ b/src/include/duckpgq/functions/tablefunctions/match.hpp @@ -22,7 +22,6 @@ struct PGQMatchFunction : public TableFunction { name = "duckpgq_match"; arguments.push_back(LogicalType::INTEGER); bind_replace = MatchBindReplace; - // bind = MatchBind; } struct MatchBindData : public TableFunctionData {