Repository navigation
feat(provider): add Google BigQuery provider - #1672
Conversation
cevheri
left a comment
There was a problem hiding this comment.
Thanks, this is a solid provider: the triad is complete, there is no new dependency, and nothing reverts main. I'm requesting changes because three pieces change behaviour beyond BigQuery, plus a few small fixes. A new provider should not change how any other engine behaves.
-
Keep the MCP statement fence on main's reading for every engine.
Passingconnection.typeintocheckReadOnlyStatementchanges the verdict on PostgreSQL, DuckDB and SQL Server too:SELECT /* /* */ 1; DROP TABLE t; */wasMULTIPLE_STATEMENTSon main and is now admitted there, andSELECT [a--b] FROM tflips the other way. No test pins those engines' verdicts.
Revertsrc/lib/mcp/guards/execution-fence.tsand the call inrun-read-query.tsto main's form. BigQuery's ownqueryReadOnlyalready applies its grammar.
Done when:checkReadOnlyStatementmatches main. -
Move the clause-aware completion rewrite into its own PR.
Thesql-completions.tschange alters completion for every engine, for example tables are no longer offered in a SELECT list. That deserves its own review.
Keep only what BigQuery needs here (tablesNeedContainerand the qualified label), the way Databend and S3 added their completion facts without touching the shared flow.
Done when: completion for a non-BigQuery connection behaves exactly as on main. -
Split agent and MCP execution on BigQuery into a follow-up PR.
On the engines that execute today, the boundary includes the identity: PostgreSQL refuses broad roles and SQL Server checks at open that the principal cannot write. Here a key that can write is accepted, and the grammar comment notes remote functions are not covered.
Land the editor provider first. In the follow-up we can talk about an identity check (for example atestIamPermissionsprobe that refuses write permissions).
Done when:AGENT_EXECUTION_ENGINES, the MCP engine list and their tests are as on main. -
Document the server-credential variables in
.env.example.
BIGQUERY_SERVER_CREDENTIALS,GOOGLE_APPLICATION_CREDENTIALSandGCE_METADATA_HOSTare read inauth.tsbut are not in.env.example, where every env var lives.
Done when: all three are there with an example value and a one-line explanation. -
Fix two small text slips.
Insrc/lib/sql/grammar.ts,BIGQUERY_GRAMMARsits between Databend's docblock andDATABEND_GRAMMAR, so that docblock now belongs to the wrong constant.DOCKERHUB.mdsays "The thirty-one row", which should be "thirty-first".
Done when: each grammar constant directly follows its own docblock and the ordinal is fixed.
Please also replace Closes #<issue number> in the description with a reference to #424. I'll approve the CI run once these are in.
…cost estimate Adds the `bigquery` engine with no Google SDK: statements are REST jobs.query calls over the shared node transport, and service-account tokens are signed with jose. It covers the editor (results, schema tree, autocomplete with dataset.table labels, a live dry-run cost badge and EXPLAIN as a dry run), monitoring from region INFORMATION_SCHEMA, seeding with job location detection, and server credentials (ADC or GKE Workload Identity) for operator-seeded connections behind BIGQUERY_SERVER_CREDENTIALS. Agent and MCP run_read_query execution and clause-aware completion follow in separate PRs (libredb#424).
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
bdee6ba to
8159252
Compare
|
One more ask, on top of the review above. A new provider is a big change, so next time please open an issue first so we can agree on the scope before the code. For this one, the integration test mocks the HTTP layer, so nothing here has run against an engine.
|
|
Yeah, I will create an issue for sure next time. For us, this initially started as a PoC, but I made quick progress and did not want to keep it from the project. We did not have a good experience with https://github.com/goccy/bigquery-emulator for our CI pipelines. This is likely due to our setup; I will look into adding it to this project/PR. |
BIGQUERY_EMULATOR_HOST (server environment only) points the transport at the emulator, and tests/live/bigquery-live-check.ts runs the real provider against it: connect, datasets, tables and views, columns, and a query across two pages. The emulator found three fixes: jobTimeoutMs is sent as the int64 string the REST schema declares, a dataset listed without a location is kept, and tables.get's legacy type names are renamed to the GoogleSQL ones INFORMATION_SCHEMA reports. The fake transport in the unit test now routes on the URL path, not a host substring, which CodeQL flagged.
|
how was your contribution experience with libredb-studio? |
|
thanks Dariusch this is a big PR, and last commit fixed the live check, merging shortly and will see next release |
|
Thank you. |
Resolve the conflicts the MQTT provider (libredb#1676) left. Every engine list now names both BigQuery and MQTT, and every count both branches had moved by one now moves by two: 31 external engines, 32 type-ids, 58 named engines, 30 provider modules. Lines both branches changed the same way merged without a conflict and still carried the +1, so those were corrected too. The chart goes to 0.1.87, because 0.1.86 was released with MQTT. The MQTT row in DOCKERHUB.md is shortened to stay under the 23,000-byte cap, BigQuery's showcase rank moves to 31 behind the embedded store, the operator bundle is regenerated, and the factory.ts line references in the connection fingerprint test point at the merged file.
|
Thanks @Dariusch, BigQuery is merged. Two follow-ups, in one PR when you have time:
|
…illed-bytes cap A dry run admits only a SELECT, maximumBytesBilled caps the real run, the agent guard refuses ML.*, AI.* and EXTERNAL_QUERY, and opening under the agent profile refuses an identity that Resource Manager's testIamPermissions shows can write on the project. Split out of libredb#1672; the MCP statement fence stays as on main.
Description
Adds Google BigQuery as an engine (
bigquery), with no Google SDK: every statement is a RESTjobs.querycall over the shared node transport, andjose(already a dependency) signs service-account tokens.It covers the editor (results, schema tree, autocomplete, a live cost estimate), monitoring and seeding. Agent and MCP
run_read_queryexecution, and clause-aware completion, follow in separate PRs.Type of Change
Related Issue
Part of #424.
Changes Made
src/lib/db/providers/sql/bigquery/): connect, query with paging and polling, typed cell decoding (INT64 as string, TIMESTAMP, STRUCT, ARRAY), error mapping, best-effortjobs.cancelon abort, and a datasets → tables / views / materialized views object surface.BIGQUERY_SERVER_CREDENTIALS=trueand only for operator-seeded connections, the server's ADC file or the metadata server (GKE Workload Identity). Tokens are cached and single-flighted.locationfield, else the default dataset's location, else the most common dataset location, so table-less statements do not fall back toUS.INFORMATION_SCHEMAreads per location, cached, with a REST fallback; on a 3,000-table project this took the schema load from about 78 s to under 10 s.INFORMATION_SCHEMA, cached for 60 s.#comments, backslash escapes (including in backtick names), triple-quoted strings, flat block comments,[…]subscripts.tablesNeedContainercapability and alabelQualifiedtable-item flag (completion for other engines is unchanged), ashowSslPanelUI flag, triple-quoted strings and backslash-escaped backticks in the span reader (off for every other grammar), and the server forcingmanaged: falseon inline connections.type: bigquerywithdatabase(project),schema(default dataset),password(key JSON or token) andlocation; the form hides host, port, SSL and SSH.docs/providers/bigquery.md; BigQuery added todocs/SEED_CONNECTIONS.md,docs/API_DOCS.md, the READMEs and listings (thirty external engines);BIGQUERY_SERVER_CREDENTIALS,GOOGLE_APPLICATION_CREDENTIALSandGCE_METADATA_HOSTin.env.example.Testing
Live, against a real BigQuery project (data in
europe-west3): connect, queries, schema tree and autocomplete, the dry-run estimate, monitoring, and every grammar fact via dry runs.Automated: new unit tests for the provider, transport, auth and tokens, decoding, the grammar and qualified completion labels, plus
tests/integration/db/bigquery-provider.test.ts, which runs the real provider, transport and auth against a fake REST server, including the shared object-surface conformance check.bun run testpasses apart fromtests/unit/db/etcd/tls-handshake.test.ts, which also fails onmain.Format, lint, typecheck, knip,
chart:check,channels:showcase:check,readme:check,security:check,build,build:lib,attw,lib:closureand the Windows launcher'sgofmt/go vet/go testpass.Test Environment
Screenshots (if applicable)
Checklist
bun run test:coverageandbun run coverage:check)src/lib/db/providers/, I updated the matchingdocs/providers/documentation andtests/integration/db/tests in the same PR (provider triad)Additional Notes
jobs.queryandINFORMATION_SCHEMAfaithfully, so the integration test uses a fake REST server and live behaviour was verified by hand.jobs.queryPOST is still in flight cannot cancel the job; the shared inventory limit (1,000 container/kind pairs) truncates autocomplete above about 333 datasets.