What You'll Learn
- 1Profile a dataset before writing a single transformation
- 2Express cleaning steps as a repeatable recipe rather than one-off spreadsheet edits
- 3Control DPU spend by choosing sampling and scheduling deliberately
- 4Promote a recipe from exploration into a governed, scheduled pipeline job
Cloud Data Prep is the visual layer that sits between raw files and a warehouse table, aimed at the work an analyst does in the hour after a dataset first lands. It profiles columns, surfaces outliers and format drift, and records every cleaning step as an ordered recipe that can be replayed against tomorrow's extract. Because the recipe is stored rather than implied by a notebook's edit history, the same transformations produce the same output on the next run, which is the property that makes exploration useful to production.
Cloud Data Prep Overview
Data Prep derives from the Trifacta wrangling tooling and runs on a managed compute backend, so the browser stays responsive while the actual work happens on workers sized to the dataset. The mental model is a flow: a source dataset, a wrangled dataset produced by a recipe, and one or more outputs. The profiler samples the source and reports the distribution, null percentage, and detected type of every column, and those profile statistics are what let the tool suggest a transformation instead of asking you to write one.
What separates it from writing SQL is the feedback loop. Each suggested change shows the before-and-after effect on the sample, so a date column that mixes two formats is fixed visibly rather than discovered downstream. What separates it from production code is governance: recipes live in the service, and moving them across environments means exporting them through the API rather than pulling a branch.
| Task | Cloud Data Prep | SQL in BigQuery | dbt or Dataform |
|---|---|---|---|
| Interactive profiling | Built in, visual | Manual queries | Requires tooling |
| Drag-and-drop transforms | Yes | No | No |
| Version control | Export to JSON | Repo native | Repo native |
| Scheduled production runs | Built in | Workflows | Workflows |
| Best fit | Ad hoc wrangling | Aggregation and joins | Modelling and tests |
Key Features
Data Preparation Workflow
A disciplined workflow starts with profiling rather than transforming. Load the source, read the column statistics, and identify which columns actually carry problems: unexpected nulls, mixed formats, values outside an expected range, or categories with trailing whitespace. Only then start writing recipe steps, because transforming before profiling tends to hard-code assumptions that the profile would have contradicted.
The second habit is to keep steps atomic. One step should do one thing, rename a column or change a type or filter a class of rows, so that when a later extract breaks the recipe it is obvious which step is wrong. Data Prep keeps the recipe as an ordered list, and each step can be toggled off to bisect a problem the same way a developer bisects a commit range.
Transformation Recipes
Recipes are written in Trifacta Recipe Language, an ordered sequence of declarations that read top to bottom. Order matters, because a filter placed before a type change sees different values than the same filter placed after, and a derive step that references a renamed column fails if the rename happens later. The language covers the operations a wrangling job needs: rename, retype, filter, derive a new column, aggregate, and join.
Common Transformations
// Data Prep recipe steps (TRQL - Trifacta Recipe Language)
// 1. Rename columns
rename col: `old_name` to: `new_name`
// 2. Change data types
settype col: `amount` as: float
// 3. Filter rows
filter rowtype: `status` == "active"
// 4. Extract date parts
derive col: `year` as: year(`order_date`)
derive col: `month` as: month(`order_date`)
// 5. Conditional transformation
derive col: `category` as:
if(`amount` > 1000, "premium",
if(`amount` > 100, "standard", "basic"))
// 6. String operations
derive col: `domain` as: extract(`email`, "@(.+)$")
// 7. Aggregation
aggregate value: sum(`amount`) group: `product_category`
// 8. Join datasets
join col: `user_id` with: `users` on: `user_id`
Data Quality Rules
// Validation rules
validate col: `email` regex: `^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$`
validate col: `phone` regex: `^\+?[1-9]\d{1,14}$`
validate col: `amount` range: 0 to 1000000
validate col: `date` format: "yyyy-MM-dd"
// Custom validation
validate col: `status` in: ["active", "inactive", "pending"]
// Row-level validation
validate row: `amount` > 0 and `quantity` > 0
Integration with Data Engineering
Data Prep earns its place in a pipeline only when the hand-off to the warehouse is clean. The service reads a source table through a BigQuery connection, applies the recipe, and writes the result back to a BigQuery table or a Cloud Storage path, which means the output can be consumed by a scheduled query or a dashboard without an intermediate copy. For wide, messy extracts the cheaper route is to stage the raw file in Cloud Storage, wrangle it, and load the result, because scanning the source table twice costs on top of the compute.
Scheduling is the second integration point. A recipe can be run on a schedule or invoked through the API, so the practical pattern is to keep the recipe as the definition of cleaning and let a workflow tool own the trigger, retries, and downstream checks. That separation matters during review: a reviewer can read the recipe to see exactly what was changed to the data, which is far more legible than a notebook full of cells.
Export to BigQuery
# Data Prep API for programmatic access
import requests
def create_dataprep_job(api_key, recipe_id, output_table):
"""Create Data Prep job via API."""
headers = {
'Authorization': f'Bearer {api_key}',
'Content-Type': 'application/json'
}
job_config = {
"wrangledDataset": {
"id": recipe_id
},
"execution": {
"runsOn": {
"type": "dataproc",
"projectId": "my-project",
"region": "us-central1"
}
},
"outputs": [{
"type": "bigquery",
"table": output_table
}]
}
response = requests.post(
"https://api.dataprep.trifacta.com/v4/job",
headers=headers,
json=job_config
)
return response.json()
Cost Optimization
Data Prep bills in Data Preparation Units, and a DPU-hour is consumed by the compute that reads, profiles, and transforms the data. Two habits control the bill. The first is to profile and preview on a sample while iterating, because a sample of a few thousand rows produces the same suggestions as the full extract at a fraction of the compute. The second is to run the full recipe only when the recipe has actually changed, rather than on every exploratory click.
The third lever is the one teams miss: sorting, joining, and grouping on high-cardinality columns are the expensive steps, so a recipe that aggregates early is cheaper than one that carries raw columns all the way to the output. Reducing the working set as soon as the transformation logic allows is usually worth more than tuning worker sizes.
# Data Prep pricing components
pricing = {
"dataprep_units": {
"description": "DPUs consumed per transformation",
"cost_per_unit": "$0.05 per DPU-hour"
},
"dataflow_workers": {
"description": "Compute for running recipes",
"cost": "Standard Dataflow pricing"
},
"storage": {
"description": "GCS for intermediate data",
"cost": "Standard GCS pricing"
}
}
# Cost optimization strategies
strategies = {
"profile_before_transform": "Understand data quality before processing",
"use_sampling": "Profile on samples, run full on production",
"incremental_processing": "Process only new/changed data",
"right_size_workers": "Don't over-provision Dataflow workers",
"schedule_off_peak": "Run jobs during off-peak hours for lower costs"
}
âšī¸
Cost Tip: Data Prep charges per DPU-hour (Data Preparation Unit). Profile your data first to understand complexity, then optimize transformations. Use sampling for initial exploration and schedule production jobs during off-peak hours.
Common Interview Questions
Q1: When would you use Cloud Data Prep vs. writing code?
Answer: Cloud Data Prep is ideal for ad-hoc data exploration, business analyst self-service, and quick prototyping. Use code (Python/SQL) for production pipelines requiring version control, testing, and complex logic. Data Prep excels at visual data profiling and interactive transformations.
Q2: How does Data Prep integrate with BigQuery?
Answer: Data Prep can read directly from BigQuery tables and write transformed data back. Use the BigQuery connection for seamless integration. For large datasets, export to GCS first, then load into BigQuery for optimal performance.
Q3: What is the DPU model in Data Prep?
Answer: DPU (Data Preparation Unit) measures computational effort per transformation. Complex operations like joins consume more DPUs than simple filters. Understanding DPU consumption helps optimize costs and plan resource allocation.
Q4: How do you version control Data Prep recipes?
Answer: Data Prep maintains built-in version history for all recipe changes. For external version control, export recipes as JSON and store in Git. Use the Data Prep API to automate recipe deployment across environments.
Q5: What data formats does Data Prep support?
Answer: Data Prep supports CSV, JSON, Parquet, Avro, Excel, and fixed-width formats. For best performance with large datasets, use columnar formats (Parquet/Avro). For web applications, JSON is commonly used.
Common Mistakes
Transforming before profiling the source
Fix: Read the column statistics first so you know which columns have mixed types, nulls, or drift before encoding assumptions.
Burying several changes in one recipe step
Fix: Keep one step per operation so a broken extract can be bisected by toggling individual steps.
Running full-volume jobs while exploring
Fix: Iterate on a sample and run the complete recipe only when the transformation logic has changed.
Best Practices
- Aggregate as early as the logic allows to shrink the working set before expensive sorts
- Export recipes to JSON and keep them in source control alongside the models they feed
- Let a workflow tool own triggers, retries, and checks while the recipe owns the cleaning logic
- Validate outputs with a row count and null-rate check before downstream refreshes run
Key Takeaways
- The workflow is profile first, transform second, so assumptions are checked rather than guessed
- Recipes are ordered programs; step order changes results and each step should do one thing
- DPU spend is driven by volume and by expensive operations, so sample while iterating
- Promote to production by scheduling the recipe through an API or workflow, not by hand
Interview Questions
Q1: When would you use Cloud Data Prep instead of writing code?
Use it for ad hoc exploration, analyst self-service, and the first cleaning pass on a new extract, where interactive profiling and visual suggestions beat writing boilerplate. Move to SQL, Python, or dbt once the logic needs version control, tests, and reviewable pull requests.
Q2: How does Data Prep integrate with BigQuery?
Through a BigQuery connection it reads a source table, runs the recipe on managed compute, and writes the result back to a BigQuery table or to Cloud Storage. Large or frequently scanned sources are better staged in Cloud Storage first so the wrangling does not also pay for repeated table scans.
Q3: What exactly is a DPU?
A Data Preparation Unit is the metered unit of computational effort, consumed per hour of the compute that profiles and transforms data. Complex steps such as joins and sorts consume more than simple filters, which is why early aggregation and sampling are the main cost controls.
Q4: How are Data Prep recipes version controlled?
The service keeps its own revision history for interactive edits, and for anything stronger you export the recipe as JSON through the API and store it in Git, then deploy the same definition to each environment so changes are reviewable and reversible.