2.2 KiB
2.2 KiB
BigQuery Client Libraries
Google Cloud client libraries provide an idiomatic way to interact with BigQuery from your preferred programming language.
Getting Started
To use the client libraries, ensure you have the Google Cloud SDK installed and authenticated. Install Google Cloud SDK
Python
-
Installation:
pip install --upgrade google-cloud-bigquery -
Usage Example:
from google.cloud import bigquery client = bigquery.Client() query_job = client.query("SELECT * FROM `project.dataset.table` LIMIT 10") results = query_job.result()
Java
-
Maven Dependency:
<dependency> <groupId>com.google.cloud</groupId> <artifactId>google-cloud-bigquery</artifactId> </dependency> -
Usage Example:
BigQuery bigquery = BigQueryOptions.getDefaultInstance().getService(); QueryJobConfiguration queryConfig = QueryJobConfiguration.newBuilder( "SELECT * FROM dataset.table").build(); TableResult results = bigquery.query(queryConfig);
Node.js (TypeScript)
-
Installation:
npm install @google-cloud/bigquery -
Usage Example:
import {BigQuery} from '@google-cloud/bigquery'; const bigquery = new BigQuery(); const [rows] = await bigquery.query('SELECT * FROM dataset.table');
Go
-
Installation:
go get cloud.google.com/go/bigquery -
Usage Example:
ctx := context.Background() client, _ := bigquery.NewClient(ctx, "project-id") q := client.Query("SELECT * FROM dataset.table") it, _ := q.Read(ctx)
BigQuery DataFrames (BigFrames)
For Python users, bigframes provides a pandas-like API that executes directly
in BigQuery.
pip install --upgrade bigframes