Home

Awesome

Google Cloud BigQuery Client for Java

Java idiomatic client for Cloud BigQuery.

Maven Stability

Quickstart

If you are using Maven with BOM, add this to your pom.xml file:

<!--  Using libraries-bom to manage versions.
See https://github.com/GoogleCloudPlatform/cloud-opensource-java/wiki/The-Google-Cloud-Platform-Libraries-BOM -->
<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>com.google.cloud</groupId>
      <artifactId>libraries-bom</artifactId>
      <version>26.43.0</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
  </dependencies>
</dependencyManagement>

<dependencies>
  <dependency>
    <groupId>com.google.cloud</groupId>
    <artifactId>google-cloud-bigquery</artifactId>
  </dependency>
</dependencies>

If you are using Maven without the BOM, add this to your dependencies:

<!-- {x-version-update-start:google-cloud-bigquery:released} -->
<dependency>
  <groupId>com.google.cloud</groupId>
  <artifactId>google-cloud-bigquery</artifactId>
  <version>2.42.2</version>
</dependency>

If you are using Gradle 5.x or later, add this to your dependencies:

implementation platform('com.google.cloud:libraries-bom:26.45.0')

implementation 'com.google.cloud:google-cloud-bigquery'

If you are using Gradle without BOM, add this to your dependencies:

implementation 'com.google.cloud:google-cloud-bigquery:2.42.2'

If you are using SBT, add this to your dependencies:

libraryDependencies += "com.google.cloud" % "google-cloud-bigquery" % "2.42.2"
<!-- {x-version-update-end} -->

Authentication

See the Authentication section in the base directory's README.

Authorization

The client application making API calls must be granted authorization scopes required for the desired Cloud BigQuery APIs, and the authenticated principal must have the IAM role(s) required to access GCP resources using the Cloud BigQuery API calls.

Getting Started

Prerequisites

You will need a Google Cloud Platform Console project with the Cloud BigQuery API enabled. You will need to enable billing to use Google Cloud BigQuery. Follow these instructions to get your project set up. You will also need to set up the local development environment by installing the Google Cloud Command Line Interface and running the following commands in command line: gcloud auth login and gcloud config set project [YOUR PROJECT ID].

Installation and setup

You'll need to obtain the google-cloud-bigquery library. See the Quickstart section to add google-cloud-bigquery as a dependency in your code.

About Cloud BigQuery

Cloud BigQuery is a fully managed, NoOps, low cost data analytics service. Data can be streamed into BigQuery at millions of rows per second to enable real-time analysis. With BigQuery you can easily deploy Petabyte-scale Databases.

See the Cloud BigQuery client library docs to learn how to use this Cloud BigQuery Client Library.

Samples

Samples are in the samples/ directory.

