tree: 78b1ae629a0652594f309b964045aa4dde4f9642
  1. src/
  2. data.yaml
  3. demo.sh
  4. docker-compose.yml
  5. pom.xml
  6. README.md
bigquery-setup/README.md

BigQuery Local Setup

Local BigQuery emulator and validation instructions for the Wayang BigQuery platform.

The local validation path has two parts and does not require a GCP account:

  1. Build the Wayang BigQuery platform and run the shared JDBC SQL-generation tests.
  2. Run BigQuery-compatible SQL tests against the local emulator.

There is also an optional real-BigQuery validation path:

  1. Run the Wayang BigQuery operator tests through JDBC against real BigQuery.

Run the commands below from the repository root. Java 17 and Docker with Docker Compose are required for the emulator tests. A GCP project and service-account key, plus the gcloud SDK, are required only for the optional real-BigQuery operator tests. Maven is provided by the repository wrapper.

Command Conventions

Use the bash blocks on macOS/Linux terminals. Use the powershell blocks on Windows PowerShell from the repository root. Docker Compose commands are the same on both platforms. The gcloud commands also work on Windows; either run each command on one line or replace Bash line-continuation backslashes with PowerShell backticks.

Stack

ComponentImagePortRole
BigQuery Emulatorghcr.io/goccy/bigquery-emulator:0.6.69050 (HTTP) / 9060 (gRPC)BigQuery-compatible SQL engine

Single container. Data is seeded from data.yaml on startup and lives in memory.

Directory Layout

bigquery-setup/
|-- docker-compose.yml          # Emulator container
|-- data.yaml                   # Seed data (test-project.sales.orders)
|-- pom.xml                     # Standalone Maven project
`-- src/test/java/.../
    `-- BigQueryEmulatorIT.java # JUnit 5 integration tests

