googleapis / googleapis/google-cloud-go
spanner: add support for named schema
- 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
Assessment
This issue has not been assessed yet.