JVM - Generic
For use with the official BigQuery Java client
package org.example;
import com.google.cloud.bigquery.BigQuery;
import com.google.cloud.bigquery.BigQueryOptions;
public class Main {
public static void main(String[] args) {
String host = System.getenv("BIGQUERY_EMULATOR_HOST");
if (host == null) {
host = "https://bigquery.googleapis.com";
}
BigQuery bigquery = BigQueryOptions.newBuilder()
.setProjectId("bigquery-public-data")
.setHost(host).build().getService();
// try to list datasets to validate it working
bigquery.listDatasets().iterateAll().forEach(dataset -> {
System.out.println(dataset.getDatasetId().getDataset());
});
}
}Last updated