From 9d8fcb759fa3dd285caa57a250512355edfff7c2 Mon Sep 17 00:00:00 2001 From: dtenwolde Date: Fri, 19 Jan 2024 10:28:41 +0100 Subject: [PATCH] Insert statement also works --- duckpgq/src/duckpgq_extension.cpp | 7 +++++++ test/sql/copy_to_duckpgq.test | 12 ++++++++++++ 2 files changed, 19 insertions(+) diff --git a/duckpgq/src/duckpgq_extension.cpp b/duckpgq/src/duckpgq_extension.cpp index a607ad8c..cd5b3dfb 100644 --- a/duckpgq/src/duckpgq_extension.cpp +++ b/duckpgq/src/duckpgq_extension.cpp @@ -1,6 +1,9 @@ #define DUCKDB_EXTENSION_MAIN #include "duckpgq_extension.hpp" + +#include + #include "duckdb/function/scalar_function.hpp" #include "duckpgq/duckpgq_functions.hpp" @@ -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(); + 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)); diff --git a/test/sql/copy_to_duckpgq.test b/test/sql/copy_to_duckpgq.test index 66cc7c84..a0e12974 100644 --- a/test/sql/copy_to_duckpgq.test +++ b/test/sql/copy_to_duckpgq.test @@ -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