How do I run a BigQuery transformation?
Create, configure, and run a Google BigQuery SQL transformation in Keboola from start to finish — set input mapping, write the SQL, set output mapping, run it, and confirm the result table landed in Storage.
You have a table in Keboola Storage and you want to transform it with BigQuery SQL and write the result back to Storage. This page takes you from nothing to a finished, successful run using a small worked example. For exact limits and syntax rules, see the reference.
Time: ~10 minutes · You will need: a Keboola project (on a BigQuery backend) where you can create configurations, and one table in Storage to read from.
Before you start
Section titled “Before you start”Get a table into Storage to use as the input. If you do not have one handy, upload the sample CSV file as a new table (Storage → your bucket → Create Table) — the example SQL below expects a source table with first and second columns.
Step 1 — Create the transformation
Section titled “Step 1 — Create the transformation”- Open Components → Transformations.
- Click New Transformation.
- Choose Google BigQuery Transformation as the type.
- Give it a descriptive name and confirm.
Step 2 — Add the input mapping
Section titled “Step 2 — Add the input mapping”- In Input Mapping, click New Table Input.
- Set Source to your Storage table.
- Set the Destination (staging table name) to
source. - Save the mapping.
Step 3 — Write the SQL script
Section titled “Step 3 — Write the SQL script”In the code editor, paste:
CREATE OR REPLACE TABLE `result` ASSELECT `first`, CAST(`second` AS INT64) * 42 AS `larger_second`FROM `source`;This reads the staged source table and creates a result table with first and second × 42. Quote identifiers with backticks (`source`). You can split longer scripts into blocks.
Step 4 — Add the output mapping
Section titled “Step 4 — Add the output mapping”- In Output Mapping, click New Table Output.
- Set Source (the staging table the script created) to
result. - Set Destination to a new Storage table, for example
out.c-main.result. - Save the mapping.
Step 5 — Run it and confirm the result
Section titled “Step 5 — Run it and confirm the result”- Click Run on the transformation.
- Wait for the job to finish with a success status.
- Open Storage, find your destination table (
out.c-main.result), and check the data sample: it should containfirstandlarger_second, withlarger_secondequal tosecond × 42.
If the table is there with the expected values, the transformation works.
Adjust the query timeout
Section titled “Adjust the query timeout”By default a BigQuery query is capped at BigQuery’s own maximum runtime. To raise or lower it for this configuration, set the Query timeout parameter — see limits.
Stop a run on a condition
Section titled “Stop a run on a condition”To abort deliberately (for example, when an integrity check fails) and return a user error, set the ABORT_TRANSFORMATION variable in your script. See aborting execution.
Troubleshooting
Section titled “Troubleshooting”| Symptom | Likely cause | Fix |
|---|---|---|
Not found: Table source (or similar) | Input mapping destination doesn’t match the script | Make sure the input Destination is exactly source and the script references `source`. |
| Run succeeds but nothing appears in Storage | No output mapping, or wrong Source staging name | Add an output mapping whose Source matches the table your script created (result). |
| Query exceeds the time limit | Long-running query past the BigQuery maximum | Optimize the query, or raise the Query timeout parameter (reference). |
| Transformation aborted with a user error | ABORT_TRANSFORMATION was set to a non-empty value | Expected if you use the abort pattern; otherwise check the logic that sets it. |
Related
Section titled “Related”- BigQuery transformation reference — limits, data types, UDFs.
- Input and output mapping — how staging works.
- Tutorial: Manipulating data — guided first transformation.