Skip to content

Commit

Permalink
Update error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Dtenwolde committed Sep 6, 2024
1 parent 0a6cdd5 commit aa97346
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
35 changes: 19 additions & 16 deletions src/core/functions/table/create_property_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,15 @@ unique_ptr<FunctionData> CreatePropertyGraphFunction::CreatePropertyGraphBind(
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<TableCatalogEntry>(
context, info->schema, vertex_table->table_name);
auto table = catalog.GetEntry<TableCatalogEntry>(
context, info->schema, vertex_table->table_name, OnEntryNotFound::RETURN_NULL);
if (!table) {
throw Exception(ExceptionType::INVALID,
"Table " + vertex_table->table_name + " not found");
}

CheckPropertyGraphTableColumns(vertex_table, table);
CheckPropertyGraphTableLabels(vertex_table, table);
} catch (Exception &) {
throw Exception(ExceptionType::INVALID,
vertex_table->table_name + " does not exist");
}
CheckPropertyGraphTableColumns(vertex_table, *table);
CheckPropertyGraphTableLabels(vertex_table, *table);

v_table_names.insert(vertex_table->table_name);
if (vertex_table->hasTableNameAlias()) {
Expand All @@ -114,12 +113,16 @@ unique_ptr<FunctionData> CreatePropertyGraphFunction::CreatePropertyGraphBind(
}

for (auto &edge_table : info->edge_tables) {
auto &table = catalog.GetEntry<TableCatalogEntry>(context, info->schema,
edge_table->table_name);
auto table = catalog.GetEntry<TableCatalogEntry>(context, info->schema,
edge_table->table_name, OnEntryNotFound::RETURN_NULL);
if (!table) {
throw Exception(ExceptionType::INVALID,
"Table " + edge_table->table_name + " not found");
}

CheckPropertyGraphTableColumns(edge_table, table);
CheckPropertyGraphTableLabels(edge_table, table);
auto &table_constraints = table.GetConstraints();
CheckPropertyGraphTableColumns(edge_table, *table);
CheckPropertyGraphTableLabels(edge_table, *table);
auto &table_constraints = table->GetConstraints();

if (edge_table->source_fk.empty() && edge_table->source_pk.empty()) {
if (table_constraints.empty()) {
Expand Down Expand Up @@ -168,7 +171,7 @@ unique_ptr<FunctionData> CreatePropertyGraphFunction::CreatePropertyGraphBind(
}

for (auto &fk : edge_table->source_fk) {
if (!table.ColumnExists(fk)) {
if (!table->ColumnExists(fk)) {
throw Exception(ExceptionType::INVALID,
"Foreign key " + fk + " does not exist in table " +
edge_table->table_name);
Expand Down Expand Up @@ -222,7 +225,7 @@ unique_ptr<FunctionData> CreatePropertyGraphFunction::CreatePropertyGraphBind(
}

for (auto &fk : edge_table->destination_fk) {
if (!table.ColumnExists(fk)) {
if (!table->ColumnExists(fk)) {
throw Exception(ExceptionType::INVALID,
"Foreign key " + fk + " does not exist in table " +
edge_table->table_name);
Expand Down
8 changes: 4 additions & 4 deletions test/sql/create_pg/create_property_graph.test
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ statement error
-CREATE PROPERTY GRAPH pg4
VERTEX TABLES (tabledoesnotexist);
----
Invalid Error: tabledoesnotexist does not exist
Invalid Error: Table tabledoesnotexist not found


statement ok
Expand All @@ -24,7 +24,7 @@ EDGE TABLES (edgetabledoesnotexist SOURCE KEY (id) REFERENCES Student (id)
DESTINATION KEY (id) REFERENCES Student (id)
);
----
Invalid Error: edgetabledoesnotexist does not exist
Invalid Error: Table edgetabledoesnotexist not found

statement ok
CREATE TABLE know(src BIGINT, dst BIGINT, createDate BIGINT);
Expand Down Expand Up @@ -147,7 +147,7 @@ EDGE TABLES (
PROPERTIES ( createDate ) LABEL Knows
)
----
Invalid Error: Referenced vertex table Student does not exist.
Invalid Error: Referenced vertex table Student is not registered in the vertex tables.


# Should fail since the edge table references vertex tables that do not exist
Expand All @@ -162,7 +162,7 @@ EDGE TABLES (
PROPERTIES ( createDate ) LABEL Knows
);
----
Invalid Error: Referenced vertex table Student does not exist.
Invalid Error: Referenced vertex table Student is not registered in the vertex tables.


# Check duplicate labels
Expand Down

0 comments on commit aa97346

Please sign in to comment.