wayang-platforms/wayang-bigquery/src/test/java/.../
`-- BigQueryOperatorsIT.java    # Wayang operator tests against real BigQuery

1. Test the Wayang BigQuery Platform

Build the BigQuery platform and its required modules:

./mvnw -Pskip-prerequisite-check -pl wayang-platforms/wayang-bigquery -am -DskipTests -Drat.skip=true test

On PowerShell:

.\mvnw.cmd --% -Pskip-prerequisite-check -pl wayang-platforms/wayang-bigquery -am -DskipTests -Drat.skip=true test

Then run the shared JDBC SQL-generation tests:

./mvnw -Pskip-prerequisite-check -pl wayang-platforms/wayang-jdbc-template -am -Dtest=JdbcExecutorTest -Dsurefire.failIfNoSpecifiedTests=false -DfailIfNoTests=false -Drat.skip=true test

On PowerShell:

.\mvnw.cmd --% -Pskip-prerequisite-check -pl wayang-platforms/wayang-jdbc-template -am -Dtest=JdbcExecutorTest -Dsurefire.failIfNoSpecifiedTests=false -DfailIfNoTests=false -Drat.skip=true test

Expected result:

Wayang Platform BigQuery ... SUCCESS
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0

2. Test the Local BigQuery Emulator

1. Start the emulator

docker compose -f bigquery-setup/docker-compose.yml up -d

The emulator starts in ~2 seconds. Data from data.yaml is loaded automatically.

2. Run integration tests

./mvnw -f bigquery-setup/pom.xml -Dtest=BigQueryEmulatorIT test

On PowerShell:

.\mvnw.cmd --% -f bigquery-setup/pom.xml -Dtest=BigQueryEmulatorIT test

The successful result must show that no tests were skipped:

Tests run: 7, Failures: 0, Errors: 0, Skipped: 0

If the emulator is unavailable, Maven can still print BUILD SUCCESS while showing Skipped: 7. That does not count as a successful emulator test.

3. Manual exploration

Query via curl:

curl -s -X POST \
  "http://localhost:9050/bigquery/v2/projects/test-project/queries" \
  -H "Content-Type: application/json" \
  -d '{"query": "SELECT * FROM sales.orders LIMIT 5", "useLegacySql": false}' \
  | python3 -m json.tool

4. Tear down

docker compose -f bigquery-setup/docker-compose.yml down

3. Optional: Test the Wayang Operators Against Real BigQuery

BigQueryOperatorsIT uses the BigQuery JDBC driver and cannot run against the local emulator. It requires a real GCP project and a service-account JSON key.

The test setup creates its own fixture tables in a configurable dataset (wayang_it by default): orders, regions, and operator_result. The tests issue SELECT, CREATE TABLE AS, and DROP statements, then remove those tables during cleanup.

1. Enable BigQuery and create a service account

Replace YOUR_PROJECT_ID in the following commands:

gcloud auth login
gcloud config set project YOUR_PROJECT_ID
gcloud services enable bigquery.googleapis.com

gcloud iam service-accounts create wayang-bq \
  --display-name="Wayang BigQuery IT"

gcloud projects add-iam-policy-binding YOUR_PROJECT_ID \
  --member="serviceAccount:wayang-bq@YOUR_PROJECT_ID.iam.gserviceaccount.com" \
  --role="roles/bigquery.jobUser"

gcloud projects add-iam-policy-binding YOUR_PROJECT_ID \
  --member="serviceAccount:wayang-bq@YOUR_PROJECT_ID.iam.gserviceaccount.com" \
  --role="roles/bigquery.dataEditor"

gcloud iam service-accounts keys create "$HOME/wayang-bq-key.json" \
  --iam-account="wayang-bq@YOUR_PROJECT_ID.iam.gserviceaccount.com"

On Windows PowerShell, the same setup can be run as:

gcloud auth login
gcloud config set project YOUR_PROJECT_ID
gcloud services enable bigquery.googleapis.com
gcloud iam service-accounts create wayang-bq --display-name="Wayang BigQuery IT"
gcloud projects add-iam-policy-binding YOUR_PROJECT_ID --member="serviceAccount:wayang-bq@YOUR_PROJECT_ID.iam.gserviceaccount.com" --role="roles/bigquery.jobUser"
gcloud projects add-iam-policy-binding YOUR_PROJECT_ID --member="serviceAccount:wayang-bq@YOUR_PROJECT_ID.iam.gserviceaccount.com" --role="roles/bigquery.dataEditor"
gcloud iam service-accounts keys create "$HOME\wayang-bq-key.json" --iam-account="wayang-bq@YOUR_PROJECT_ID.iam.gserviceaccount.com"

The service account needs jobUser to run queries and dataEditor to create, read, and drop the test dataset tables.

2. Choose the test dataset

The test creates the dataset if it does not exist. By default it uses wayang_it; override it with -Dbigquery.dataset=DATASET_ID or BIGQUERY_DATASET if the project needs a different dataset name.

3. Run the operator tests

./mvnw -Pskip-prerequisite-check -pl wayang-platforms/wayang-bigquery -am \
  -Dtest=BigQueryOperatorsIT -Dsurefire.failIfNoSpecifiedTests=false \
  -DfailIfNoTests=false \
  -Dbigquery.project=YOUR_PROJECT_ID \
  -Dbigquery.saEmail=wayang-bq@YOUR_PROJECT_ID.iam.gserviceaccount.com \
  -Dbigquery.keyPath="$HOME/wayang-bq-key.json" \
  -Dbigquery.location=US \
  -Dbigquery.dataset=wayang_it \
  -Drat.skip=true -Dlicense.skip=true test

On PowerShell:

.\mvnw.cmd --% -Pskip-prerequisite-check -pl wayang-platforms/wayang-bigquery -am -Dtest=BigQueryOperatorsIT -Dsurefire.failIfNoSpecifiedTests=false -DfailIfNoTests=false -Dbigquery.project=YOUR_PROJECT_ID -Dbigquery.saEmail=wayang-bq@YOUR_PROJECT_ID.iam.gserviceaccount.com -Dbigquery.keyPath=C:\path\to\wayang-bq-key.json -Dbigquery.location=US -Dbigquery.dataset=wayang_it -Drat.skip=true -Dlicense.skip=true test

System properties take precedence over the equivalent environment variables:

System propertyEnvironment variableDefault
bigquery.projectBIGQUERY_PROJECTyour-project
bigquery.saEmailBIGQUERY_SA_EMAILwayang-bq@<project>.iam.gserviceaccount.com
bigquery.keyPathBIGQUERY_KEY_PATH$HOME/wayang-bq-key.json
bigquery.locationBIGQUERY_LOCATIONUS
bigquery.datasetBIGQUERY_DATASETwayang_it

Successful real-BigQuery validation must show:

Tests run: 13, Failures: 0, Errors: 0, Skipped: 0

If the browser uses a local proxy, pass the same proxy to both CLI tools and the Maven test JVM. For example, with a proxy at 127.0.0.1:7890, set HTTP_PROXY/HTTPS_PROXY and use JAVA_TOOL_OPTIONS with -Dhttp.proxyHost, -Dhttp.proxyPort, -Dhttps.proxyHost, and -Dhttps.proxyPort.

On PowerShell:

$env:HTTP_PROXY="http://127.0.0.1:7890"
$env:HTTPS_PROXY="http://127.0.0.1:7890"
$env:JAVA_TOOL_OPTIONS="-Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=7890 -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=7890"
.\mvnw.cmd --% -Pskip-prerequisite-check -pl wayang-platforms/wayang-bigquery -am -Dtest=BigQueryOperatorsIT -Dsurefire.failIfNoSpecifiedTests=false -DfailIfNoTests=false -Dbigquery.project=YOUR_PROJECT_ID -Dbigquery.saEmail=wayang-bq@YOUR_PROJECT_ID.iam.gserviceaccount.com -Dbigquery.keyPath=C:\path\to\wayang-bq-key.json -Dbigquery.location=US -Dbigquery.dataset=wayang_it -Drat.skip=true -Dlicense.skip=true test
Remove-Item Env:HTTP_PROXY, Env:HTTPS_PROXY, Env:JAVA_TOOL_OPTIONS

If credentials or the project configuration are missing, Maven can still print BUILD SUCCESS with Skipped: 13. That does not count as successful real-BigQuery validation.

4. Optional: Re-run Cost Profiling

Follow the shared cost-profiling guide in guides/cost-profiling.md. This setup guide only covers the BigQuery emulator and real BigQuery validation setup. BigQuery cost profiling uses BigQueryCostPilotIT, so it needs the same real-BigQuery credentials as the optional operator tests above.

BigQuery-specific profiling values:

ItemValue
Maven modulewayang-platforms/wayang-bigquery
Profiling testBigQueryCostPilotIT
Property prefixbigquery.profile.*
Profiling dataset propertybigquery.profile.dataset
Default output directorytarget/cost-profiling/bigquery
Learned parameters filewayang-platforms/wayang-bigquery/src/main/resources/wayang-bigquery-defaults.properties

Test Coverage

Local emulator tests

TestWhat it checks
testDatasetVisiblesales dataset exists
testFullScanFull table scan, 10 rows
testFilterByRegionWHERE region = 'APAC'
testFilterByAmountWHERE amount > 1000
testAggregationGROUP BY region + SUM(amount)
testProjectionSELECT region, product LIMIT 5
testCountSELECT count(*), used by Wayang for cardinality estimation

Real BigQuery operator tests

TestWhat it checks
tableSourceFull table scan through Wayang into a BigQuery sink table
filterString filter pushdown
projectionMulti-column projection pushdown
joinFull Wayang join plan with normalization before the sink table
globalReduceGlobal SUM(amount)
reduceBySUM(amount) GROUP BY region
sortBigQuery sort operator SQL-clause contract
tableSinkCREATE TABLE AS SELECT and cleanup
javaPlanBuilderReadTableFilterProjectionreadTable -> filter -> projection -> writeTable
javaPlanBuilderReadTableFilterGlobalReducereadTable -> filter -> globalReduce -> writeTable
javaPlanBuilderReadTableReduceBySortreadTable -> reduceByKey -> sort -> writeTable
javaPlanBuilderReadTableFilterProjectionTableSinkreadTable -> filter -> projection -> writeTable
javaPlanBuilderReadTableJoinreadTable + readTable -> join -> writeTable

The combination tests use .withTargetPlatform(BigQuery.platform()) so the small 10-row fixture still exercises BigQuery SQL pushdown. The join test creates and cleans up a temporary distinct-region lookup table.

Emulator Environment Variable

BIGQUERY_HOST=http://localhost:9050 ./mvnw -f bigquery-setup/pom.xml -Dtest=BigQueryEmulatorIT test

On PowerShell:

$env:BIGQUERY_HOST="http://localhost:9050"
.\mvnw.cmd --% -f bigquery-setup/pom.xml -Dtest=BigQueryEmulatorIT test
Remove-Item Env:BIGQUERY_HOST

Notes

  • Emulator tests use the google-cloud-bigquery client library (REST-based, no JDBC).
  • The emulator client connects with NoCredentials; no GCP account is needed.
  • The BigQuery JDBC driver (google-cloud-bigquery-jdbc) requires OAuth even against the emulator, so BigQueryOperatorsIT runs only against real BigQuery.
  • Emulator tests validate SQL compatibility, but only BigQueryOperatorsIT validates end-to-end Wayang-to-BigQuery JDBC execution.