Google Cloud Services - BigQuery

This extension allows to inject a object inside your Quarkus application.

Be sure to have read the Google Cloud Services extension pack global documentation before this one, it contains general configuration and information.

Bootstrapping the project

First, we need a new project. Create a new project with the following command (replace the version placeholder with the correct one):

mvn io.quarkus:quarkus-maven-plugin:${quarkusVersion}:create \
    -DprojectGroupId=org.acme \
    -DprojectArtifactId=bigquery-quickstart \
cd bigquery-quickstart

This command generates a Maven project, importing the Google Cloud BigQuery extension.

If you already have your Quarkus project configured, you can add the quarkus-google-cloud-bigquery extension to your project by running the following command in your project base directory:

./mvnw quarkus:add-extension -Dextensions="quarkus-google-cloud-bigquery"

This will add the following to your pom.xml:


Some example

This is an example usage of the extension: we create a REST resource with a single endpoint that queries the Stackoverflow public dataset for questions tagged with 'google-bigquery' and returns the results.

import java.util.UUID;

import javax.inject.Inject;


public class BigQueryResource {
    BigQuery bigquery; // Inject BigQuery

    public String bigquery() throws InterruptedException {
        QueryJobConfiguration queryConfig = QueryJobConfiguration.newBuilder(// Define a new Job with the query
                "SELECT "
                        + "CONCAT('', CAST(id as STRING)) as url, view_count "
                        + "FROM `bigquery-public-data.stackoverflow.posts_questions` "
                        + "WHERE tags like '%google-bigquery%' ORDER BY favorite_count DESC LIMIT 10")

        // Create a job ID so that we can safely retry.
        JobId jobId = JobId.of(UUID.randomUUID().toString());
        Job queryJob = bigquery.create(JobInfo.newBuilder(queryConfig).setJobId(jobId).build());

        // Wait for the query to complete.
        queryJob = queryJob.waitFor();

        // Check for errors
        if (queryJob == null) {
            throw new RuntimeException("Job no longer exists");
        } else if (queryJob.getStatus().getError() != null) {
            throw new RuntimeException(queryJob.getStatus().getError().toString());

        // Get the results and return them
        TableResult result = queryJob.getQueryResults();
        return, false)
                .map(row -> row.get("url").getStringValue() + " - " + row.get("view_count").getLongValue() + "\n")