From 96c9ff167d6af8ef5ea5a4eb5722d244a5534f1d Mon Sep 17 00:00:00 2001 From: apstndb <803393+apstndb@users.noreply.github.com> Date: Thu, 19 Sep 2024 17:23:36 +0900 Subject: [PATCH] Improve tryParsePropertyGraphElementKeys --- parser.go | 18 +- ...eplace_property_graph_fingraph_verbose.sql | 28 ++ ...property_graph_if_not_exists_fingraph.sql} | 2 +- ...y_graph_if_not_exists_fingraph_verbose.sql | 19 -- ...e_property_graph_fingraph_verbose.sql.txt} | 315 ++++++++++-------- ...erty_graph_if_not_exists_fingraph.sql.txt} | 140 ++++---- ...e_property_graph_fingraph_verbose.sql.txt} | 315 ++++++++++-------- ...erty_graph_if_not_exists_fingraph.sql.txt} | 140 ++++---- 8 files changed, 521 insertions(+), 456 deletions(-) create mode 100644 testdata/input/ddl/create_or_replace_property_graph_fingraph_verbose.sql rename testdata/input/ddl/{create_or_replace_property_graph_fingraph.sql => create_property_graph_if_not_exists_fingraph.sql} (88%) delete mode 100644 testdata/input/ddl/create_property_graph_if_not_exists_fingraph_verbose.sql rename testdata/result/{statement/create_property_graph_if_not_exists_fingraph_verbose.sql.txt => ddl/create_or_replace_property_graph_fingraph_verbose.sql.txt} (50%) rename testdata/result/{statement/create_or_replace_property_graph_fingraph.sql.txt => ddl/create_property_graph_if_not_exists_fingraph.sql.txt} (67%) rename testdata/result/{ddl/create_property_graph_if_not_exists_fingraph_verbose.sql.txt => statement/create_or_replace_property_graph_fingraph_verbose.sql.txt} (50%) rename testdata/result/{ddl/create_or_replace_property_graph_fingraph.sql.txt => statement/create_property_graph_if_not_exists_fingraph.sql.txt} (67%) diff --git a/parser.go b/parser.go index b734083a..98087673 100644 --- a/parser.go +++ b/parser.go @@ -3567,18 +3567,27 @@ func (p *Parser) tryParsePropertyGraphElementKeys() ast.PropertyGraphElementKeys return nil } + // element_key + var elementKey *ast.PropertyGraphElementKey if key := p.tryExpectKeywordLike("KEY"); key != nil { keyColumns := p.parsePropertyGraphColumnNameList() - elementKey := &ast.PropertyGraphElementKey{ + elementKey = &ast.PropertyGraphElementKey{ Key: key.Pos, Keys: keyColumns, } - return &ast.PropertyGraphNodeElementKey{ - PropertyGraphElementKey: *elementKey, + + // if SOURCE KEY doesn't follow, it is node_element_key. + if !p.Token.IsKeywordLike("SOURCE") { + return &ast.PropertyGraphNodeElementKey{ + PropertyGraphElementKey: *elementKey, + } } } + // the rest of edge_element_keys + + // source_key source := p.expectKeywordLike("SOURCE").Pos p.expectKeywordLike("KEY") sourceColumns := p.parsePropertyGraphColumnNameList() @@ -3586,6 +3595,7 @@ func (p *Parser) tryParsePropertyGraphElementKeys() ast.PropertyGraphElementKeys sourceReference := p.parseIdent() sourceReferenceColumns := p.tryParsePropertyGraphColumnNameList() + // destination_key destination := p.expectKeywordLike("DESTINATION").Pos p.expectKeywordLike("KEY") destinationColumns := p.parsePropertyGraphColumnNameList() @@ -3594,7 +3604,7 @@ func (p *Parser) tryParsePropertyGraphElementKeys() ast.PropertyGraphElementKeys destinationReferenceColumns := p.tryParsePropertyGraphColumnNameList() return &ast.PropertyGraphEdgeElementKeys{ - // Element: elementKey, + Element: elementKey, Source: &ast.PropertyGraphSourceKey{ Source: source, Keys: sourceColumns, diff --git a/testdata/input/ddl/create_or_replace_property_graph_fingraph_verbose.sql b/testdata/input/ddl/create_or_replace_property_graph_fingraph_verbose.sql new file mode 100644 index 00000000..2e97e23c --- /dev/null +++ b/testdata/input/ddl/create_or_replace_property_graph_fingraph_verbose.sql @@ -0,0 +1,28 @@ +CREATE OR REPLACE PROPERTY GRAPH FinGraph + NODE TABLES ( + Account AS Account -- element_alias + KEY (id) -- element_key in node_element_key in element_keys + -- label_and_property_list + LABEL DetailedAccount -- LABEL label_name in element_label + PROPERTIES (create_time, is_blocked, nick_name AS name) -- derived_property_list + DEFAULT LABEL -- DEFAULT LABEL in element_label + NO PROPERTIES -- NO PROPERTIES in element_properties + , + Person + -- no element_keys + -- no element_label because of direct element_properties + PROPERTIES ARE ALL COLUMNS EXCEPT (city) -- properties_are + ) + EDGE TABLES ( + PersonOwnAccount AS PersonOwnAccount + KEY (id, account_id) + SOURCE KEY (id) REFERENCES Person -- source_key without column_name_list + DESTINATION KEY (account_id) REFERENCES Account -- destination_key without column_name_list + LABEL Owns + PROPERTIES ALL COLUMNS, + AccountTransferAccount + SOURCE KEY (id) REFERENCES Account (id) -- source_key + DESTINATION KEY (to_id) REFERENCES Account (id) -- destination_key + LABEL Transfers -- LABEL label_name in element_label + -- without element_properties + ) \ No newline at end of file diff --git a/testdata/input/ddl/create_or_replace_property_graph_fingraph.sql b/testdata/input/ddl/create_property_graph_if_not_exists_fingraph.sql similarity index 88% rename from testdata/input/ddl/create_or_replace_property_graph_fingraph.sql rename to testdata/input/ddl/create_property_graph_if_not_exists_fingraph.sql index e432bf76..632af155 100644 --- a/testdata/input/ddl/create_or_replace_property_graph_fingraph.sql +++ b/testdata/input/ddl/create_property_graph_if_not_exists_fingraph.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE PROPERTY GRAPH FinGraph +CREATE PROPERTY GRAPH IF NOT EXISTS FinGraph NODE TABLES ( Account, Person diff --git a/testdata/input/ddl/create_property_graph_if_not_exists_fingraph_verbose.sql b/testdata/input/ddl/create_property_graph_if_not_exists_fingraph_verbose.sql deleted file mode 100644 index 67d6190c..00000000 --- a/testdata/input/ddl/create_property_graph_if_not_exists_fingraph_verbose.sql +++ /dev/null @@ -1,19 +0,0 @@ -CREATE PROPERTY GRAPH IF NOT EXISTS FinGraph - NODE TABLES ( - Account AS Account - DEFAULT LABEL - PROPERTIES (create_time, is_blocked, nick_name AS name), - Person - LABEL Person - PROPERTIES ALL COLUMNS - ) - EDGE TABLES ( - PersonOwnAccount - SOURCE KEY (id) REFERENCES Person (id) - DESTINATION KEY (account_id) REFERENCES Account (id) - LABEL Owns PROPERTIES ALL COLUMNS EXCEPT (a), - AccountTransferAccount - SOURCE KEY (id) REFERENCES Account (id) - DESTINATION KEY (to_id) REFERENCES Account (id) - LABEL Transfers NO PROPERTIES - ) \ No newline at end of file diff --git a/testdata/result/statement/create_property_graph_if_not_exists_fingraph_verbose.sql.txt b/testdata/result/ddl/create_or_replace_property_graph_fingraph_verbose.sql.txt similarity index 50% rename from testdata/result/statement/create_property_graph_if_not_exists_fingraph_verbose.sql.txt rename to testdata/result/ddl/create_or_replace_property_graph_fingraph_verbose.sql.txt index 27ed080d..b4cad616 100644 --- a/testdata/result/statement/create_property_graph_if_not_exists_fingraph_verbose.sql.txt +++ b/testdata/result/ddl/create_or_replace_property_graph_fingraph_verbose.sql.txt @@ -1,119 +1,153 @@ ---- create_property_graph_if_not_exists_fingraph_verbose.sql -CREATE PROPERTY GRAPH IF NOT EXISTS FinGraph +--- create_or_replace_property_graph_fingraph_verbose.sql +CREATE OR REPLACE PROPERTY GRAPH FinGraph NODE TABLES ( - Account AS Account - DEFAULT LABEL - PROPERTIES (create_time, is_blocked, nick_name AS name), + Account AS Account -- element_alias + KEY (id) -- element_key in node_element_key in element_keys + -- label_and_property_list + LABEL DetailedAccount -- LABEL label_name in element_label + PROPERTIES (create_time, is_blocked, nick_name AS name) -- derived_property_list + DEFAULT LABEL -- DEFAULT LABEL in element_label + NO PROPERTIES -- NO PROPERTIES in element_properties + , Person - LABEL Person - PROPERTIES ALL COLUMNS + -- no element_keys + -- no element_label because of direct element_properties + PROPERTIES ARE ALL COLUMNS EXCEPT (city) -- properties_are ) EDGE TABLES ( - PersonOwnAccount - SOURCE KEY (id) REFERENCES Person (id) - DESTINATION KEY (account_id) REFERENCES Account (id) - LABEL Owns PROPERTIES ALL COLUMNS EXCEPT (a), + PersonOwnAccount AS PersonOwnAccount + KEY (id, account_id) + SOURCE KEY (id) REFERENCES Person -- source_key without column_name_list + DESTINATION KEY (account_id) REFERENCES Account -- destination_key without column_name_list + LABEL Owns + PROPERTIES ALL COLUMNS, AccountTransferAccount - SOURCE KEY (id) REFERENCES Account (id) - DESTINATION KEY (to_id) REFERENCES Account (id) - LABEL Transfers NO PROPERTIES + SOURCE KEY (id) REFERENCES Account (id) -- source_key + DESTINATION KEY (to_id) REFERENCES Account (id) -- destination_key + LABEL Transfers -- LABEL label_name in element_label + -- without element_properties ) --- AST &ast.CreatePropertyGraph{ Create: 0, - OrReplace: false, - IfNotExists: true, + OrReplace: true, + IfNotExists: false, Name: &ast.Ident{ - NamePos: 36, - NameEnd: 44, + NamePos: 33, + NameEnd: 41, Name: "FinGraph", }, Content: &ast.PropertyGraphContent{ - Node: 47, + Node: 44, NodeTables: &ast.PropertyGraphElementList{ - LParen: 59, - RParen: 232, + LParen: 56, + RParen: 638, Elements: []*ast.PropertyGraphElement{ &ast.PropertyGraphElement{ Name: &ast.Ident{ - NamePos: 65, - NameEnd: 72, + NamePos: 62, + NameEnd: 69, Name: "Account", }, Alias: &ast.Ident{ - NamePos: 76, - NameEnd: 83, + NamePos: 73, + NameEnd: 80, Name: "Account", }, - Keys: nil, + Keys: &ast.PropertyGraphNodeElementKey{ + PropertyGraphElementKey: ast.PropertyGraphElementKey{ + Key: 104, + Keys: &ast.PropertyGraphColumnNameList{ + LParen: 108, + RParen: 111, + ColumnNameList: []*ast.Ident{ + &ast.Ident{ + NamePos: 109, + NameEnd: 111, + Name: "id", + }, + }, + }, + }, + }, Properties: &ast.PropertyGraphLabelAndPropertiesList{ LabelAndProperties: []*ast.PropertyGraphLabelAndProperties{ &ast.PropertyGraphLabelAndProperties{ - Label: &ast.PropertyGraphElementLabelDefaultLabel{ - Default: 91, - Label: 99, + Label: &ast.PropertyGraphElementLabelLabelName{ + Label: 203, + Name: &ast.Ident{ + NamePos: 209, + NameEnd: 224, + Name: "DetailedAccount", + }, }, Properties: &ast.PropertyGraphDerivedPropertyList{ - Properties: 112, - RParen: 166, + Properties: 270, + RParen: 324, DerivedProperties: []*ast.PropertyGraphDerivedProperty{ &ast.PropertyGraphDerivedProperty{ Expr: &ast.Ident{ - NamePos: 124, - NameEnd: 135, + NamePos: 282, + NameEnd: 293, Name: "create_time", }, PropertyName: (*ast.Ident)(nil), }, &ast.PropertyGraphDerivedProperty{ Expr: &ast.Ident{ - NamePos: 137, - NameEnd: 147, + NamePos: 295, + NameEnd: 305, Name: "is_blocked", }, PropertyName: (*ast.Ident)(nil), }, &ast.PropertyGraphDerivedProperty{ Expr: &ast.Ident{ - NamePos: 149, - NameEnd: 158, + NamePos: 307, + NameEnd: 316, Name: "nick_name", }, PropertyName: &ast.Ident{ - NamePos: 162, - NameEnd: 166, + NamePos: 320, + NameEnd: 324, Name: "name", }, }, }, }, }, + &ast.PropertyGraphLabelAndProperties{ + Label: &ast.PropertyGraphElementLabelDefaultLabel{ + Default: 357, + Label: 365, + }, + Properties: &ast.PropertyGraphNoProperties{ + No: 413, + Properties: 416, + }, + }, }, }, }, &ast.PropertyGraphElement{ Name: &ast.Ident{ - NamePos: 173, - NameEnd: 179, + NamePos: 476, + NameEnd: 482, Name: "Person", }, Alias: (*ast.Ident)(nil), Keys: nil, - Properties: &ast.PropertyGraphLabelAndPropertiesList{ - LabelAndProperties: []*ast.PropertyGraphLabelAndProperties{ - &ast.PropertyGraphLabelAndProperties{ - Label: &ast.PropertyGraphElementLabelLabelName{ - Label: 187, - Name: &ast.Ident{ - NamePos: 193, - NameEnd: 199, - Name: "Person", - }, - }, - Properties: &ast.PropertyGraphPropertiesAre{ - Properties: 207, - Columns: 222, - ExceptColumns: (*ast.PropertyGraphColumnNameList)(nil), + Properties: &ast.PropertyGraphPropertiesAre{ + Properties: 577, + Columns: 596, + ExceptColumns: &ast.PropertyGraphColumnNameList{ + LParen: 611, + RParen: 616, + ColumnNameList: []*ast.Ident{ + &ast.Ident{ + NamePos: 612, + NameEnd: 616, + Name: "city", }, }, }, @@ -122,104 +156,96 @@ CREATE PROPERTY GRAPH IF NOT EXISTS FinGraph }, }, EdgeTables: &ast.PropertyGraphElementList{ - LParen: 248, - RParen: 592, + LParen: 654, + RParen: 1207, Elements: []*ast.PropertyGraphElement{ &ast.PropertyGraphElement{ Name: &ast.Ident{ - NamePos: 254, - NameEnd: 270, + NamePos: 660, + NameEnd: 676, Name: "PersonOwnAccount", }, - Alias: (*ast.Ident)(nil), - Keys: &ast.PropertyGraphEdgeElementKeys{ - Element: (*ast.PropertyGraphElementKey)(nil), - Source: &ast.PropertyGraphSourceKey{ - Source: 277, - Keys: &ast.PropertyGraphColumnNameList{ - LParen: 288, - RParen: 291, + Alias: &ast.Ident{ + NamePos: 680, + NameEnd: 696, + Name: "PersonOwnAccount", + }, + Keys: &ast.PropertyGraphEdgeElementKeys{ + Element: &ast.PropertyGraphElementKey{ + Key: 703, + Keys: &ast.PropertyGraphColumnNameList{ + LParen: 707, + RParen: 722, ColumnNameList: []*ast.Ident{ &ast.Ident{ - NamePos: 289, - NameEnd: 291, + NamePos: 708, + NameEnd: 710, Name: "id", }, + &ast.Ident{ + NamePos: 712, + NameEnd: 722, + Name: "account_id", + }, }, }, - ElementReference: &ast.Ident{ - NamePos: 304, - NameEnd: 310, - Name: "Person", - }, - ReferenceColumns: &ast.PropertyGraphColumnNameList{ - LParen: 311, - RParen: 314, + }, + Source: &ast.PropertyGraphSourceKey{ + Source: 730, + Keys: &ast.PropertyGraphColumnNameList{ + LParen: 741, + RParen: 744, ColumnNameList: []*ast.Ident{ &ast.Ident{ - NamePos: 312, - NameEnd: 314, + NamePos: 742, + NameEnd: 744, Name: "id", }, }, }, + ElementReference: &ast.Ident{ + NamePos: 757, + NameEnd: 763, + Name: "Person", + }, + ReferenceColumns: (*ast.PropertyGraphColumnNameList)(nil), }, Destination: &ast.PropertyGraphDestinationKey{ - Destination: 322, + Destination: 809, Keys: &ast.PropertyGraphColumnNameList{ - LParen: 338, - RParen: 349, + LParen: 825, + RParen: 836, ColumnNameList: []*ast.Ident{ &ast.Ident{ - NamePos: 339, - NameEnd: 349, + NamePos: 826, + NameEnd: 836, Name: "account_id", }, }, }, ElementReference: &ast.Ident{ - NamePos: 362, - NameEnd: 369, + NamePos: 849, + NameEnd: 856, Name: "Account", }, - ReferenceColumns: &ast.PropertyGraphColumnNameList{ - LParen: 370, - RParen: 373, - ColumnNameList: []*ast.Ident{ - &ast.Ident{ - NamePos: 371, - NameEnd: 373, - Name: "id", - }, - }, - }, + ReferenceColumns: (*ast.PropertyGraphColumnNameList)(nil), }, }, Properties: &ast.PropertyGraphLabelAndPropertiesList{ LabelAndProperties: []*ast.PropertyGraphLabelAndProperties{ &ast.PropertyGraphLabelAndProperties{ Label: &ast.PropertyGraphElementLabelLabelName{ - Label: 381, + Label: 907, Name: &ast.Ident{ - NamePos: 387, - NameEnd: 391, + NamePos: 913, + NameEnd: 917, Name: "Owns", }, }, Properties: &ast.PropertyGraphPropertiesAre{ - Properties: 392, - Columns: 407, - ExceptColumns: &ast.PropertyGraphColumnNameList{ - LParen: 422, - RParen: 424, - ColumnNameList: []*ast.Ident{ - &ast.Ident{ - NamePos: 423, - NameEnd: 424, - Name: "a", - }, - }, - }, + Properties: 926, + Columns: 941, + ExceptColumns: (*ast.PropertyGraphColumnNameList)(nil), }, }, }, @@ -227,68 +253,68 @@ CREATE PROPERTY GRAPH IF NOT EXISTS FinGraph }, &ast.PropertyGraphElement{ Name: &ast.Ident{ - NamePos: 431, - NameEnd: 453, + NamePos: 954, + NameEnd: 976, Name: "AccountTransferAccount", }, Alias: (*ast.Ident)(nil), Keys: &ast.PropertyGraphEdgeElementKeys{ Element: (*ast.PropertyGraphElementKey)(nil), Source: &ast.PropertyGraphSourceKey{ - Source: 460, + Source: 983, Keys: &ast.PropertyGraphColumnNameList{ - LParen: 471, - RParen: 474, + LParen: 994, + RParen: 997, ColumnNameList: []*ast.Ident{ &ast.Ident{ - NamePos: 472, - NameEnd: 474, + NamePos: 995, + NameEnd: 997, Name: "id", }, }, }, ElementReference: &ast.Ident{ - NamePos: 487, - NameEnd: 494, + NamePos: 1010, + NameEnd: 1017, Name: "Account", }, ReferenceColumns: &ast.PropertyGraphColumnNameList{ - LParen: 495, - RParen: 498, + LParen: 1018, + RParen: 1021, ColumnNameList: []*ast.Ident{ &ast.Ident{ - NamePos: 496, - NameEnd: 498, + NamePos: 1019, + NameEnd: 1021, Name: "id", }, }, }, }, Destination: &ast.PropertyGraphDestinationKey{ - Destination: 506, + Destination: 1043, Keys: &ast.PropertyGraphColumnNameList{ - LParen: 522, - RParen: 528, + LParen: 1059, + RParen: 1065, ColumnNameList: []*ast.Ident{ &ast.Ident{ - NamePos: 523, - NameEnd: 528, + NamePos: 1060, + NameEnd: 1065, Name: "to_id", }, }, }, ElementReference: &ast.Ident{ - NamePos: 541, - NameEnd: 548, + NamePos: 1078, + NameEnd: 1085, Name: "Account", }, ReferenceColumns: &ast.PropertyGraphColumnNameList{ - LParen: 549, - RParen: 552, + LParen: 1086, + RParen: 1089, ColumnNameList: []*ast.Ident{ &ast.Ident{ - NamePos: 550, - NameEnd: 552, + NamePos: 1087, + NameEnd: 1089, Name: "id", }, }, @@ -299,17 +325,14 @@ CREATE PROPERTY GRAPH IF NOT EXISTS FinGraph LabelAndProperties: []*ast.PropertyGraphLabelAndProperties{ &ast.PropertyGraphLabelAndProperties{ Label: &ast.PropertyGraphElementLabelLabelName{ - Label: 560, + Label: 1116, Name: &ast.Ident{ - NamePos: 566, - NameEnd: 575, + NamePos: 1122, + NameEnd: 1131, Name: "Transfers", }, }, - Properties: &ast.PropertyGraphNoProperties{ - No: 576, - Properties: 579, - }, + Properties: nil, }, }, }, @@ -320,4 +343,4 @@ CREATE PROPERTY GRAPH IF NOT EXISTS FinGraph } --- SQL -CREATE PROPERTY GRAPH IF NOT EXISTS FinGraph NODE TABLES(Account AS Account DEFAULT LABEL PROPERTIES (create_time, is_blocked, nick_name AS name), Person LABEL Person PROPERTIES ARE ALL COLUMNS) EDGE TABLES (PersonOwnAccount SOURCE KEY (id) REFERENCES Person (id) DESTINATION KEY (account_id) REFERENCES Account (id) LABEL Owns PROPERTIES ARE ALL COLUMNS EXCEPT (a), AccountTransferAccount SOURCE KEY (id) REFERENCES Account (id) DESTINATION KEY (to_id) REFERENCES Account (id) LABEL Transfers NO PROPERTIES) +CREATE OR REPLACE PROPERTY GRAPH FinGraph NODE TABLES(Account AS Account KEY (id) LABEL DetailedAccount PROPERTIES (create_time, is_blocked, nick_name AS name) DEFAULT LABEL NO PROPERTIES, Person PROPERTIES ARE ALL COLUMNS EXCEPT (city)) EDGE TABLES (PersonOwnAccount AS PersonOwnAccount KEY (id, account_id) SOURCE KEY (id) REFERENCES Person DESTINATION KEY (account_id) REFERENCES Account LABEL Owns PROPERTIES ARE ALL COLUMNS, AccountTransferAccount SOURCE KEY (id) REFERENCES Account (id) DESTINATION KEY (to_id) REFERENCES Account (id) LABEL Transfers) diff --git a/testdata/result/statement/create_or_replace_property_graph_fingraph.sql.txt b/testdata/result/ddl/create_property_graph_if_not_exists_fingraph.sql.txt similarity index 67% rename from testdata/result/statement/create_or_replace_property_graph_fingraph.sql.txt rename to testdata/result/ddl/create_property_graph_if_not_exists_fingraph.sql.txt index 7dd6b1c1..06ceb355 100644 --- a/testdata/result/statement/create_or_replace_property_graph_fingraph.sql.txt +++ b/testdata/result/ddl/create_property_graph_if_not_exists_fingraph.sql.txt @@ -1,5 +1,5 @@ ---- create_or_replace_property_graph_fingraph.sql -CREATE OR REPLACE PROPERTY GRAPH FinGraph +--- create_property_graph_if_not_exists_fingraph.sql +CREATE PROPERTY GRAPH IF NOT EXISTS FinGraph NODE TABLES ( Account, Person @@ -17,23 +17,23 @@ CREATE OR REPLACE PROPERTY GRAPH FinGraph --- AST &ast.CreatePropertyGraph{ Create: 0, - OrReplace: true, - IfNotExists: false, + OrReplace: false, + IfNotExists: true, Name: &ast.Ident{ - NamePos: 33, - NameEnd: 41, + NamePos: 36, + NameEnd: 44, Name: "FinGraph", }, Content: &ast.PropertyGraphContent{ - Node: 44, + Node: 47, NodeTables: &ast.PropertyGraphElementList{ - LParen: 56, - RParen: 84, + LParen: 59, + RParen: 87, Elements: []*ast.PropertyGraphElement{ &ast.PropertyGraphElement{ Name: &ast.Ident{ - NamePos: 62, - NameEnd: 69, + NamePos: 65, + NameEnd: 72, Name: "Account", }, Alias: (*ast.Ident)(nil), @@ -42,8 +42,8 @@ CREATE OR REPLACE PROPERTY GRAPH FinGraph }, &ast.PropertyGraphElement{ Name: &ast.Ident{ - NamePos: 75, - NameEnd: 81, + NamePos: 78, + NameEnd: 84, Name: "Person", }, Alias: (*ast.Ident)(nil), @@ -53,73 +53,73 @@ CREATE OR REPLACE PROPERTY GRAPH FinGraph }, }, EdgeTables: &ast.PropertyGraphElementList{ - LParen: 100, - RParen: 396, + LParen: 103, + RParen: 399, Elements: []*ast.PropertyGraphElement{ &ast.PropertyGraphElement{ Name: &ast.Ident{ - NamePos: 106, - NameEnd: 122, + NamePos: 109, + NameEnd: 125, Name: "PersonOwnAccount", }, Alias: (*ast.Ident)(nil), Keys: &ast.PropertyGraphEdgeElementKeys{ Element: (*ast.PropertyGraphElementKey)(nil), Source: &ast.PropertyGraphSourceKey{ - Source: 129, + Source: 132, Keys: &ast.PropertyGraphColumnNameList{ - LParen: 140, - RParen: 143, + LParen: 143, + RParen: 146, ColumnNameList: []*ast.Ident{ &ast.Ident{ - NamePos: 141, - NameEnd: 143, + NamePos: 144, + NameEnd: 146, Name: "id", }, }, }, ElementReference: &ast.Ident{ - NamePos: 156, - NameEnd: 162, + NamePos: 159, + NameEnd: 165, Name: "Person", }, ReferenceColumns: &ast.PropertyGraphColumnNameList{ - LParen: 163, - RParen: 166, + LParen: 166, + RParen: 169, ColumnNameList: []*ast.Ident{ &ast.Ident{ - NamePos: 164, - NameEnd: 166, + NamePos: 167, + NameEnd: 169, Name: "id", }, }, }, }, Destination: &ast.PropertyGraphDestinationKey{ - Destination: 174, + Destination: 177, Keys: &ast.PropertyGraphColumnNameList{ - LParen: 190, - RParen: 201, + LParen: 193, + RParen: 204, ColumnNameList: []*ast.Ident{ &ast.Ident{ - NamePos: 191, - NameEnd: 201, + NamePos: 194, + NameEnd: 204, Name: "account_id", }, }, }, ElementReference: &ast.Ident{ - NamePos: 214, - NameEnd: 221, + NamePos: 217, + NameEnd: 224, Name: "Account", }, ReferenceColumns: &ast.PropertyGraphColumnNameList{ - LParen: 222, - RParen: 225, + LParen: 225, + RParen: 228, ColumnNameList: []*ast.Ident{ &ast.Ident{ - NamePos: 223, - NameEnd: 225, + NamePos: 226, + NameEnd: 228, Name: "id", }, }, @@ -130,10 +130,10 @@ CREATE OR REPLACE PROPERTY GRAPH FinGraph LabelAndProperties: []*ast.PropertyGraphLabelAndProperties{ &ast.PropertyGraphLabelAndProperties{ Label: &ast.PropertyGraphElementLabelLabelName{ - Label: 233, + Label: 236, Name: &ast.Ident{ - NamePos: 239, - NameEnd: 243, + NamePos: 242, + NameEnd: 246, Name: "Owns", }, }, @@ -144,68 +144,68 @@ CREATE OR REPLACE PROPERTY GRAPH FinGraph }, &ast.PropertyGraphElement{ Name: &ast.Ident{ - NamePos: 249, - NameEnd: 271, + NamePos: 252, + NameEnd: 274, Name: "AccountTransferAccount", }, Alias: (*ast.Ident)(nil), Keys: &ast.PropertyGraphEdgeElementKeys{ Element: (*ast.PropertyGraphElementKey)(nil), Source: &ast.PropertyGraphSourceKey{ - Source: 278, + Source: 281, Keys: &ast.PropertyGraphColumnNameList{ - LParen: 289, - RParen: 292, + LParen: 292, + RParen: 295, ColumnNameList: []*ast.Ident{ &ast.Ident{ - NamePos: 290, - NameEnd: 292, + NamePos: 293, + NameEnd: 295, Name: "id", }, }, }, ElementReference: &ast.Ident{ - NamePos: 305, - NameEnd: 312, + NamePos: 308, + NameEnd: 315, Name: "Account", }, ReferenceColumns: &ast.PropertyGraphColumnNameList{ - LParen: 313, - RParen: 316, + LParen: 316, + RParen: 319, ColumnNameList: []*ast.Ident{ &ast.Ident{ - NamePos: 314, - NameEnd: 316, + NamePos: 317, + NameEnd: 319, Name: "id", }, }, }, }, Destination: &ast.PropertyGraphDestinationKey{ - Destination: 324, + Destination: 327, Keys: &ast.PropertyGraphColumnNameList{ - LParen: 340, - RParen: 346, + LParen: 343, + RParen: 349, ColumnNameList: []*ast.Ident{ &ast.Ident{ - NamePos: 341, - NameEnd: 346, + NamePos: 344, + NameEnd: 349, Name: "to_id", }, }, }, ElementReference: &ast.Ident{ - NamePos: 359, - NameEnd: 366, + NamePos: 362, + NameEnd: 369, Name: "Account", }, ReferenceColumns: &ast.PropertyGraphColumnNameList{ - LParen: 367, - RParen: 370, + LParen: 370, + RParen: 373, ColumnNameList: []*ast.Ident{ &ast.Ident{ - NamePos: 368, - NameEnd: 370, + NamePos: 371, + NameEnd: 373, Name: "id", }, }, @@ -216,10 +216,10 @@ CREATE OR REPLACE PROPERTY GRAPH FinGraph LabelAndProperties: []*ast.PropertyGraphLabelAndProperties{ &ast.PropertyGraphLabelAndProperties{ Label: &ast.PropertyGraphElementLabelLabelName{ - Label: 378, + Label: 381, Name: &ast.Ident{ - NamePos: 384, - NameEnd: 393, + NamePos: 387, + NameEnd: 396, Name: "Transfers", }, }, @@ -234,4 +234,4 @@ CREATE OR REPLACE PROPERTY GRAPH FinGraph } --- SQL -CREATE OR REPLACE PROPERTY GRAPH FinGraph NODE TABLES(Account, Person) EDGE TABLES (PersonOwnAccount SOURCE KEY (id) REFERENCES Person (id) DESTINATION KEY (account_id) REFERENCES Account (id) LABEL Owns, AccountTransferAccount SOURCE KEY (id) REFERENCES Account (id) DESTINATION KEY (to_id) REFERENCES Account (id) LABEL Transfers) +CREATE PROPERTY GRAPH IF NOT EXISTS FinGraph NODE TABLES(Account, Person) EDGE TABLES (PersonOwnAccount SOURCE KEY (id) REFERENCES Person (id) DESTINATION KEY (account_id) REFERENCES Account (id) LABEL Owns, AccountTransferAccount SOURCE KEY (id) REFERENCES Account (id) DESTINATION KEY (to_id) REFERENCES Account (id) LABEL Transfers) diff --git a/testdata/result/ddl/create_property_graph_if_not_exists_fingraph_verbose.sql.txt b/testdata/result/statement/create_or_replace_property_graph_fingraph_verbose.sql.txt similarity index 50% rename from testdata/result/ddl/create_property_graph_if_not_exists_fingraph_verbose.sql.txt rename to testdata/result/statement/create_or_replace_property_graph_fingraph_verbose.sql.txt index 27ed080d..b4cad616 100644 --- a/testdata/result/ddl/create_property_graph_if_not_exists_fingraph_verbose.sql.txt +++ b/testdata/result/statement/create_or_replace_property_graph_fingraph_verbose.sql.txt @@ -1,119 +1,153 @@ ---- create_property_graph_if_not_exists_fingraph_verbose.sql -CREATE PROPERTY GRAPH IF NOT EXISTS FinGraph +--- create_or_replace_property_graph_fingraph_verbose.sql +CREATE OR REPLACE PROPERTY GRAPH FinGraph NODE TABLES ( - Account AS Account - DEFAULT LABEL - PROPERTIES (create_time, is_blocked, nick_name AS name), + Account AS Account -- element_alias + KEY (id) -- element_key in node_element_key in element_keys + -- label_and_property_list + LABEL DetailedAccount -- LABEL label_name in element_label + PROPERTIES (create_time, is_blocked, nick_name AS name) -- derived_property_list + DEFAULT LABEL -- DEFAULT LABEL in element_label + NO PROPERTIES -- NO PROPERTIES in element_properties + , Person - LABEL Person - PROPERTIES ALL COLUMNS + -- no element_keys + -- no element_label because of direct element_properties + PROPERTIES ARE ALL COLUMNS EXCEPT (city) -- properties_are ) EDGE TABLES ( - PersonOwnAccount - SOURCE KEY (id) REFERENCES Person (id) - DESTINATION KEY (account_id) REFERENCES Account (id) - LABEL Owns PROPERTIES ALL COLUMNS EXCEPT (a), + PersonOwnAccount AS PersonOwnAccount + KEY (id, account_id) + SOURCE KEY (id) REFERENCES Person -- source_key without column_name_list + DESTINATION KEY (account_id) REFERENCES Account -- destination_key without column_name_list + LABEL Owns + PROPERTIES ALL COLUMNS, AccountTransferAccount - SOURCE KEY (id) REFERENCES Account (id) - DESTINATION KEY (to_id) REFERENCES Account (id) - LABEL Transfers NO PROPERTIES + SOURCE KEY (id) REFERENCES Account (id) -- source_key + DESTINATION KEY (to_id) REFERENCES Account (id) -- destination_key + LABEL Transfers -- LABEL label_name in element_label + -- without element_properties ) --- AST &ast.CreatePropertyGraph{ Create: 0, - OrReplace: false, - IfNotExists: true, + OrReplace: true, + IfNotExists: false, Name: &ast.Ident{ - NamePos: 36, - NameEnd: 44, + NamePos: 33, + NameEnd: 41, Name: "FinGraph", }, Content: &ast.PropertyGraphContent{ - Node: 47, + Node: 44, NodeTables: &ast.PropertyGraphElementList{ - LParen: 59, - RParen: 232, + LParen: 56, + RParen: 638, Elements: []*ast.PropertyGraphElement{ &ast.PropertyGraphElement{ Name: &ast.Ident{ - NamePos: 65, - NameEnd: 72, + NamePos: 62, + NameEnd: 69, Name: "Account", }, Alias: &ast.Ident{ - NamePos: 76, - NameEnd: 83, + NamePos: 73, + NameEnd: 80, Name: "Account", }, - Keys: nil, + Keys: &ast.PropertyGraphNodeElementKey{ + PropertyGraphElementKey: ast.PropertyGraphElementKey{ + Key: 104, + Keys: &ast.PropertyGraphColumnNameList{ + LParen: 108, + RParen: 111, + ColumnNameList: []*ast.Ident{ + &ast.Ident{ + NamePos: 109, + NameEnd: 111, + Name: "id", + }, + }, + }, + }, + }, Properties: &ast.PropertyGraphLabelAndPropertiesList{ LabelAndProperties: []*ast.PropertyGraphLabelAndProperties{ &ast.PropertyGraphLabelAndProperties{ - Label: &ast.PropertyGraphElementLabelDefaultLabel{ - Default: 91, - Label: 99, + Label: &ast.PropertyGraphElementLabelLabelName{ + Label: 203, + Name: &ast.Ident{ + NamePos: 209, + NameEnd: 224, + Name: "DetailedAccount", + }, }, Properties: &ast.PropertyGraphDerivedPropertyList{ - Properties: 112, - RParen: 166, + Properties: 270, + RParen: 324, DerivedProperties: []*ast.PropertyGraphDerivedProperty{ &ast.PropertyGraphDerivedProperty{ Expr: &ast.Ident{ - NamePos: 124, - NameEnd: 135, + NamePos: 282, + NameEnd: 293, Name: "create_time", }, PropertyName: (*ast.Ident)(nil), }, &ast.PropertyGraphDerivedProperty{ Expr: &ast.Ident{ - NamePos: 137, - NameEnd: 147, + NamePos: 295, + NameEnd: 305, Name: "is_blocked", }, PropertyName: (*ast.Ident)(nil), }, &ast.PropertyGraphDerivedProperty{ Expr: &ast.Ident{ - NamePos: 149, - NameEnd: 158, + NamePos: 307, + NameEnd: 316, Name: "nick_name", }, PropertyName: &ast.Ident{ - NamePos: 162, - NameEnd: 166, + NamePos: 320, + NameEnd: 324, Name: "name", }, }, }, }, }, + &ast.PropertyGraphLabelAndProperties{ + Label: &ast.PropertyGraphElementLabelDefaultLabel{ + Default: 357, + Label: 365, + }, + Properties: &ast.PropertyGraphNoProperties{ + No: 413, + Properties: 416, + }, + }, }, }, }, &ast.PropertyGraphElement{ Name: &ast.Ident{ - NamePos: 173, - NameEnd: 179, + NamePos: 476, + NameEnd: 482, Name: "Person", }, Alias: (*ast.Ident)(nil), Keys: nil, - Properties: &ast.PropertyGraphLabelAndPropertiesList{ - LabelAndProperties: []*ast.PropertyGraphLabelAndProperties{ - &ast.PropertyGraphLabelAndProperties{ - Label: &ast.PropertyGraphElementLabelLabelName{ - Label: 187, - Name: &ast.Ident{ - NamePos: 193, - NameEnd: 199, - Name: "Person", - }, - }, - Properties: &ast.PropertyGraphPropertiesAre{ - Properties: 207, - Columns: 222, - ExceptColumns: (*ast.PropertyGraphColumnNameList)(nil), + Properties: &ast.PropertyGraphPropertiesAre{ + Properties: 577, + Columns: 596, + ExceptColumns: &ast.PropertyGraphColumnNameList{ + LParen: 611, + RParen: 616, + ColumnNameList: []*ast.Ident{ + &ast.Ident{ + NamePos: 612, + NameEnd: 616, + Name: "city", }, }, }, @@ -122,104 +156,96 @@ CREATE PROPERTY GRAPH IF NOT EXISTS FinGraph }, }, EdgeTables: &ast.PropertyGraphElementList{ - LParen: 248, - RParen: 592, + LParen: 654, + RParen: 1207, Elements: []*ast.PropertyGraphElement{ &ast.PropertyGraphElement{ Name: &ast.Ident{ - NamePos: 254, - NameEnd: 270, + NamePos: 660, + NameEnd: 676, Name: "PersonOwnAccount", }, - Alias: (*ast.Ident)(nil), - Keys: &ast.PropertyGraphEdgeElementKeys{ - Element: (*ast.PropertyGraphElementKey)(nil), - Source: &ast.PropertyGraphSourceKey{ - Source: 277, - Keys: &ast.PropertyGraphColumnNameList{ - LParen: 288, - RParen: 291, + Alias: &ast.Ident{ + NamePos: 680, + NameEnd: 696, + Name: "PersonOwnAccount", + }, + Keys: &ast.PropertyGraphEdgeElementKeys{ + Element: &ast.PropertyGraphElementKey{ + Key: 703, + Keys: &ast.PropertyGraphColumnNameList{ + LParen: 707, + RParen: 722, ColumnNameList: []*ast.Ident{ &ast.Ident{ - NamePos: 289, - NameEnd: 291, + NamePos: 708, + NameEnd: 710, Name: "id", }, + &ast.Ident{ + NamePos: 712, + NameEnd: 722, + Name: "account_id", + }, }, }, - ElementReference: &ast.Ident{ - NamePos: 304, - NameEnd: 310, - Name: "Person", - }, - ReferenceColumns: &ast.PropertyGraphColumnNameList{ - LParen: 311, - RParen: 314, + }, + Source: &ast.PropertyGraphSourceKey{ + Source: 730, + Keys: &ast.PropertyGraphColumnNameList{ + LParen: 741, + RParen: 744, ColumnNameList: []*ast.Ident{ &ast.Ident{ - NamePos: 312, - NameEnd: 314, + NamePos: 742, + NameEnd: 744, Name: "id", }, }, }, + ElementReference: &ast.Ident{ + NamePos: 757, + NameEnd: 763, + Name: "Person", + }, + ReferenceColumns: (*ast.PropertyGraphColumnNameList)(nil), }, Destination: &ast.PropertyGraphDestinationKey{ - Destination: 322, + Destination: 809, Keys: &ast.PropertyGraphColumnNameList{ - LParen: 338, - RParen: 349, + LParen: 825, + RParen: 836, ColumnNameList: []*ast.Ident{ &ast.Ident{ - NamePos: 339, - NameEnd: 349, + NamePos: 826, + NameEnd: 836, Name: "account_id", }, }, }, ElementReference: &ast.Ident{ - NamePos: 362, - NameEnd: 369, + NamePos: 849, + NameEnd: 856, Name: "Account", }, - ReferenceColumns: &ast.PropertyGraphColumnNameList{ - LParen: 370, - RParen: 373, - ColumnNameList: []*ast.Ident{ - &ast.Ident{ - NamePos: 371, - NameEnd: 373, - Name: "id", - }, - }, - }, + ReferenceColumns: (*ast.PropertyGraphColumnNameList)(nil), }, }, Properties: &ast.PropertyGraphLabelAndPropertiesList{ LabelAndProperties: []*ast.PropertyGraphLabelAndProperties{ &ast.PropertyGraphLabelAndProperties{ Label: &ast.PropertyGraphElementLabelLabelName{ - Label: 381, + Label: 907, Name: &ast.Ident{ - NamePos: 387, - NameEnd: 391, + NamePos: 913, + NameEnd: 917, Name: "Owns", }, }, Properties: &ast.PropertyGraphPropertiesAre{ - Properties: 392, - Columns: 407, - ExceptColumns: &ast.PropertyGraphColumnNameList{ - LParen: 422, - RParen: 424, - ColumnNameList: []*ast.Ident{ - &ast.Ident{ - NamePos: 423, - NameEnd: 424, - Name: "a", - }, - }, - }, + Properties: 926, + Columns: 941, + ExceptColumns: (*ast.PropertyGraphColumnNameList)(nil), }, }, }, @@ -227,68 +253,68 @@ CREATE PROPERTY GRAPH IF NOT EXISTS FinGraph }, &ast.PropertyGraphElement{ Name: &ast.Ident{ - NamePos: 431, - NameEnd: 453, + NamePos: 954, + NameEnd: 976, Name: "AccountTransferAccount", }, Alias: (*ast.Ident)(nil), Keys: &ast.PropertyGraphEdgeElementKeys{ Element: (*ast.PropertyGraphElementKey)(nil), Source: &ast.PropertyGraphSourceKey{ - Source: 460, + Source: 983, Keys: &ast.PropertyGraphColumnNameList{ - LParen: 471, - RParen: 474, + LParen: 994, + RParen: 997, ColumnNameList: []*ast.Ident{ &ast.Ident{ - NamePos: 472, - NameEnd: 474, + NamePos: 995, + NameEnd: 997, Name: "id", }, }, }, ElementReference: &ast.Ident{ - NamePos: 487, - NameEnd: 494, + NamePos: 1010, + NameEnd: 1017, Name: "Account", }, ReferenceColumns: &ast.PropertyGraphColumnNameList{ - LParen: 495, - RParen: 498, + LParen: 1018, + RParen: 1021, ColumnNameList: []*ast.Ident{ &ast.Ident{ - NamePos: 496, - NameEnd: 498, + NamePos: 1019, + NameEnd: 1021, Name: "id", }, }, }, }, Destination: &ast.PropertyGraphDestinationKey{ - Destination: 506, + Destination: 1043, Keys: &ast.PropertyGraphColumnNameList{ - LParen: 522, - RParen: 528, + LParen: 1059, + RParen: 1065, ColumnNameList: []*ast.Ident{ &ast.Ident{ - NamePos: 523, - NameEnd: 528, + NamePos: 1060, + NameEnd: 1065, Name: "to_id", }, }, }, ElementReference: &ast.Ident{ - NamePos: 541, - NameEnd: 548, + NamePos: 1078, + NameEnd: 1085, Name: "Account", }, ReferenceColumns: &ast.PropertyGraphColumnNameList{ - LParen: 549, - RParen: 552, + LParen: 1086, + RParen: 1089, ColumnNameList: []*ast.Ident{ &ast.Ident{ - NamePos: 550, - NameEnd: 552, + NamePos: 1087, + NameEnd: 1089, Name: "id", }, }, @@ -299,17 +325,14 @@ CREATE PROPERTY GRAPH IF NOT EXISTS FinGraph LabelAndProperties: []*ast.PropertyGraphLabelAndProperties{ &ast.PropertyGraphLabelAndProperties{ Label: &ast.PropertyGraphElementLabelLabelName{ - Label: 560, + Label: 1116, Name: &ast.Ident{ - NamePos: 566, - NameEnd: 575, + NamePos: 1122, + NameEnd: 1131, Name: "Transfers", }, }, - Properties: &ast.PropertyGraphNoProperties{ - No: 576, - Properties: 579, - }, + Properties: nil, }, }, }, @@ -320,4 +343,4 @@ CREATE PROPERTY GRAPH IF NOT EXISTS FinGraph } --- SQL -CREATE PROPERTY GRAPH IF NOT EXISTS FinGraph NODE TABLES(Account AS Account DEFAULT LABEL PROPERTIES (create_time, is_blocked, nick_name AS name), Person LABEL Person PROPERTIES ARE ALL COLUMNS) EDGE TABLES (PersonOwnAccount SOURCE KEY (id) REFERENCES Person (id) DESTINATION KEY (account_id) REFERENCES Account (id) LABEL Owns PROPERTIES ARE ALL COLUMNS EXCEPT (a), AccountTransferAccount SOURCE KEY (id) REFERENCES Account (id) DESTINATION KEY (to_id) REFERENCES Account (id) LABEL Transfers NO PROPERTIES) +CREATE OR REPLACE PROPERTY GRAPH FinGraph NODE TABLES(Account AS Account KEY (id) LABEL DetailedAccount PROPERTIES (create_time, is_blocked, nick_name AS name) DEFAULT LABEL NO PROPERTIES, Person PROPERTIES ARE ALL COLUMNS EXCEPT (city)) EDGE TABLES (PersonOwnAccount AS PersonOwnAccount KEY (id, account_id) SOURCE KEY (id) REFERENCES Person DESTINATION KEY (account_id) REFERENCES Account LABEL Owns PROPERTIES ARE ALL COLUMNS, AccountTransferAccount SOURCE KEY (id) REFERENCES Account (id) DESTINATION KEY (to_id) REFERENCES Account (id) LABEL Transfers) diff --git a/testdata/result/ddl/create_or_replace_property_graph_fingraph.sql.txt b/testdata/result/statement/create_property_graph_if_not_exists_fingraph.sql.txt similarity index 67% rename from testdata/result/ddl/create_or_replace_property_graph_fingraph.sql.txt rename to testdata/result/statement/create_property_graph_if_not_exists_fingraph.sql.txt index 7dd6b1c1..06ceb355 100644 --- a/testdata/result/ddl/create_or_replace_property_graph_fingraph.sql.txt +++ b/testdata/result/statement/create_property_graph_if_not_exists_fingraph.sql.txt @@ -1,5 +1,5 @@ ---- create_or_replace_property_graph_fingraph.sql -CREATE OR REPLACE PROPERTY GRAPH FinGraph +--- create_property_graph_if_not_exists_fingraph.sql +CREATE PROPERTY GRAPH IF NOT EXISTS FinGraph NODE TABLES ( Account, Person @@ -17,23 +17,23 @@ CREATE OR REPLACE PROPERTY GRAPH FinGraph --- AST &ast.CreatePropertyGraph{ Create: 0, - OrReplace: true, - IfNotExists: false, + OrReplace: false, + IfNotExists: true, Name: &ast.Ident{ - NamePos: 33, - NameEnd: 41, + NamePos: 36, + NameEnd: 44, Name: "FinGraph", }, Content: &ast.PropertyGraphContent{ - Node: 44, + Node: 47, NodeTables: &ast.PropertyGraphElementList{ - LParen: 56, - RParen: 84, + LParen: 59, + RParen: 87, Elements: []*ast.PropertyGraphElement{ &ast.PropertyGraphElement{ Name: &ast.Ident{ - NamePos: 62, - NameEnd: 69, + NamePos: 65, + NameEnd: 72, Name: "Account", }, Alias: (*ast.Ident)(nil), @@ -42,8 +42,8 @@ CREATE OR REPLACE PROPERTY GRAPH FinGraph }, &ast.PropertyGraphElement{ Name: &ast.Ident{ - NamePos: 75, - NameEnd: 81, + NamePos: 78, + NameEnd: 84, Name: "Person", }, Alias: (*ast.Ident)(nil), @@ -53,73 +53,73 @@ CREATE OR REPLACE PROPERTY GRAPH FinGraph }, }, EdgeTables: &ast.PropertyGraphElementList{ - LParen: 100, - RParen: 396, + LParen: 103, + RParen: 399, Elements: []*ast.PropertyGraphElement{ &ast.PropertyGraphElement{ Name: &ast.Ident{ - NamePos: 106, - NameEnd: 122, + NamePos: 109, + NameEnd: 125, Name: "PersonOwnAccount", }, Alias: (*ast.Ident)(nil), Keys: &ast.PropertyGraphEdgeElementKeys{ Element: (*ast.PropertyGraphElementKey)(nil), Source: &ast.PropertyGraphSourceKey{ - Source: 129, + Source: 132, Keys: &ast.PropertyGraphColumnNameList{ - LParen: 140, - RParen: 143, + LParen: 143, + RParen: 146, ColumnNameList: []*ast.Ident{ &ast.Ident{ - NamePos: 141, - NameEnd: 143, + NamePos: 144, + NameEnd: 146, Name: "id", }, }, }, ElementReference: &ast.Ident{ - NamePos: 156, - NameEnd: 162, + NamePos: 159, + NameEnd: 165, Name: "Person", }, ReferenceColumns: &ast.PropertyGraphColumnNameList{ - LParen: 163, - RParen: 166, + LParen: 166, + RParen: 169, ColumnNameList: []*ast.Ident{ &ast.Ident{ - NamePos: 164, - NameEnd: 166, + NamePos: 167, + NameEnd: 169, Name: "id", }, }, }, }, Destination: &ast.PropertyGraphDestinationKey{ - Destination: 174, + Destination: 177, Keys: &ast.PropertyGraphColumnNameList{ - LParen: 190, - RParen: 201, + LParen: 193, + RParen: 204, ColumnNameList: []*ast.Ident{ &ast.Ident{ - NamePos: 191, - NameEnd: 201, + NamePos: 194, + NameEnd: 204, Name: "account_id", }, }, }, ElementReference: &ast.Ident{ - NamePos: 214, - NameEnd: 221, + NamePos: 217, + NameEnd: 224, Name: "Account", }, ReferenceColumns: &ast.PropertyGraphColumnNameList{ - LParen: 222, - RParen: 225, + LParen: 225, + RParen: 228, ColumnNameList: []*ast.Ident{ &ast.Ident{ - NamePos: 223, - NameEnd: 225, + NamePos: 226, + NameEnd: 228, Name: "id", }, }, @@ -130,10 +130,10 @@ CREATE OR REPLACE PROPERTY GRAPH FinGraph LabelAndProperties: []*ast.PropertyGraphLabelAndProperties{ &ast.PropertyGraphLabelAndProperties{ Label: &ast.PropertyGraphElementLabelLabelName{ - Label: 233, + Label: 236, Name: &ast.Ident{ - NamePos: 239, - NameEnd: 243, + NamePos: 242, + NameEnd: 246, Name: "Owns", }, }, @@ -144,68 +144,68 @@ CREATE OR REPLACE PROPERTY GRAPH FinGraph }, &ast.PropertyGraphElement{ Name: &ast.Ident{ - NamePos: 249, - NameEnd: 271, + NamePos: 252, + NameEnd: 274, Name: "AccountTransferAccount", }, Alias: (*ast.Ident)(nil), Keys: &ast.PropertyGraphEdgeElementKeys{ Element: (*ast.PropertyGraphElementKey)(nil), Source: &ast.PropertyGraphSourceKey{ - Source: 278, + Source: 281, Keys: &ast.PropertyGraphColumnNameList{ - LParen: 289, - RParen: 292, + LParen: 292, + RParen: 295, ColumnNameList: []*ast.Ident{ &ast.Ident{ - NamePos: 290, - NameEnd: 292, + NamePos: 293, + NameEnd: 295, Name: "id", }, }, }, ElementReference: &ast.Ident{ - NamePos: 305, - NameEnd: 312, + NamePos: 308, + NameEnd: 315, Name: "Account", }, ReferenceColumns: &ast.PropertyGraphColumnNameList{ - LParen: 313, - RParen: 316, + LParen: 316, + RParen: 319, ColumnNameList: []*ast.Ident{ &ast.Ident{ - NamePos: 314, - NameEnd: 316, + NamePos: 317, + NameEnd: 319, Name: "id", }, }, }, }, Destination: &ast.PropertyGraphDestinationKey{ - Destination: 324, + Destination: 327, Keys: &ast.PropertyGraphColumnNameList{ - LParen: 340, - RParen: 346, + LParen: 343, + RParen: 349, ColumnNameList: []*ast.Ident{ &ast.Ident{ - NamePos: 341, - NameEnd: 346, + NamePos: 344, + NameEnd: 349, Name: "to_id", }, }, }, ElementReference: &ast.Ident{ - NamePos: 359, - NameEnd: 366, + NamePos: 362, + NameEnd: 369, Name: "Account", }, ReferenceColumns: &ast.PropertyGraphColumnNameList{ - LParen: 367, - RParen: 370, + LParen: 370, + RParen: 373, ColumnNameList: []*ast.Ident{ &ast.Ident{ - NamePos: 368, - NameEnd: 370, + NamePos: 371, + NameEnd: 373, Name: "id", }, }, @@ -216,10 +216,10 @@ CREATE OR REPLACE PROPERTY GRAPH FinGraph LabelAndProperties: []*ast.PropertyGraphLabelAndProperties{ &ast.PropertyGraphLabelAndProperties{ Label: &ast.PropertyGraphElementLabelLabelName{ - Label: 378, + Label: 381, Name: &ast.Ident{ - NamePos: 384, - NameEnd: 393, + NamePos: 387, + NameEnd: 396, Name: "Transfers", }, }, @@ -234,4 +234,4 @@ CREATE OR REPLACE PROPERTY GRAPH FinGraph } --- SQL -CREATE OR REPLACE PROPERTY GRAPH FinGraph NODE TABLES(Account, Person) EDGE TABLES (PersonOwnAccount SOURCE KEY (id) REFERENCES Person (id) DESTINATION KEY (account_id) REFERENCES Account (id) LABEL Owns, AccountTransferAccount SOURCE KEY (id) REFERENCES Account (id) DESTINATION KEY (to_id) REFERENCES Account (id) LABEL Transfers) +CREATE PROPERTY GRAPH IF NOT EXISTS FinGraph NODE TABLES(Account, Person) EDGE TABLES (PersonOwnAccount SOURCE KEY (id) REFERENCES Person (id) DESTINATION KEY (account_id) REFERENCES Account (id) LABEL Owns, AccountTransferAccount SOURCE KEY (id) REFERENCES Account (id) DESTINATION KEY (to_id) REFERENCES Account (id) LABEL Transfers)