googleapis / googleapis/google-cloud-go

spanner: add support for named schema

Open
#11,560 0 comments 0 reactions 1 assignee Assigned to @rahul2393 View on GitHub
api: spanner triage me
Dominant language
Go
Stars
4.5k
Forks
1.6k
Avg merge
1d 13h
Merged PRs (30d)
109

Description

## Is your feature request related to a problem? Please describe.

The following code fails to parse the DDL that contains named schemas.
We would appreciate it if you could support named schemas in the `spansql` package.

```go
const ddl = `
CREATE SCHEMA sch1;

CREATE TABLE sch1.Singers (
SingerId INT64 NOT NULL,
FirstName STRING(1024),
LastName STRING(1024),
SingerInfo BYTES(MAX),
) PRIMARY KEY(SingerId);

CREATE INDEX sch1.indexOnSingers ON sch1.Singers(FirstName);
`

func main() {
ddl, err := spansql.ParseDDL("named-schema.sql", ddl)
if err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
}

for _, stmt := range ddl.List {
fmt.Printf("%v\n", stmt)
}
}
```

When it runs, it outputs the error as follows:
```console
Error: named-schema.sql:1.0: unknown DDL statement
exit status 1
```

## Describe the solution you'd like

Add support for Spanner's named schema.
https://cloud.google.com/spanner/docs/named-schemas

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.