Skip to content

Commit 38fb7a5

Browse files
Merge pull request #4 from stackql/feature/mods-and-tvf
table-val-funcs-and-modifiers-for-tables-and-views
2 parents 663e526 + 3361295 commit 38fb7a5

File tree

8 files changed

+4316
-4058
lines changed

8 files changed

+4316
-4058
lines changed

go/vt/sqlparser/ast.go

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,9 @@ type (
238238

239239
// SelectStatement is set for Create View.
240240
SelectStatement SelectStatement
241+
242+
// Modifier is optional for Create View and Create Table.
243+
Modifier string
241244
}
242245

243246
// ParenSelect is a parenthesized SELECT statement.
@@ -579,13 +582,20 @@ type (
579582
ParenTableExpr struct {
580583
Exprs TableExprs
581584
}
585+
586+
// TableValuedFuncTableExpr represents a call to a table-valued function.
587+
TableValuedFuncTableExpr struct {
588+
FuncExpr Expr
589+
As TableIdent
590+
}
582591
)
583592

584-
func (*AliasedTableExpr) iTableExpr() {}
585-
func (*ParenTableExpr) iTableExpr() {}
586-
func (*JoinTableExpr) iTableExpr() {}
587-
func (*ExecSubquery) iTableExpr() {}
588-
func (*Union) iTableExpr() {}
593+
func (*AliasedTableExpr) iTableExpr() {}
594+
func (*ParenTableExpr) iTableExpr() {}
595+
func (*JoinTableExpr) iTableExpr() {}
596+
func (*ExecSubquery) iTableExpr() {}
597+
func (*Union) iTableExpr() {}
598+
func (*TableValuedFuncTableExpr) iTableExpr() {}
589599

590600
type (
591601
// SimpleTableExpr represents a simple table expression.
@@ -1012,6 +1022,15 @@ func (node *ParenSelect) Format(buf *TrackedBuffer) {
10121022
buf.astPrintf(node, "(%v)", node.Select)
10131023
}
10141024

1025+
// Format formats the node.
1026+
func (node *TableValuedFuncTableExpr) Format(buf *TrackedBuffer) {
1027+
if node.As.IsEmpty() {
1028+
buf.astPrintf(node, "%v", node.FuncExpr)
1029+
return
1030+
}
1031+
buf.astPrintf(node, "%v as \"%v\"", node.FuncExpr, node.As)
1032+
}
1033+
10151034
// Format formats the node.
10161035
func (node *Auth) Format(buf *TrackedBuffer) {
10171036
var infraql_opt string

go/vt/sqlparser/constants.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ const (
8484
IgnoreStr = "ignore "
8585
ForceStr = "force "
8686

87+
// Table Modifiers
88+
TempStr = "temp"
89+
TemporaryStr = "temporary"
90+
91+
// View Modifiers
92+
MaterializedStr = "materialized"
93+
8794
// Where.Type
8895
WhereStr = "where"
8996
HavingStr = "having"

go/vt/sqlparser/external_visitor.go

Lines changed: 112 additions & 111 deletions
Large diffs are not rendered by default.

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)