Skip to content

Commit 091a1ad

Browse files
Merge pull request #6 from stackql/feature/materialized-view-lifecycle
materialized-view-lifecycle
2 parents 5219cdf + c9a56d2 commit 091a1ad

File tree

6 files changed

+4266
-4148
lines changed

6 files changed

+4266
-4148
lines changed

go/vt/sqlparser/ast.go

Lines changed: 52 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,13 @@ type (
206206
Charset string
207207
}
208208

209+
RefreshMaterializedView struct {
210+
Concurrently bool
211+
ViewName TableName
212+
WithData bool
213+
ImplicitSelect SelectStatement // This is mutated during analysis.
214+
}
215+
209216
// DDL represents a CREATE, ALTER, DROP, RENAME, TRUNCATE or ANALYZE statement.
210217
DDL struct {
211218
Action string
@@ -333,38 +340,39 @@ type (
333340
OtherAdmin struct{}
334341
)
335342

336-
func (*Union) iStatement() {}
337-
func (*Select) iStatement() {}
338-
func (*Stream) iStatement() {}
339-
func (*Insert) iStatement() {}
340-
func (*Update) iStatement() {}
341-
func (*Delete) iStatement() {}
342-
func (*Set) iStatement() {}
343-
func (*SetTransaction) iStatement() {}
344-
func (*DBDDL) iStatement() {}
345-
func (*DDL) iStatement() {}
346-
func (*Show) iStatement() {}
347-
func (*Use) iStatement() {}
348-
func (*Begin) iStatement() {}
349-
func (*Commit) iStatement() {}
350-
func (*Rollback) iStatement() {}
351-
func (*SRollback) iStatement() {}
352-
func (*Savepoint) iStatement() {}
353-
func (*Release) iStatement() {}
354-
func (*Explain) iStatement() {}
355-
func (*OtherRead) iStatement() {}
356-
func (*Auth) iStatement() {}
357-
func (*Registry) iStatement() {}
358-
func (*AuthRevoke) iStatement() {}
359-
func (*Exec) iStatement() {}
360-
func (*Purge) iStatement() {}
361-
func (*NativeQuery) iStatement() {}
362-
func (*DescribeTable) iStatement() {}
363-
func (*OtherAdmin) iStatement() {}
364-
func (*Select) iSelectStatement() {}
365-
func (*Union) iSelectStatement() {}
366-
func (*ParenSelect) iSelectStatement() {}
367-
func (*Sleep) iStatement() {}
343+
func (*Union) iStatement() {}
344+
func (*Select) iStatement() {}
345+
func (*Stream) iStatement() {}
346+
func (*Insert) iStatement() {}
347+
func (*Update) iStatement() {}
348+
func (*Delete) iStatement() {}
349+
func (*Set) iStatement() {}
350+
func (*SetTransaction) iStatement() {}
351+
func (*DBDDL) iStatement() {}
352+
func (*DDL) iStatement() {}
353+
func (*Show) iStatement() {}
354+
func (*Use) iStatement() {}
355+
func (*Begin) iStatement() {}
356+
func (*Commit) iStatement() {}
357+
func (*Rollback) iStatement() {}
358+
func (*SRollback) iStatement() {}
359+
func (*Savepoint) iStatement() {}
360+
func (*Release) iStatement() {}
361+
func (*Explain) iStatement() {}
362+
func (*OtherRead) iStatement() {}
363+
func (*Auth) iStatement() {}
364+
func (*Registry) iStatement() {}
365+
func (*AuthRevoke) iStatement() {}
366+
func (*Exec) iStatement() {}
367+
func (*Purge) iStatement() {}
368+
func (*NativeQuery) iStatement() {}
369+
func (*DescribeTable) iStatement() {}
370+
func (*OtherAdmin) iStatement() {}
371+
func (*Select) iSelectStatement() {}
372+
func (*Union) iSelectStatement() {}
373+
func (*ParenSelect) iSelectStatement() {}
374+
func (*RefreshMaterializedView) iStatement() {}
375+
func (*Sleep) iStatement() {}
368376

369377
// ParenSelect can actually not be a top level statement,
370378
// but we have to allow it because it's a requirement
@@ -1138,6 +1146,18 @@ func (node *DBDDL) Format(buf *TrackedBuffer) {
11381146
}
11391147
}
11401148

1149+
func (node *RefreshMaterializedView) Format(buf *TrackedBuffer) {
1150+
if node.Concurrently {
1151+
buf.astPrintf(node, "refresh materialized view concurrently %v", node.ViewName)
1152+
return
1153+
}
1154+
if !node.WithData {
1155+
buf.astPrintf(node, "refresh materialized view %v with no data", node.ViewName)
1156+
return
1157+
}
1158+
buf.astPrintf(node, "refresh materialized view %v", node.ViewName)
1159+
}
1160+
11411161
// Format formats the node.
11421162
func (node *DDL) Format(buf *TrackedBuffer) {
11431163
switch node.Action {

go/vt/sqlparser/external_visitor.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ func (node *NativeQuery) Accept(vis SQLAstVisitor) error { return v
7575
func (node *RangeCond) Accept(vis SQLAstVisitor) error { return vis.Visit(node) }
7676
func (node ReferenceAction) Accept(vis SQLAstVisitor) error { return vis.Visit(node) }
7777
func (node *Registry) Accept(vis SQLAstVisitor) error { return vis.Visit(node) }
78+
func (node *RefreshMaterializedView) Accept(vis SQLAstVisitor) error { return vis.Visit(node) }
7879
func (node *Release) Accept(vis SQLAstVisitor) error { return vis.Visit(node) }
7980
func (node *Rollback) Accept(vis SQLAstVisitor) error { return vis.Visit(node) }
8081
func (node *SQLVal) Accept(vis SQLAstVisitor) error { return vis.Visit(node) }

go/vt/sqlparser/rewriter.go

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)