SampleSource CodeTry it
Add Column Load Appendsource codeOpen in Cloud Shell
Add Empty Columnsource codeOpen in Cloud Shell
Auth Drive Scopesource codeOpen in Cloud Shell
Auth Snippetssource codeOpen in Cloud Shell
Auth User Flowsource codeOpen in Cloud Shell
Auth User Querysource codeOpen in Cloud Shell
Authorize Datasetsource codeOpen in Cloud Shell
Authorized View Tutorialsource codeOpen in Cloud Shell
Browse Tablesource codeOpen in Cloud Shell
Cancel Jobsource codeOpen in Cloud Shell
Copy Multiple Tablessource codeOpen in Cloud Shell
Copy Tablesource codeOpen in Cloud Shell
Copy Table Cmeksource codeOpen in Cloud Shell
Create And Query Repeated Record Fieldsource codeOpen in Cloud Shell
Create Clustered Tablesource codeOpen in Cloud Shell
Create Datasetsource codeOpen in Cloud Shell
Create Dataset Awssource codeOpen in Cloud Shell
Create Dataset With Regional Endpointsource codeOpen in Cloud Shell
Create External Table Awssource codeOpen in Cloud Shell
Create Iam Policysource codeOpen in Cloud Shell
Create Jobsource codeOpen in Cloud Shell
Create Materialized Viewsource codeOpen in Cloud Shell
Create Modelsource codeOpen in Cloud Shell
Create Partitioned Tablesource codeOpen in Cloud Shell
Create Range Partitioned Tablesource codeOpen in Cloud Shell
Create Routinesource codeOpen in Cloud Shell
Create Routine Ddlsource codeOpen in Cloud Shell
Create Tablesource codeOpen in Cloud Shell
Create Table Cmeksource codeOpen in Cloud Shell
Create Table External Hive Partitionedsource codeOpen in Cloud Shell
Create Table Without Schemasource codeOpen in Cloud Shell
Create Tables With Primary And Foreign Keyssource codeOpen in Cloud Shell
Create Viewsource codeOpen in Cloud Shell
Dataset Existssource codeOpen in Cloud Shell
Ddl Create Viewsource codeOpen in Cloud Shell
Delete Datasetsource codeOpen in Cloud Shell
Delete Dataset And Contentssource codeOpen in Cloud Shell
Delete Label Datasetsource codeOpen in Cloud Shell
Delete Label Tablesource codeOpen in Cloud Shell
Delete Materialized Viewsource codeOpen in Cloud Shell
Delete Modelsource codeOpen in Cloud Shell
Delete Routinesource codeOpen in Cloud Shell
Delete Tablesource codeOpen in Cloud Shell
Export Query Results To S3source codeOpen in Cloud Shell
Extract Modelsource codeOpen in Cloud Shell
Extract Table Compressedsource codeOpen in Cloud Shell
Extract Table To Csvsource codeOpen in Cloud Shell
Extract Table To Jsonsource codeOpen in Cloud Shell
Get Dataset Infosource codeOpen in Cloud Shell
Get Dataset Labelssource codeOpen in Cloud Shell
Get Jobsource codeOpen in Cloud Shell
Get Modelsource codeOpen in Cloud Shell
Get Routinesource codeOpen in Cloud Shell
Get Tablesource codeOpen in Cloud Shell
Get Table Labelssource codeOpen in Cloud Shell
Get Viewsource codeOpen in Cloud Shell
Grant View Accesssource codeOpen in Cloud Shell
Inserting Data Typessource codeOpen in Cloud Shell
Label Datasetsource codeOpen in Cloud Shell
Label Tablesource codeOpen in Cloud Shell
List Datasetssource codeOpen in Cloud Shell
List Datasets By Labelsource codeOpen in Cloud Shell
List Jobssource codeOpen in Cloud Shell
List Modelssource codeOpen in Cloud Shell
List Routinessource codeOpen in Cloud Shell
List Tablessource codeOpen in Cloud Shell
Load Avro From Gcssource codeOpen in Cloud Shell
Load Avro From Gcs Truncatesource codeOpen in Cloud Shell
Load Csv From Gcssource codeOpen in Cloud Shell
Load Csv From Gcs Autodetectsource codeOpen in Cloud Shell
Load Csv From Gcs Truncatesource codeOpen in Cloud Shell
Load Json From Gcssource codeOpen in Cloud Shell
Load Json From Gcs Autodetectsource codeOpen in Cloud Shell
Load Json From Gcs Cmeksource codeOpen in Cloud Shell
Load Json From Gcs Truncatesource codeOpen in Cloud Shell
Load Local Filesource codeOpen in Cloud Shell
Load Local File In Sessionsource codeOpen in Cloud Shell
Load Orc From Gcssource codeOpen in Cloud Shell
Load Orc From Gcs Truncatesource codeOpen in Cloud Shell
Load Parquetsource codeOpen in Cloud Shell
Load Parquet Replace Tablesource codeOpen in Cloud Shell
Load Partitioned Tablesource codeOpen in Cloud Shell
Load Table Clusteredsource codeOpen in Cloud Shell
Nested Repeated Schemasource codeOpen in Cloud Shell
Query Batchsource codeOpen in Cloud Shell
Query Clustered Tablesource codeOpen in Cloud Shell
Query Destination Table Cmeksource codeOpen in Cloud Shell
Query Disable Cachesource codeOpen in Cloud Shell
Query Dry Runsource codeOpen in Cloud Shell
Query External Bigtable Permsource codeOpen in Cloud Shell
Query External Bigtable Tempsource codeOpen in Cloud Shell
Query External Gcs Permsource codeOpen in Cloud Shell
Query External Gcs Tempsource codeOpen in Cloud Shell
Query External Sheets Permsource codeOpen in Cloud Shell
Query External Sheets Tempsource codeOpen in Cloud Shell
Query External Table Awssource codeOpen in Cloud Shell
Query Large Resultssource codeOpen in Cloud Shell
Query Materialized Viewsource codeOpen in Cloud Shell
Query Paginationsource codeOpen in Cloud Shell
Query Partitioned Tablesource codeOpen in Cloud Shell
Query Scriptsource codeOpen in Cloud Shell
Query Short Modesource codeOpen in Cloud Shell
Query Total Rowssource codeOpen in Cloud Shell
Query With Array Of Structs Named Parameterssource codeOpen in Cloud Shell
Query With Array Parameterssource codeOpen in Cloud Shell
Query With Named Parameterssource codeOpen in Cloud Shell
Query With Named Types Parameterssource codeOpen in Cloud Shell
Query With Positional Parameterssource codeOpen in Cloud Shell
Query With Positional Types Parameterssource codeOpen in Cloud Shell
Query With Structs Parameterssource codeOpen in Cloud Shell
Query With Timestamp Parameterssource codeOpen in Cloud Shell
Quickstart Samplesource codeOpen in Cloud Shell
Relax Column Load Appendsource codeOpen in Cloud Shell
Relax Column Modesource codeOpen in Cloud Shell
Relax Table Querysource codeOpen in Cloud Shell
Resource Clean Upsource codeOpen in Cloud Shell
Run Legacy Querysource codeOpen in Cloud Shell
Save Query To Tablesource codeOpen in Cloud Shell
Set User Agentsource codeOpen in Cloud Shell
Simple Appsource codeOpen in Cloud Shell
Simple Querysource codeOpen in Cloud Shell
Simple Query Connection Read Apisource codeOpen in Cloud Shell
Table Existssource codeOpen in Cloud Shell
Table Insert Rowssource codeOpen in Cloud Shell
Table Insert Rows Without Row Idssource codeOpen in Cloud Shell
Undelete Tablesource codeOpen in Cloud Shell
Update Dataset Accesssource codeOpen in Cloud Shell
Update Dataset Descriptionsource codeOpen in Cloud Shell
Update Dataset Expirationsource codeOpen in Cloud Shell
Update Dataset Partition Expirationsource codeOpen in Cloud Shell
Update Iam Policysource codeOpen in Cloud Shell
Update Materialized Viewsource codeOpen in Cloud Shell
Update Model Descriptionsource codeOpen in Cloud Shell
Update Routinesource codeOpen in Cloud Shell
Update Table Cmeksource codeOpen in Cloud Shell
Update Table Descriptionsource codeOpen in Cloud Shell
Update Table Dmlsource codeOpen in Cloud Shell
Update Table Expirationsource codeOpen in Cloud Shell
Update Table Require Partition Filtersource codeOpen in Cloud Shell
Update View Querysource codeOpen in Cloud Shell

