Skip to content

Commit

Permalink
Now throw original duckdb error instead of DuckPGQ parse data or stat…
Browse files Browse the repository at this point in the history
…e not found
  • Loading branch information
Dtenwolde committed Feb 19, 2024
1 parent 150b318 commit 4ab8ee7
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 2 deletions.
4 changes: 2 additions & 2 deletions duckpgq/src/duckpgq_extension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ BoundStatement duckpgq_bind(ClientContext &context, Binder &binder,
SQLStatement &statement) {
auto lookup = context.registered_state.find("duckpgq");
if (lookup == context.registered_state.end()) {
throw Exception(ExceptionType::BINDER, "Registered state not found");
throw;
}

auto duckpgq_state = (DuckPGQState *)lookup->second.get();
Expand All @@ -107,7 +107,7 @@ BoundStatement duckpgq_bind(ClientContext &context, Binder &binder,
if (duckpgq_parse_data) {
return duckpgq_binder->Bind(*(duckpgq_parse_data->statement));
}
throw Exception(ExceptionType::BINDER, "Unable to find DuckPGQ Parse Data");
throw;
}

void duckpgq_find_match_function(TableRef *table_ref,
Expand Down
52 changes: 52 additions & 0 deletions test/sql/non_existing_table.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# https://github.com/cwida/duckpgq-extension/issues/95
# name: test/sql/sqlpgq/non_existing_table.test
# group: [sqlpgq]

require duckpgq

statement error
select * from table_that_does_not_exist;
----
Catalog Error: Table with name table_that_does_not_exist does not exist!

statement ok
CREATE TABLE test (a INTEGER);

statement error
SELECT b from test;
----
Binder Error: Referenced column "b" not found in FROM clause!

statement ok
import database 'duckdb-pgq/data/SNB0.003';

statement ok
-CREATE PROPERTY GRAPH snb
VERTEX TABLES (
Person,
Organisation IN typemask(company, university)
)
EDGE TABLES (
Person_knows_person SOURCE KEY (Person1Id) REFERENCES Person (id)
DESTINATION KEY (Person2Id) REFERENCES Person (id)
LABEL Knows,
person_workAt_Organisation SOURCE KEY (PersonId) REFERENCES Person (id)
DESTINATION KEY (OrganisationId) REFERENCES Organisation (id)
LABEL workAt_Organisation
);

statement error
-FROM GRAPH_TABLE (snb
MATCH (a:Kind)
COLUMNS (*)
);
----
Binder Error: The label kind is not registered in property graph snb

statement error
-FROM GRAPH_TABLE (abc
MATCH (a:Kind)
COLUMNS (*)
);
----
Binder Error: Property graph abc does not exist

0 comments on commit 4ab8ee7

Please sign in to comment.