Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Spanner Graph(SQL/PGQ) schema statements #101

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
c41fae0
Bump Go version to 1.20, and add util.go
apstndb Sep 19, 2024
b818a86
Implement CREATE PROPERTY GRAPH and DROP PROPERTY GRAPH statements
apstndb Sep 19, 2024
52da535
Improve GQL schema statements
apstndb Sep 19, 2024
81b35e5
Improve tryParsePropertyGraphElementKeys
apstndb Sep 19, 2024
fdf5939
Clean up PropertyGraph*
apstndb Sep 19, 2024
c64b222
Bump Go version in .github/workflows
apstndb Sep 19, 2024
590202b
Merge branch 'main' into support-create-property-graph
apstndb Sep 21, 2024
264c013
Merge remote-tracking branch 'origin/main' into support-create-proper…
apstndb Oct 15, 2024
d294d67
Merge remote-tracking branch 'apstndb/support-create-property-graph' …
apstndb Oct 15, 2024
0d6cd02
Merge remote-tracking branch 'origin/main' into support-create-proper…
apstndb Oct 20, 2024
69f38b2
Update implementation of graph schema statements
apstndb Oct 20, 2024
252b4df
Update ast/ast_test.go
apstndb Oct 20, 2024
04d615b
Merge remote-tracking branch 'origin/main' into support-create-proper…
apstndb Oct 27, 2024
1742216
Merge remote-tracking branch 'origin/main' into support-create-proper…
apstndb Dec 18, 2024
65341ea
Merge remote-tracking branch 'origin/main' into support-create-proper…
apstndb Dec 20, 2024
9764cf8
Merge remote-tracking branch 'origin/main' into support-create-proper…
apstndb Jan 11, 2025
f8e6a56
Update to pass gen-ast-pos
apstndb Jan 11, 2025
88cb3ee
Add whitespace
apstndb Jan 11, 2025
cb051d9
Fix code styles
apstndb Jan 11, 2025
6628a84
Update testdata
apstndb Jan 11, 2025
92ece9e
Update parser.go
apstndb Jan 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
477 changes: 394 additions & 83 deletions ast/ast.go

Large diffs are not rendered by default.

176 changes: 176 additions & 0 deletions ast/pos.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

98 changes: 98 additions & 0 deletions ast/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,104 @@ func (d *DropModel) SQL() string {
return "DROP MODEL " + strOpt(d.IfExists, "IF EXISTS ") + d.Name.SQL()
}

// ================================================================================
//
// GQL schema statements
//
// ================================================================================

func (c *CreatePropertyGraph) SQL() string {
return "CREATE " +
strOpt(c.OrReplace, "OR REPLACE ") +
"PROPERTY GRAPH " +
strOpt(c.IfNotExists, "IF NOT EXISTS ") +
c.Name.SQL() + " " + c.Content.SQL()
}

func (p *PropertyGraphContent) SQL() string {
return p.NodeTables.SQL() + sqlOpt(" ", p.EdgeTables, "")
}

func (p *PropertyGraphNodeTables) SQL() string {
return "NODE TABLES " + p.Tables.SQL()
}

func (p *PropertyGraphEdgeTables) SQL() string {
return "EDGE TABLES " + p.Tables.SQL()
}

func (p *PropertyGraphElementList) SQL() string {
return "(" + sqlJoin(p.Elements, ", ") + ")"
}

func (p *PropertyGraphElement) SQL() string {
return p.Name.SQL() +
sqlOpt(" AS ", p.Alias, "") +
sqlOpt(" ", p.Keys, "") +
sqlOpt(" ", p.Properties, "")
}

func (p *PropertyGraphSingleProperties) SQL() string { return p.Properties.SQL() }

func (p *PropertyGraphLabelAndPropertiesList) SQL() string {
return sqlJoin(p.LabelAndProperties, " ")
}

func (p *PropertyGraphLabelAndProperties) SQL() string {
return p.Label.SQL() + sqlOpt(" ", p.Properties, "")
}

func (p *PropertyGraphElementLabelLabelName) SQL() string { return "LABEL " + p.Name.SQL() }

func (p *PropertyGraphElementLabelDefaultLabel) SQL() string { return "DEFAULT LABEL" }

func (p *PropertyGraphNodeElementKey) SQL() string { return p.Key.SQL() }

func (p *PropertyGraphEdgeElementKeys) SQL() string {
return sqlOpt("", p.Element, " ") +
p.Source.SQL() + " " + p.Destination.SQL()
}

func (p *PropertyGraphElementKey) SQL() string { return "KEY " + p.Keys.SQL() }

func (p *PropertyGraphSourceKey) SQL() string {
return "SOURCE KEY " + p.Keys.SQL() +
" REFERENCES " + p.ElementReference.SQL() +
sqlOpt(" ", p.ReferenceColumns, "")
}

func (p *PropertyGraphDestinationKey) SQL() string {
return "DESTINATION KEY " + p.Keys.SQL() +
" REFERENCES " + p.ElementReference.SQL() +
sqlOpt(" ", p.ReferenceColumns, "")
}

func (p *PropertyGraphColumnNameList) SQL() string {
return "(" + sqlJoin(p.ColumnNameList, ", ") + ")"
}

func (p *PropertyGraphNoProperties) SQL() string {
return "NO PROPERTIES"
}

func (p *PropertyGraphPropertiesAre) SQL() string {
return "PROPERTIES ARE ALL COLUMNS" + sqlOpt(" EXCEPT ", p.ExceptColumns, "")
}

func (p *PropertyGraphDerivedPropertyList) SQL() string {
return "PROPERTIES (" + sqlJoin(p.DerivedProperties, ", ") + ")"
}

func (p *PropertyGraphDerivedProperty) SQL() string {
return p.Expr.SQL() + sqlOpt(" AS ", p.Alias, "")
}

func (g *DropPropertyGraph) SQL() string {
return "DROP PROPERTY GRAPH " +
strOpt(g.IfExists, "IF EXISTS ") +
g.Name.SQL()
}

// ================================================================================
//
// Types for Schema
Expand Down
Loading
Loading