Client libraries¶
For tabbed per-language setup (Go, Python, Java, Node.js, bq CLI), see Languages & tools.
Two equivalent ways to redirect a BigQuery client at the emulator:
- Endpoint override (works in every official client). In Go:
client, err := bigquery.NewClient(ctx, "test-project",
option.WithEndpoint("http://localhost:9050"),
option.WithoutAuthentication(),
)
BIGQUERY_EMULATOR_HOSTenvironment variable (mirrors theSTORAGE_EMULATOR_HOSTandSPANNER_EMULATOR_HOSTconventions used by other Google emulators):
export BIGQUERY_EMULATOR_HOST=localhost:9050
Bearer tokens in Authorization headers are accepted but never validated,
identical to cloud-spanner-emulator's posture. The full upstream auth model
(ADC, service-account keys, OAuth scopes) documented under
BigQuery authentication is
intentionally not modeled.
SQL dialect¶
BigQuery's useLegacySql field defaults to true on the wire (older clients
still rely on this). The emulator only supports GoogleSQL, because the engine is
GoogleSQL's analyzer feeding the local execution coordinator. The query handlers
will:
- Treat
useLegacySqlunset orfalseas GoogleSQL. - Reject
useLegacySql=truewith HTTP 400 +reason: invalidQuery.
If you're using the official Go client, explicitly set Query.UseLegacySQL =
false to be safe.
Python (google-cloud-bigquery), Java, and Node.js clients all support the
analogous endpoint override. We document each one as the relevant smoke tests
pass under the conformance harness.
Seeding & CLI compatibility¶
The gateway accepts both the legacy underscore flag names this repository started
with (--http_port) and the hyphen-separated names documented for
gateway_main (--http-port), so existing scripts keep working and operators
can lift invocation snippets from the upstream docs unchanged. The full alias
table and the seeding workflows live in docs/SEEDING.md:
- Declarative YAML seed files via
--seed-data-file FILE.yaml(repeatable). Loaded after the engine reports SERVING but before the gateway accepts public traffic, so any client that hits the REST API sees the seeded datasets/tables/rows from request one. - Initial-data template directory via
--initial-data-dir DIR. The gateway copies the tree into--data-diron first boot (when nocatalog.duckdbis present) and never on subsequent boots, so operator writes are protected. - Production seed REST API via
--enable-seed-api. HitsPOST /api/emulator/seedto mirror live BigQuery metadata + rows into the local emulator; the polling endpoint isGET /api/emulator/seed/operations/{id}. Off by default; loopback-only by default; optional shared-secret header for defense in depth. The production reader is opt-in via theseed_production_livebuild tag so the default gateway build stays free of the cloud BigQuery client deps.
Test lanes¶
The repository runs two parallel conformance lanes against the same gateway:
- Fixture conformance —
task conformance:*drives YAML fixtures through the in-repo runner and pins SQL semantics against the local execution coordinator (the singlelocalprofile today, which covers every routed strategy: DuckDB fast path, DuckDB rewrites, DuckDB UDFs, semantic executor, and control ops). Seedocs/ENGINE_POLICY.mdfor the route catalog andconformance/README.mdfor the fixture schema, profile matrix, and authoring guide. - Third-party client conformance —
task thirdparty:*runs the imported BigQuery client-library sample suites (Go, Node.js, Python, BigQuery DataFrames) end-to-end against the gateway's REST + gRPC surface and (optionally)fake-gcs-server. Seethird_party/README.mdfor the per-language wiring contract, env-var matrix, and skip rules.