Skip to content

Commit

Permalink
Initial merge with v0.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Dtenwolde committed Feb 13, 2024
1 parent 57492c3 commit e308c27
Show file tree
Hide file tree
Showing 16 changed files with 67 additions and 63 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ EXTENSION_FLAGS=\
-DDUCKDB_EXTENSION_${EXTENSION_NAME}_TEST_PATH="$(PROJ_DIR)test/sql"

#### Add more of the DuckDB in-tree extensions here that you need (also feel free to remove them when not needed)
EXTRA_EXTENSIONS_FLAG=-DBUILD_EXTENSIONS="tpch;visualizer"
EXTRA_EXTENSIONS_FLAG=-DBUILD_EXTENSIONS="tpch"

BUILD_FLAGS=-DEXTENSION_STATIC_BUILD=1 $(EXTENSION_FLAGS) ${EXTRA_EXTENSIONS_FLAG} $(OSX_BUILD_FLAG) $(TOOLCHAIN_FLAGS)
CLIENT_FLAGS:=
Expand Down
2 changes: 1 addition & 1 deletion duckdb
Submodule duckdb updated 3364 files
2 changes: 1 addition & 1 deletion duckdb-pgq
Submodule duckdb-pgq updated 3364 files
6 changes: 3 additions & 3 deletions duckpgq/src/duckpgq/functions/scalar/csr_creation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ 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("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");
}

Expand All @@ -55,7 +55,7 @@ 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("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++) {
Expand All @@ -82,7 +82,7 @@ static void CsrInitializeWeight(DuckPGQState &context, int32_t id,
throw NotImplementedException("Unrecognized weight type detected.");
}
} catch (std::bad_alloc const &) {
throw Exception("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");
}

