spanner

package
v0.0.0-...-bdbe55d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2026 License: MIT Imports: 23 Imported by: 0

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

View Source
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.

View Source
const Engine = "spanner"

Engine is the name goldeneye knows the database by.

View Source
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

func Analyze(ctx context.Context, endpoint string, c endtoend.Case) ([]byte, error)

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

func Check(ctx context.Context, endpoint string, c endtoend.Case) (string, error)

Check compares what Spanner reports for a case with the output the case committed, returning a diff when they differ.

func Generate

func Generate(ctx context.Context, endpoint string) (dialect.Files, error)

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.

func Locate

func Locate() (string, error)

Locate returns the server to generate from, named by SPANNER_SERVER_URI.

func Version

func Version(ctx context.Context, endpoint string) (string, error)

Version describes the server: Spanner Omni reports no release of its own through the API, so the instance the databases are created in is described instead.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL