Help › Connect to databases

Connect to Google BigQuery

Connect to BigQuery with a service account key or the Google Cloud CLI, see what a query will read before it runs, and what is particular to BigQuery.

Querlyn 0.1.0 is not released yet. This help describes it ahead of release.

Querlyn talks to BigQuery through its REST API. A project is a database in Querlyn, a dataset a schema. BigQuery bills on-demand queries by the bytes they read, so Querlyn says what a query will read before it runs it; see What a query will cost.

What you need

  • The Google Cloud project to run queries in (and be billed to), for example acme-analytics.
  • One of:
    • a service account's JSON key, as a file or to paste;
    • the Google Cloud CLI, signed in with gcloud auth application-default login.
  • The account needs to run jobs in the project (the BigQuery Job User role) and to read the datasets you work with (BigQuery Data Viewer).

Fill in the dialog

  1. Choose File › New Connection… and, under Database engine, Google BigQuery.

  2. API endpoint stays bigquery.googleapis.com and Port 443. Change them only for a private endpoint of your own network.

  3. Under Project, enter the project ID.

  4. Under Sign in with, choose:

    Sign in withWhat it does
    Service account keyUnder Key file, choose the key's JSON file. Querlyn reads it each time it signs in and keeps only its path. Leave Key file empty to paste the key instead under Service account key (JSON); it is then kept like a password (see Choose where passwords are kept).
    Google Cloud CLIQuerlyn asks the Google Cloud CLI for a token (gcloud auth application-default print-access-token), as the account you signed in to it with. Nothing is kept in Querlyn.

    Sign In checks the sign-in now; connecting signs in anyway.

  5. Optionally fill in:

    • Location: where queries run, such as US, EU or europe-west2. Empty lets BigQuery choose from the tables a query reads.
    • Maximum bytes billed: the most one query may bill, such as 10 GB. A query that would bill more fails without being charged.
    • Ask before reading: from how large an estimate Querlyn asks before a run, such as 500 MB or 10 GB, or off to never ask because of the bytes. Empty means from 1 GB on a Production connection and never on others. See What a query will cost.
    • Default dataset: the dataset that names without one are looked up in.
    • Other projects: projects to list in the sidebar besides those the account can list, separated by commas, such as bigquery-public-data.
  6. Choose Test Connection, then Save & Connect.

There is no user name: the token says who you are. Connections to Google's own hosts are always encrypted and verified; other TLS choices are refused for them.

What a query will cost

  • Before every run Querlyn asks BigQuery what the run will read (a dry run, which is free) and shows it under Messages before any rows arrive, and while the query runs. After each statement, Messages says what BigQuery processed and billed.
  • On a Production connection a run that will read 1 GB or more, or whose size could not be estimated, asks first, and the question states the bytes. Every other question there (a destructive statement, for example) states them too. See Stay safe on production.
  • Ask before reading, in the connection's settings, moves that line for one connection. A size such as 10 GB asks from there on, on a connection of any environment; off never asks because of the bytes, also on Production. A connection that never asks about anything (see Confirm risky statements) does not ask about bytes either. The estimate is shown whatever the setting.
  • Maximum bytes billed goes with every query. The estimate says when a query reads more than it, and BigQuery then refuses the query without charge.
  • Explain shows the dry run's estimate without running the query.
  • Values for completion are sampled only when the sample would read at most 100 MB: BigQuery bills the whole column whatever a LIMIT says. See Values of a column.
  • Profiling a whole table first asks, with the bytes it will read. See Profile the values of a column.
  • Querlyn reads tables only when you ask: the Migrations tab does not check a dataset's history by itself.

The estimate is BigQuery's upper bound. BigQuery bills at least 10 MB for each table a query reads, and nothing for a result from its cache.

What is particular to BigQuery

  • Projects and datasets. The sidebar lists the projects the account can list, and those under Other projects; under each, its datasets, and in a dataset its tables, views, materialized views, external tables, functions and procedures. The database button in the bar above the editor chooses the tab's project, which its queries run and are billed in.
  • Names are written in backticks, a whole path in one pair if you like: `acme-analytics.sales.orders`. Completion understands both.
  • Scripts run as one job. A selection of several statements, a DECLARE and an IF or a BEGIN … END block, is sent whole, and the results of its statements arrive in order.
  • A tab keeps a BigQuery session once it needs one: for Begin Transaction, BEGIN TRANSACTION, DECLARE, SET or a temporary table. Variables and temporary tables then last from one run to the next, until the tab closes.
  • Transactions hold inserts, updates, deletes and merges. BigQuery runs CREATE, ALTER and DROP of permanent tables only outside a transaction, so switch a tab that commits by hand to auto-commit for them; the error says so too. See Commit and roll back changes.
  • Rows can be edited only in a table that declares its key. BigQuery enforces no key and a table may hold the same row twice, so a table without a primary key is read-only in the results. Declare one with ALTER TABLE sales.orders ADD PRIMARY KEY (id) NOT ENFORCED.
  • Nested values: an array shows its elements; a struct, and an array of structs, show as BigQuery writes them, {'name': Ada, 'city': London}. Geography values are their WKT text, intervals and ranges BigQuery's own text.
  • Server Activity lists the running jobs of the project in the connection's location (US when none is set), and cancels them. Others' jobs need the right to list all jobs; without it, you see your own.
  • Parameters are written ? or @name, and their values are bound to the query.
  • Read-only is Querlyn's check. An account that may only read is the stronger guard.
  • Copying tables to and from BigQuery, and importing files into it, work as for any database; a copied table gets informational keys (NOT ENFORCED).

What Querlyn does not do

  • Sign in with a Google account in the browser (OAuth), or with workload identity federation. Use the Google Cloud CLI instead.
  • Explain Analyze: run the query, then Explain it; the plan then shows the stages of its last run.
  • Dry Run of an UPDATE or DELETE with undo: BigQuery has no savepoints.
  • The table designer, Show DDL and schema compare.
  • Users and privileges: BigQuery's access is Google Cloud IAM, in the Google Cloud console.
  • Backup and restore: BigQuery's time travel, snapshots and clones are its own answer.
  • The "blocking others" notice, lock and statement timeouts, and migration lock warnings.
  • A run on several connections does not estimate what it reads on BigQuery, nor ask about it.

Help for Querlyn 0.1.0. All help topics