Expand Down
2 changes: 1 addition & 1 deletion duckpgq/src/duckpgq/functions/scalar/reachability.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ static void ReachabilityFunction(DataChunk &args, ExpressionState &state,
break;
}
default:
throw Exception("Unknown mode encountered");
throw Exception(ExceptionType::INTERNAL, "Unknown reachability mode encountered");
}
} else {
exit_early = BfsWithoutArray(exit_early, csr, input_size, seen, visit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ void CreatePropertyGraphFunction::CheckPropertyGraphTableLabels(
const shared_ptr<PropertyGraphTable> &pg_table, TableCatalogEntry &table) {
if (!pg_table->discriminator.empty()) {
if (!table.ColumnExists(pg_table->discriminator)) {
throw BinderException("Column %s not found in table %s",
pg_table->discriminator, 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 BinderException("The discriminator column %s for table %s should "
"be of type BIGINT or INTEGER",
pg_table->discriminator, pg_table->table_name);
throw Exception(ExceptionType::INVALID, "The discriminator column " +
pg_table->discriminator + " of table " +
pg_table->table_name + " should be of type BIGINT or INTEGER");
}
}
}
Expand All @@ -29,8 +29,8 @@ void CreatePropertyGraphFunction::CheckPropertyGraphTableColumns(
if (pg_table->all_columns) {
for (auto &except_column : pg_table->except_columns) {
if (!table.ColumnExists(except_column)) {
throw BinderException("Except column %s not found in table %s",
except_column, pg_table->table_name);
throw Exception(ExceptionType::INVALID, "Except column " + except_column +
" not found in table " + pg_table->table_name);
}
}

Expand All @@ -49,24 +49,25 @@ void CreatePropertyGraphFunction::CheckPropertyGraphTableColumns(

for (auto &column : pg_table->column_names) {
if (!table.ColumnExists(column)) {
throw BinderException("Column %s not found in table %s", column,
pg_table->table_name);
throw Exception(ExceptionType::INVALID, "Column " + column +
" not found in table " + pg_table->table_name);
}
}
}

duckdb::unique_ptr<FunctionData>
unique_ptr<FunctionData>
CreatePropertyGraphFunction::CreatePropertyGraphBind(
ClientContext &context, TableFunctionBindInput &input,
vector<LogicalType> &return_types, vector<string> &names) {
names.emplace_back("Success");
return_types.emplace_back(LogicalType::BOOLEAN);
auto lookup = context.registered_state.find("duckpgq");
if (lookup == context.registered_state.end()) {
throw BinderException("Registered DuckPGQ state not found");
throw Exception(ExceptionType::INVALID,
"Registered DuckPGQ state not found");
}
auto duckpgq_state = (DuckPGQState *)lookup->second.get();
auto duckpgq_parse_data =
const auto duckpgq_state = (DuckPGQState *)lookup->second.get();
const auto duckpgq_parse_data =
dynamic_cast<DuckPGQParseData *>(duckpgq_state->parse_data.get());

if (!duckpgq_parse_data) {
Expand All @@ -79,12 +80,10 @@ CreatePropertyGraphFunction::CreatePropertyGraphBind(
duckpgq_state->registered_property_graphs.find(info->property_graph_name);

if (pg_table != duckpgq_state->registered_property_graphs.end()) {
throw BinderException("Property graph table with name %s already exists",
info->property_graph_name);
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) {
auto &table = catalog.GetEntry<TableCatalogEntry>(context, info->schema,
Expand All @@ -108,53 +107,47 @@ CreatePropertyGraphFunction::CreatePropertyGraphBind(

if (v_table_names.find(edge_table->source_reference) ==
v_table_names.end()) {
throw BinderException("Referenced vertex table %s does not exist.",
edge_table->source_reference);
throw Exception(ExceptionType::INVALID, "Referenced vertex table " + edge_table->source_reference + " does not exist.");
}

auto &pk_source_table = catalog.GetEntry<TableCatalogEntry>(
context, info->schema, edge_table->source_reference);
for (auto &pk : edge_table->source_pk) {
if (!pk_source_table.ColumnExists(pk)) {
throw BinderException("Primary key %s does not exist in table %s", pk,
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 BinderException("Referenced vertex table %s does not exist.",
edge_table->source_reference);
throw Exception(ExceptionType::INVALID, "Referenced vertex table " + edge_table->source_reference + " does not exist");
}

auto &pk_destination_table = catalog.GetEntry<TableCatalogEntry>(
context, info->schema, edge_table->destination_reference);

for (auto &pk : edge_table->destination_pk) {
if (!pk_destination_table.ColumnExists(pk)) {
throw BinderException("Primary key %s does not exist in table %s", pk,
edge_table->destination_reference);
throw Exception(ExceptionType::INVALID,"Primary key " + pk + " does not exist in table " + edge_table->destination_reference);
}
}

for (auto &fk : edge_table->source_fk) {
if (!table.ColumnExists(fk)) {
throw BinderException("Foreign key %s does not exist in table %s", fk,
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 BinderException("Foreign key %s does not exist in table %s", fk,
edge_table->table_name);
throw Exception(ExceptionType::INVALID,"Foreign key " + fk + " does not exist in table " + edge_table->table_name);
}
}
}
return make_uniq<CreatePropertyGraphBindData>(info);
}

duckdb::unique_ptr<GlobalTableFunctionState>
unique_ptr<GlobalTableFunctionState>
CreatePropertyGraphFunction::CreatePropertyGraphInit(
ClientContext &context, TableFunctionInitInput &input) {
return make_uniq<CreatePropertyGraphGlobalData>();
Expand All @@ -167,7 +160,7 @@ 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 BinderException("Registered DuckPGQ state not found");
throw Exception(ExceptionType::INVALID,"Registered DuckPGQ state not found");
}
auto duckpgq_state = (DuckPGQState *)lookup->second.get();
auto pg_lookup = duckpgq_state->registered_property_graphs.find(
Expand All @@ -176,8 +169,7 @@ void CreatePropertyGraphFunction::CreatePropertyGraphFunc(
duckpgq_state->registered_property_graphs[pg_info->property_graph_name] =
pg_info->Copy();
} else {
throw BinderException("A property graph with name %s already exists.",
pg_info->property_graph_name);
throw Exception(ExceptionType::INVALID,"A property graph with name " + pg_info->property_graph_name + " already exists.");
}
}
}; // namespace duckdb
4 changes: 2 additions & 2 deletions duckpgq/src/duckpgq/functions/tablefunctions/match.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ 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 BinderException("The label %s is not registered in property graph %s",
label, 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;
Expand Down
16 changes: 8 additions & 8 deletions duckpgq/src/duckpgq_extension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ ParserExtensionParseResult duckpgq_parse(ParserExtensionInfo *info,
parser.ParseQuery((query[0] == '-') ? query.substr(1, query.length())
: query);
if (parser.statements.size() != 1) {
throw ParserException(
throw Exception(ExceptionType::PARSER,
"More than 1 statement detected, please only give one.");
}
return {make_uniq_base<ParserExtensionParseData, DuckPGQParseData>(
Expand All @@ -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 BinderException("Registered state not found");
throw Exception(ExceptionType::BINDER, "Registered state not found");
}

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 BinderException("Unable to find DuckPGQ Parse Data");
throw Exception(ExceptionType::BINDER, "Unable to find DuckPGQ Parse Data");
}

void duckpgq_find_match_function(TableRef *table_ref,
Expand Down Expand Up @@ -135,7 +135,7 @@ duckpgq_handle_statement(SQLStatement *statement, DuckPGQState &duckpgq_state) {
const auto select_node =
dynamic_cast<SelectNode *>(select_statement->node.get());
duckpgq_find_match_function(select_node->from_table.get(), duckpgq_state);
throw Exception("use duckpgq_bind instead");
throw Exception(ExceptionType::BINDER, "use duckpgq_bind instead");
}
if (statement->type == StatementType::CREATE_STATEMENT) {
const auto &create_statement = statement->Cast<CreateStatement>();
Expand Down Expand Up @@ -170,7 +170,7 @@ duckpgq_handle_statement(SQLStatement *statement, DuckPGQState &duckpgq_state) {
const auto select_node =
dynamic_cast<SelectNode *>(copy_statement.select_statement.get());
duckpgq_find_match_function(select_node->from_table.get(), duckpgq_state);
throw Exception("use duckpgq_bind instead");
throw Exception(ExceptionType::BINDER, "use duckpgq_bind instead");
}
if (statement->type == StatementType::INSERT_STATEMENT) {
const auto &insert_statement = statement->Cast<InsertStatement>();
Expand All @@ -180,8 +180,8 @@ duckpgq_handle_statement(SQLStatement *statement, DuckPGQState &duckpgq_state) {

// Preferably throw NotImplementedExpection here, but only BinderExceptions
// are caught properly on MacOS right now
throw BinderException("%s has not been implemented yet for DuckPGQ queries",
StatementTypeToString(statement->type));
throw Exception(ExceptionType::NOT_IMPLEMENTED,
StatementTypeToString(statement->type) + "has not been implemented yet for DuckPGQ queries");
}

ParserExtensionPlanResult
Expand All @@ -201,7 +201,7 @@ duckpgq_plan(ParserExtensionInfo *, ClientContext &context,
dynamic_cast<DuckPGQParseData *>(duckpgq_state->parse_data.get());

if (!duckpgq_parse_data) {
throw BinderException("No DuckPGQ parse data found");
throw Exception(ExceptionType::BINDER, "No DuckPGQ parse data found");
}

auto statement = duckpgq_parse_data->statement.get();
Expand Down
1 change: 1 addition & 0 deletions test/sql/altering_table.test
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,4 @@ statement error
WHERE a.name = 'Daniel'
COLUMNS (a.jd)
) study;
----
6 changes: 3 additions & 3 deletions test/sql/create_pg/create_property_graph.test
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ EDGE TABLES (
PROPERTIES ( createDate ) LABEL Knows
)
----
Binder Error: Property graph table with name pg already exists
Invalid Error: Property graph table with name pg already exists

# Alias for the vertex table
statement ok
Expand Down Expand Up @@ -130,7 +130,7 @@ EDGE TABLES (
PROPERTIES ( createDate ) LABEL Knows
)
----
Binder Error: Referenced vertex table Student does not exist.
Invalid Error: Referenced vertex table Student does not exist.


# Should fail since the edge table references vertex tables that do not exist
Expand All @@ -145,4 +145,4 @@ EDGE TABLES (
PROPERTIES ( createDate ) LABEL Knows
);
----
Binder Error: Referenced vertex table Student does not exist.
Invalid Error: Referenced vertex table Student does not exist.
2 changes: 2 additions & 0 deletions test/sql/create_pg/drop_property_graph.test
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ FROM GRAPH_TABLE (pg
(a:Person)
COLUMNS (a.id)
) study;
----
Binder Error: Property graph pg does not exist

statement ok
-CREATE PROPERTY GRAPH pg
Expand Down
4 changes: 3 additions & 1 deletion test/sql/create_pg/optional_edge_table_clause.test
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ statement error
-FROM GRAPH_TABLE (snb
MATCH (p:Person)-[k:Knows]->(p2:Person)
COLUMNS (*)
) tmp
) tmp
----
Binder Error: The label knows is not registered in property graph snb
21 changes: 11 additions & 10 deletions test/sql/path-finding/complex_matching.test
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,19 @@ query III
MATCH o = ANY SHORTEST (p:Person)-[w:knows]-> {1,3}(p2:Person)-[i:hasInterest]->(t:Tag)
COLUMNS (p.id as p_id, p2.id as p2_id, t.id)
) tmp
ORDER BY p_id, p2_id
limit 10;
----
14 32985348833329 3
14 32985348833329 139
14 30786325577731 196
14 28587302322196 280
14 28587302322180 294
14 24189255811081 295
14 28587302322196 448
14 32985348833329 470
14 28587302322196 540
14 24189255811109 543
14 10995116277782 598
14 10995116277782 805
14 10995116277782 1174
14 10995116277782 1183
14 10995116277782 1527
14 10995116277782 1676
14 10995116277782 1998
14 10995116277782 798
14 10995116277782 1031
14 10995116277782 1986

query IIIII
WITH CTE1 AS (SELECT CREATE_CSR_EDGE(
Expand Down
2 changes: 2 additions & 0 deletions test/sql/path-finding/shortest_path.test
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ statement error
WHERE a.name = 'Daniel'
COLUMNS (p, a.name as name, b.name as b_name)
) study;
----
Binder Error: Referenced column "p" not found in FROM clause!


query III
Expand Down
3 changes: 3 additions & 0 deletions test/sql/pattern-matching/basic_match.test
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ FROM GRAPH_TABLE (pg
(:Person)-[k:Knows]->(b:Person)
COLUMNS (a.name as a_name, b.name as b_name)
) study;
----

statement error
-SELECT study.a_name, study.b_name, study.c_name
Expand All @@ -206,6 +207,7 @@ FROM GRAPH_TABLE (pg
(a)-[k:Knows]->(b:Person)
COLUMNS (a.ncame as a_name, b.name as b_name)
) study;
----

statement error
-SELECT study.a_name, study.b_name, study.c_name
Expand All @@ -214,6 +216,7 @@ FROM GRAPH_TABLE (pg
()-[k:Knows]->(b:Person)
COLUMNS (a.name as a_name, b.name as b_name)
) study;
----


query II
Expand Down
Loading

0 comments on commit e308c27

Please sign in to comment.