Skip to content

Commit

Permalink
Throw error when creating property graph on view instead of segfault
Browse files Browse the repository at this point in the history
  • Loading branch information
Dtenwolde committed Oct 30, 2024
1 parent 59cb3d9 commit b29e8ab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/core/functions/table/create_property_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <duckpgq/core/utils/duckpgq_utils.hpp>
#include "duckdb/main/connection_manager.hpp"
#include <duckpgq/core/parser/duckpgq_parser.hpp>
#include "duckdb/catalog/catalog_entry/view_catalog_entry.hpp"

namespace duckpgq {
namespace core {
Expand Down Expand Up @@ -183,7 +184,11 @@ unique_ptr<FunctionData> CreatePropertyGraphFunction::CreatePropertyGraphBind(
CheckPropertyGraphTableColumns(vertex_table, *table);
CheckPropertyGraphTableLabels(vertex_table, *table);
} catch (CatalogException &e) {
throw Exception(ExceptionType::INVALID, "Catalog exception while creating table " + vertex_table->table_name);
auto table = catalog.GetEntry<ViewCatalogEntry>(context, info->schema, vertex_table->table_name, OnEntryNotFound::RETURN_NULL);
if (table) {
throw Exception(ExceptionType::INVALID, "Found a view with name " + vertex_table->table_name + ". Creating property graph tables over views is currently not supported.");
}
throw Exception(ExceptionType::INVALID, e.what());
}


Expand Down
7 changes: 4 additions & 3 deletions test/sql/create_pg/create_pg_on_view.test
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ CREATE TABLE w(id TEXT PRIMARY KEY);
statement ok
CREATE TABLE v_w(v_id TEXT, w_id TEXT);

statement ok
statement error
-CREATE PROPERTY GRAPH g1
VERTEX TABLES (v, w)

EDGE TABLES (
v_w SOURCE KEY (v_id) REFERENCES v (id)
DESTINATION KEY (w_id) REFERENCES w (id)
LABEL hasW
);
);
----
Invalid Error: Found a view with name v. Creating property graph tables over views is currently not supported.

0 comments on commit b29e8ab

Please sign in to comment.