Skip to content

Commit

Permalink
Insert statement also works
Browse files Browse the repository at this point in the history
  • Loading branch information
Dtenwolde committed Jan 19, 2024
1 parent a7dfd00 commit 9d8fcb7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions duckpgq/src/duckpgq_extension.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#define DUCKDB_EXTENSION_MAIN

#include "duckpgq_extension.hpp"

#include <duckdb/parser/statement/insert_statement.hpp>

#include "duckdb/function/scalar_function.hpp"
#include "duckpgq/duckpgq_functions.hpp"

Expand Down Expand Up @@ -160,6 +163,10 @@ ParserExtensionPlanResult duckpgq_handle_statement(SQLStatement *statement, Duck
}
throw Exception("use duckpgq_bind instead");
}
if (statement->type == StatementType::INSERT_STATEMENT) {
auto &insert_statement = statement->Cast<InsertStatement>();
duckpgq_handle_statement(insert_statement.select_statement.get(), 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));
Expand Down
12 changes: 12 additions & 0 deletions test/sql/copy_to_duckpgq.test
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,15 @@ query IIIIIIII
SELECT * FROM result;
----
Ali Abouba 1987-05-29 41.203.147.168 Internet Explorer 1264 male 2011-05-12 02:46:47.595+00

statement ok
-INSERT INTO result (FROM GRAPH_TABLE (snb
MATCH (a is person where a.id = 17592186044461)
COLUMNS(a.firstName, a.lastName, a.birthday, a.locationIP, a.browserUsed, a.LocationCityId, a.gender, a.creationDate)
) tmp)

query IIIIIIII
SELECT * FROM result;
----
Ali Abouba 1987-05-29 41.203.147.168 Internet Explorer 1264 male 2011-05-12 02:46:47.595+00
Ali Abouba 1987-05-29 41.203.147.168 Internet Explorer 1264 male 2011-05-12 02:46:47.595+00

0 comments on commit 9d8fcb7

Please sign in to comment.