diff --git a/duckpgq/src/duckpgq_extension.cpp b/duckpgq/src/duckpgq_extension.cpp index 9148bdac..a607ad8c 100644 --- a/duckpgq/src/duckpgq_extension.cpp +++ b/duckpgq/src/duckpgq_extension.cpp @@ -13,6 +13,8 @@ #include "duckdb/parser/parsed_data/create_table_function_info.hpp" #include "duckdb/parser/query_node/select_node.hpp" #include "duckdb/parser/statement/copy_statement.hpp" +#include "duckdb/parser/parsed_data/create_table_info.hpp" + #include "duckdb/parser/statement/extension_statement.hpp" #include "duckpgq/functions/tablefunctions/drop_property_graph.hpp" @@ -120,11 +122,17 @@ ParserExtensionPlanResult duckpgq_handle_statement(SQLStatement *statement, Duck throw Exception("use duckpgq_bind instead"); } if (statement->type == StatementType::CREATE_STATEMENT) { - ParserExtensionPlanResult result; - result.function = CreatePropertyGraphFunction(); - result.requires_valid_transaction = true; - result.return_type = StatementReturnType::QUERY_RESULT; - return result; + auto &create_statement = statement->Cast(); + auto create_property_graph = dynamic_cast(create_statement.info.get()); + if (create_property_graph) { + ParserExtensionPlanResult result; + result.function = CreatePropertyGraphFunction(); + result.requires_valid_transaction = true; + result.return_type = StatementReturnType::QUERY_RESULT; + return result; + } + auto create_table = reinterpret_cast(create_statement.info.get()); + duckpgq_handle_statement(create_table->query.get(), duckpgq_state); } if (statement->type == StatementType::DROP_STATEMENT) { ParserExtensionPlanResult result; diff --git a/test/sql/copy_to_duckpgq.test b/test/sql/copy_to_duckpgq.test index f770c0c2..66cc7c84 100644 --- a/test/sql/copy_to_duckpgq.test +++ b/test/sql/copy_to_duckpgq.test @@ -56,7 +56,18 @@ statement ok COLUMNS(a.firstName, a.lastName, a.birthday, a.locationIP, a.browserUsed, a.LocationCityId, a.gender, a.creationDate) ) tmp) TO '__TEST_DIR__/is1.csv' (HEADER FALSE); -query IIIIIII +query IIIIIIII SELECT * FROM '__TEST_DIR__/is1.csv'; ---- Ali Abouba 1987-05-29 41.203.147.168 Internet Explorer 1264 male 2011-05-12 02:46:47.595 + +statement ok +-CREATE TABLE result as (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