diff --git a/src/include/duckdb/parser/parsed_data/create_property_graph_info.hpp b/src/include/duckdb/parser/parsed_data/create_property_graph_info.hpp index e519dd1f8034..a31354b21d6e 100644 --- a/src/include/duckdb/parser/parsed_data/create_property_graph_info.hpp +++ b/src/include/duckdb/parser/parsed_data/create_property_graph_info.hpp @@ -58,6 +58,18 @@ struct CreatePropertyGraphInfo : public CreateInfo { return result; }; + shared_ptr GetTable(const string &table_name, bool error_not_found = true) { + auto entry = label_map.find(table_name); + if (entry == label_map.end()) { + if (error_not_found) { + throw Exception(ExceptionType::INVALID, + "Table " + table_name + " not found in property graph " + property_graph_name); + } + return nullptr; + } + return entry->second; + } + //! Serializes a blob into a CreatePropertyGraphInfo void Serialize(Serializer &serializer) const override; //! Deserializes a blob back into a CreatePropertyGraphInfo diff --git a/src/include/duckdb/parser/property_graph_table.hpp b/src/include/duckdb/parser/property_graph_table.hpp index 243d3ed2a553..9b0517f1d01f 100644 --- a/src/include/duckdb/parser/property_graph_table.hpp +++ b/src/include/duckdb/parser/property_graph_table.hpp @@ -69,5 +69,9 @@ class PropertyGraphTable { bool hasTableNameAlias() { return !table_name_alias.empty(); } + + string ToLower(const std::string &str); + + bool IsSourceTable(const string &table_name); }; } // namespace duckdb diff --git a/src/parser/property_graph_table.cpp b/src/parser/property_graph_table.cpp index d251df535636..778a7424175b 100644 --- a/src/parser/property_graph_table.cpp +++ b/src/parser/property_graph_table.cpp @@ -257,6 +257,20 @@ shared_ptr PropertyGraphTable::Deserialize(Deserializer &des return pg_table; } + +// Helper function to convert a string to lowercase +string PropertyGraphTable::ToLower(const std::string &str) { + string result = str; + transform(result.begin(), result.end(), result.begin(), + [](unsigned char c){ return std::tolower(c); }); + return result; +} + + +bool PropertyGraphTable::IsSourceTable(const string& table_name) { + return ToLower(this->source_reference) == ToLower(table_name); +} + shared_ptr PropertyGraphTable::Copy() const { auto result = make_shared_ptr(); diff --git a/src/parser/transform/statement/transform_create_property_graph.cpp b/src/parser/transform/statement/transform_create_property_graph.cpp index 3497280ce802..7f42970f2331 100644 --- a/src/parser/transform/statement/transform_create_property_graph.cpp +++ b/src/parser/transform/statement/transform_create_property_graph.cpp @@ -92,7 +92,6 @@ Transformer::TransformPropertyGraphTable(duckdb_libpgquery::PGPropertyGraphTable } else { pg_table->source_reference = possible_src_alias->second; } - D_ASSERT(graph_table->dst_name); auto dst_name = TransformQualifiedName(*graph_table->dst_name); auto possible_dst_alias = table_alias_map.find(dst_name.name);