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

use SubStatementStr field in DDL for getting sub statement in CREATE VIEW #2448

Merged
merged 2 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ github.com/dolthub/jsonpath v0.0.2-0.20240227200619-19675ab05c71 h1:bMGS25NWAGTE
github.com/dolthub/jsonpath v0.0.2-0.20240227200619-19675ab05c71/go.mod h1:2/2zjLQ/JOOSbbSboojeg+cAwcRV0fDLzIiWch/lhqI=
github.com/dolthub/sqllogictest/go v0.0.0-20201107003712-816f3ae12d81 h1:7/v8q9XGFa6q5Ap4Z/OhNkAMBaK5YeuEzwJt+NZdhiE=
github.com/dolthub/sqllogictest/go v0.0.0-20201107003712-816f3ae12d81/go.mod h1:siLfyv2c92W1eN/R4QqG/+RjjX5W2+gCTRjZxBjI3TY=
github.com/dolthub/vitess v0.0.0-20240410183958-15cc912ab042 h1:VxB3MyyVGp+Pr9fnkahIj2FXRfM5dpvdz1rV6ERCH1s=
github.com/dolthub/vitess v0.0.0-20240410183958-15cc912ab042/go.mod h1:uBvlRluuL+SbEWTCZ68o0xvsdYZER3CEG/35INdzfJM=
github.com/dolthub/vitess v0.0.0-20240415183649-5b2c6a9c5851 h1:M8B0eOAbWtzkxMp7xgv9kGHRrKFOXyBVH9+qTCRcG0w=
github.com/dolthub/vitess v0.0.0-20240415183649-5b2c6a9c5851/go.mod h1:uBvlRluuL+SbEWTCZ68o0xvsdYZER3CEG/35INdzfJM=
github.com/dolthub/vitess v0.0.0-20240415200146-562b545c47df h1:hXB89Qhyu0ymVhP4AvuCtHWGpQmZN0Tt5Cc58Ig8/dg=
github.com/dolthub/vitess v0.0.0-20240415200146-562b545c47df/go.mod h1:uBvlRluuL+SbEWTCZ68o0xvsdYZER3CEG/35INdzfJM=
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
Expand Down
9 changes: 7 additions & 2 deletions sql/planbuilder/create_ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,13 @@ func (b *Builder) buildAlterEvent(inScope *scope, query string, c *ast.DDL) (out

func (b *Builder) buildCreateView(inScope *scope, query string, c *ast.DDL) (outScope *scope) {
outScope = inScope.push()

selectStr := query[c.SubStatementPositionStart:c.SubStatementPositionEnd]
selectStr := c.SubStatementStr
if selectStr == "" {
if c.SubStatementPositionEnd > len(query) {
b.handleErr(fmt.Errorf("unable to get sub statement"))
}
selectStr = query[c.SubStatementPositionStart:c.SubStatementPositionEnd]
}
stmt, _, err := ast.ParseOneWithOptions(selectStr, b.parserOpts)
if err != nil {
b.handleErr(err)
Expand Down