googleapis / java-bigquery

Apache License 2.0
112 stars 121 forks source link

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:

<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"

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.

Sample Source Code Try it
Add Column Load Append source code Open in Cloud Shell
Add Empty Column source code Open in Cloud Shell
Auth Drive Scope source code Open in Cloud Shell
Auth Snippets source code Open in Cloud Shell
Auth User Flow source code Open in Cloud Shell
Auth User Query source code Open in Cloud Shell
Authorize Dataset source code Open in Cloud Shell
Authorized View Tutorial source code Open in Cloud Shell
Browse Table source code Open in Cloud Shell
Cancel Job source code Open in Cloud Shell
Copy Multiple Tables source code Open in Cloud Shell
Copy Table source code Open in Cloud Shell
Copy Table Cmek source code Open in Cloud Shell
Create And Query Repeated Record Field source code Open in Cloud Shell
Create Clustered Table source code Open in Cloud Shell
Create Dataset source code Open in Cloud Shell
Create Dataset Aws source code Open in Cloud Shell
Create Dataset With Regional Endpoint source code Open in Cloud Shell
Create External Table Aws source code Open in Cloud Shell
Create Iam Policy source code Open in Cloud Shell
Create Job source code Open in Cloud Shell
Create Materialized View source code Open in Cloud Shell
Create Model source code Open in Cloud Shell
Create Partitioned Table source code Open in Cloud Shell
Create Range Partitioned Table source code Open in Cloud Shell
Create Routine source code Open in Cloud Shell
Create Routine Ddl source code Open in Cloud Shell
Create Table source code Open in Cloud Shell
Create Table Cmek source code Open in Cloud Shell
Create Table External Hive Partitioned source code Open in Cloud Shell
Create Table Without Schema source code Open in Cloud Shell
Create Tables With Primary And Foreign Keys source code Open in Cloud Shell
Create View source code Open in Cloud Shell
Dataset Exists source code Open in Cloud Shell
Ddl Create View source code Open in Cloud Shell
Delete Dataset source code Open in Cloud Shell
Delete Dataset And Contents source code Open in Cloud Shell
Delete Label Dataset source code Open in Cloud Shell
Delete Label Table source code Open in Cloud Shell
Delete Materialized View source code Open in Cloud Shell
Delete Model source code Open in Cloud Shell
Delete Routine source code Open in Cloud Shell
Delete Table source code Open in Cloud Shell
Export Query Results To S3 source code Open in Cloud Shell
Extract Model source code Open in Cloud Shell
Extract Table Compressed source code Open in Cloud Shell
Extract Table To Csv source code Open in Cloud Shell
Extract Table To Json source code Open in Cloud Shell
Get Dataset Info source code Open in Cloud Shell
Get Dataset Labels source code Open in Cloud Shell
Get Job source code Open in Cloud Shell
Get Model source code Open in Cloud Shell
Get Routine source code Open in Cloud Shell
Get Table source code Open in Cloud Shell
Get Table Labels source code Open in Cloud Shell
Get View source code Open in Cloud Shell
Grant View Access source code Open in Cloud Shell
Inserting Data Types source code Open in Cloud Shell
Label Dataset source code Open in Cloud Shell
Label Table source code Open in Cloud Shell
List Datasets source code Open in Cloud Shell
List Datasets By Label source code Open in Cloud Shell
List Jobs source code Open in Cloud Shell
List Models source code Open in Cloud Shell
List Routines source code Open in Cloud Shell
List Tables source code Open in Cloud Shell
Load Avro From Gcs source code Open in Cloud Shell
Load Avro From Gcs Truncate source code Open in Cloud Shell
Load Csv From Gcs source code Open in Cloud Shell
Load Csv From Gcs Autodetect source code Open in Cloud Shell
Load Csv From Gcs Truncate source code Open in Cloud Shell
Load Json From Gcs source code Open in Cloud Shell
Load Json From Gcs Autodetect source code Open in Cloud Shell
Load Json From Gcs Cmek source code Open in Cloud Shell
Load Json From Gcs Truncate source code Open in Cloud Shell
Load Local File source code Open in Cloud Shell
Load Local File In Session source code Open in Cloud Shell
Load Orc From Gcs source code Open in Cloud Shell
Load Orc From Gcs Truncate source code Open in Cloud Shell
Load Parquet source code Open in Cloud Shell
Load Parquet Replace Table source code Open in Cloud Shell
Load Partitioned Table source code Open in Cloud Shell
Load Table Clustered source code Open in Cloud Shell
Nested Repeated Schema source code Open in Cloud Shell
Query Batch source code Open in Cloud Shell
Query Clustered Table source code Open in Cloud Shell
Query Destination Table Cmek source code Open in Cloud Shell
Query Disable Cache source code Open in Cloud Shell
Query Dry Run source code Open in Cloud Shell
Query External Bigtable Perm source code Open in Cloud Shell
Query External Bigtable Temp source code Open in Cloud Shell
Query External Gcs Perm source code Open in Cloud Shell
Query External Gcs Temp source code Open in Cloud Shell
Query External Sheets Perm source code Open in Cloud Shell
Query External Sheets Temp source code Open in Cloud Shell
Query External Table Aws source code Open in Cloud Shell
Query Large Results source code Open in Cloud Shell
Query Materialized View source code Open in Cloud Shell
Query Pagination source code Open in Cloud Shell
Query Partitioned Table source code Open in Cloud Shell
Query Script source code Open in Cloud Shell
Query Short Mode source code Open in Cloud Shell
Query Total Rows source code Open in Cloud Shell
Query With Array Of Structs Named Parameters source code Open in Cloud Shell
Query With Array Parameters source code Open in Cloud Shell
Query With Named Parameters source code Open in Cloud Shell
Query With Named Types Parameters source code Open in Cloud Shell
Query With Positional Parameters source code Open in Cloud Shell
Query With Positional Types Parameters source code Open in Cloud Shell
Query With Structs Parameters source code Open in Cloud Shell
Query With Timestamp Parameters source code Open in Cloud Shell
Quickstart Sample source code Open in Cloud Shell
Relax Column Load Append source code Open in Cloud Shell
Relax Column Mode source code Open in Cloud Shell
Relax Table Query source code Open in Cloud Shell
Resource Clean Up source code Open in Cloud Shell
Run Legacy Query source code Open in Cloud Shell
Save Query To Table source code Open in Cloud Shell
Set User Agent source code Open in Cloud Shell
Simple App source code Open in Cloud Shell
Simple Query source code Open in Cloud Shell
Simple Query Connection Read Api source code Open in Cloud Shell
Table Exists source code Open in Cloud Shell
Table Insert Rows source code Open in Cloud Shell
Table Insert Rows Without Row Ids source code Open in Cloud Shell
Undelete Table source code Open in Cloud Shell
Update Dataset Access source code Open in Cloud Shell
Update Dataset Description source code Open in Cloud Shell
Update Dataset Expiration source code Open in Cloud Shell
Update Dataset Partition Expiration source code Open in Cloud Shell
Update Iam Policy source code Open in Cloud Shell
Update Materialized View source code Open in Cloud Shell
Update Model Description source code Open in Cloud Shell
Update Routine source code Open in Cloud Shell
Update Table Cmek source code Open in Cloud Shell
Update Table Description source code Open in Cloud Shell
Update Table Dml source code Open in Cloud Shell
Update Table Expiration source code Open in Cloud Shell
Update Table Require Partition Filter source code Open in Cloud Shell
Update View Query source code Open 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 Version Status
Java 8 Kokoro CI
Java 8 OSX Kokoro CI
Java 8 Windows Kokoro CI
Java 11 Kokoro CI

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