Troubleshooting

To get help, follow the instructions in the shared Troubleshooting document.

Supported Java Versions

Java 8 or above is required for using this client.

Google's Java client libraries, Google Cloud Client Libraries and Google Cloud API Libraries, follow the Oracle Java SE support roadmap (see the Oracle Java SE Product Releases section).

For new development

In general, new feature development occurs with support for the lowest Java LTS version covered by Oracle's Premier Support (which typically lasts 5 years from initial General Availability). If the minimum required JVM for a given library is changed, it is accompanied by a semver major release.

Java 11 and (in September 2021) Java 17 are the best choices for new development.

Keeping production systems current

Google tests its client libraries with all current LTS versions covered by Oracle's Extended Support (which typically lasts 8 years from initial General Availability).

Legacy support

Google's client libraries support legacy versions of Java runtimes with long term stable libraries that don't receive feature updates on a best efforts basis as it may not be possible to backport all patches.

Google provides updates on a best efforts basis to apps that continue to use Java 7, though apps might need to upgrade to current versions of the library that supports their JVM.

Where to find specific information

The latest versions and the supported Java versions are identified on the individual GitHub repository github.com/GoogleAPIs/java-SERVICENAME and on google-cloud-java.

Versioning

This library follows Semantic Versioning.

Contributing

Contributions to this library are always welcome and highly encouraged.

See CONTRIBUTING for more information how to get started.

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms. See Code of Conduct for more information.

License

Apache 2.0 - See LICENSE for more information.

CI Status

Java VersionStatus
Java 8Kokoro CI
Java 8 OSXKokoro CI
Java 8 WindowsKokoro CI
Java 11Kokoro CI

Java is a registered trademark of Oracle and/or its affiliates.