Skip to content

Commit

Permalink
Merge pull request #195 from cwida/19-support-create-or-replace-prope…
Browse files Browse the repository at this point in the history
…rty-graph

Add support for CREATE OR REPLACE PROPERTY GRAPH
  • Loading branch information
Dtenwolde committed Mar 8, 2024
2 parents e55aa6d + 65a432e commit 8bd29f5
Show file tree
Hide file tree
Showing 5 changed files with 18,355 additions and 18,296 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ Transformer::TransformCreatePropertyGraph(duckdb_libpgquery::PGCreatePropertyGra
case_insensitive_map_t<string> table_alias_map;
auto property_graph_name = TransformQualifiedName(*stmt.name);
info->property_graph_name = property_graph_name.name;

info->on_conflict = TransformOnConflict(stmt.onconflict);
D_ASSERT(stmt.vertex_tables);
for (auto &vertex_table = stmt.vertex_tables->head; vertex_table != nullptr; vertex_table = lnext(vertex_table)) {
auto node = reinterpret_cast<duckdb_libpgquery::PGNode *>(vertex_table->data.ptr_value);
Expand Down
15 changes: 15 additions & 0 deletions third_party/libpg_query/grammar/statements/pgq.y
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,24 @@ CreatePropertyGraphStmt:
n->name = $4;
n->vertex_tables = $9?lappend($9,$8):list_make1($8);
n->edge_tables = $11;
n->onconflict = PG_ERROR_ON_CONFLICT;
$$ = (PGNode *)n;
}
;
|
CREATE_P OR REPLACE PROPERTY GRAPH qualified_name
VertexOrNode TABLES '(' VertexTableDefinition VertexTableDefinitionList ')'
EdgeTablesClauseOptional
{
PGCreatePropertyGraphStmt *n = makeNode(PGCreatePropertyGraphStmt);
n->name = $6;
n->vertex_tables = $11?lappend($11,$10):list_make1($10);
n->edge_tables = $13;
n->onconflict = PG_REPLACE_ON_CONFLICT;
$$ = (PGNode *)n;
}
;


VertexTableDefinitionList:
',' VertexTableDefinition
Expand Down
4 changes: 2 additions & 2 deletions third_party/libpg_query/include/nodes/nodes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,8 @@ typedef enum PGNodeTag {
T_PGAttachStmt,
T_PGDetachStmt,
T_PGUseStmt,
T_PGDropPropertyGraphStmt, /* SQL/PGQ extension */
T_PGCreatePropertyGraphStmt, /* SQL/PGQ extension */
T_PGDropPropertyGraphStmt, /* SQL/PGQ extension */
T_PGCreatePropertyGraphStmt, /* SQL/PGQ extension */

/*
* TAGS FOR PARSE TREE NODES (parsenodes.h)
Expand Down
1 change: 1 addition & 0 deletions third_party/libpg_query/include/nodes/parsenodes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2178,6 +2178,7 @@ typedef struct PGCreatePropertyGraphStmt {
PGRangeVar *name;
PGList *vertex_tables;
PGList *edge_tables;
PGOnCreateConflict onconflict; /* what to do on create conflict */
} PGCreatePropertyGraphStmt;

typedef struct PGPropertyGraphTable {
Expand Down
Loading

0 comments on commit 8bd29f5

Please sign in to comment.