Documentation
¶
Overview ¶
Package spanner generates the GoogleSQL dialect seed under internal/engine/googlesql/dialect from a live Spanner server, and verifies the GoogleSQL analyze cases under internal/endtoend/testdata against the same server. The server is Spanner Omni, the downloadable Spanner, run from its container image; the package writes into the googlesql directory, since sqlc's engine is named after the language Spanner speaks rather than the database.
Spanner keeps no catalog of its types, functions or operators, so types.jsonl, functions.jsonl and operators.jsonl are written by hand and are not this package's business. What it does describe is its information schema: relations.jsonl is every view of INFORMATION_SCHEMA and SPANNER_SYS, read from INFORMATION_SCHEMA itself.
The package also verifies the GoogleSQL analyze cases against the same server: each case's schema becomes a database of its own, its fixture is written there, and each query is compiled in PLAN mode, which runs nothing and reports the type of each result column and of each parameter the query leaves undeclared, and the query plan, which says which table column each result column and parameter stands for. The answer is printed in the JSON shape sqlc analyze prints and compared with the case's committed stdout.json byte for byte.
The server is named by SPANNER_SERVER_URI, the gRPC endpoint of a Spanner Omni server such as localhost:15000, which is reached without TLS or credentials, as Omni is. Databases are created in the instance Omni's single server provides, projects/default/instances/default.
Index ¶
- Constants
- func Analyze(ctx context.Context, endpoint string, c endtoend.Case) ([]byte, error)
- func Check(ctx context.Context, endpoint string, c endtoend.Case) (string, error)
- func Generate(ctx context.Context, endpoint string) (dialect.Files, error)
- func Locate() (string, error)
- func Version(ctx context.Context, endpoint string) (string, error)
Constants ¶
const ( Dir = "googlesql" Cases = "googlesql" )
Dir is the name of the engine directory the dialect lives under, and Cases the name of the analyze case directories under internal/endtoend/testdata: both are named after the language, GoogleSQL, which is how sqlc knows the dialect.
const Engine = "spanner"
Engine is the name goldeneye knows the database by.
const Instance = "projects/default/instances/default"
Instance is the instance a Spanner Omni single server provides, which every database is created in.
Variables ¶
This section is empty.
Functions ¶
func Analyze ¶
Analyze creates a database of the case's own from its schema, writes its fixture there, compiles its queries and returns what Spanner reports in the JSON shape sqlc analyze prints.
func Check ¶
Check compares what Spanner reports for a case with the output the case committed, returning a diff when they differ.
func Generate ¶
Generate reads the dialect from the server: relations.jsonl, the views of INFORMATION_SCHEMA and SPANNER_SYS, read from a database of their own, since every database has the same ones.
Types ¶
This section is empty.