bq
Interact with Google BigQuery
TLDR
Run query against a BigQuery table using standard SQL, add --dry_run flag to estimate the number of bytes read by the query
Run a parameterized query
Create a new dataset or table in the US location
List all datasets in a project
Batch load data from a specific file in formats such as CSV, JSON, Parquet, and Avro to a table
Copy one table to another
Display help
SYNOPSIS
bq
PARAMETERS
--apilog=
Path to the apilog file. Enables logging of BigQuery API requests and responses to the specified file.
--dataset_id=
Specifies the default dataset to use for unqualified table names.
--format=
Specifies the output format. Options include prettyjson, json, csv, and pretty.
--location=
Specifies the location for operations like creating datasets. This is important for regional datasets.
--project_id=
Specifies the Google Cloud project ID to use.
--transfer_service_account=
Specifies the service account used for data transfers.
help
Displays help information about the command.
query
Executes a SQL query against BigQuery.
load
Loads data into a BigQuery table from a file or other source.
extract
Extracts data from a BigQuery table to a file or other destination.
mk
Creates datasets, tables, or other BigQuery resources.
rm
Deletes datasets, tables, or other BigQuery resources.
ls
Lists datasets, tables, or other BigQuery resources.
update
Updates BigQuery resources.
DESCRIPTION
The bq command-line tool is a Python-based command-line interface for interacting with Google's BigQuery service.
It allows users to manage BigQuery resources such as datasets, tables, and jobs directly from the terminal.
With bq, users can perform various tasks, including running queries, loading data into tables, exporting data from tables, and managing access controls.
It provides a flexible and efficient way to automate BigQuery workflows and integrate them into scripts or other applications.
The bq tool is part of the Google Cloud SDK (Software Development Kit) and requires authentication with a Google Cloud account to access BigQuery resources. The configurations are generally stored into the .bigqueryrc file at the user's home directory.
CAVEATS
Requires the Google Cloud SDK to be installed and configured, including authentication with a Google Cloud account.
AUTHENTICATION
The bq command uses the same authentication mechanism as the Google Cloud SDK. You typically need to authenticate using gcloud auth login before using bq.
CONFIGURATION
The bq tool's settings are often stored in a .bigqueryrc file in your home directory. You can modify settings such as the default project ID and dataset ID in this file or through command-line flags.