Prepare and test your skills

Prepare and test your skills

Design and execution of data transformation pipelines for feature creation is the process of converting raw source data into normalized, encoded, and complete features that models can consume at scale. Raw data flows from operational sources into ingestion tools, then through transformation logic, and finally into training tables or a central feature store for serving. On Google Cloud, BigQuery (opens in a new tab) handles tabular SQL transformation, Dataflow (opens in a new tab) handles batch and streaming transformation, and BigQuery ML (opens in a new tab) applies automatic preprocessing during CREATE MODEL.
Scalable ingestion and transformation architecture separates source selection from data movement so batch, streaming, and event-driven features can share one pipeline pattern. Data sources include operational databases such as Cloud SQL, Spanner, AlloyDB for PostgreSQL, and Firestore, data lakes such as Cloud Storage with BigLake, streaming platforms such as Pub/Sub and Dataflow, and external APIs. For each source, data flows from the source system into an ingestion tool and then into BigQuery or Cloud Storage storage optimized for machine learning (ML) training, separate from the operational source.
Transformation tool choice depends on latency, volume, and reuse requirements for feature consumption. Dataflow processes data from various sources in batch and stream with ML-component integration, and it combines with Eventarc for event-driven architectures where changes trigger processing. Dataform automates SQL-based transformations for extraction, loading, and transformation (ELT) workflows after raw data lands in BigQuery staging tables. BigQuery itself performs classical tabular ingestion and in-warehouse SQL transformation for frequently accessed structured data, where materialized tables provide faster training reads than views or subqueries.
Feature transformation logic in these pipelines covers four core tasks for model consumption. Feature scaling standardizes numeric ranges, categorical encoding converts strings and booleans to numeric vectors, missing-value handling replaces gaps, and derived-feature creation builds new signals such as bucketed ranges or crossed categories. Dataflow or Dataform automates these operations in batch, streaming, or real time, while Vertex AI Feature Store (opens in a new tab) centralizes the resulting features in BigQuery tables or views for reuse across models and projects. Because BigQuery stores both online serving data and historical offline data, the same feature definitions support training and serving without duplicate engineering.
Automatic preprocessing in BigQuery ML is the default transformation that runs during training through the CREATE MODEL statement without custom code. Automatic preprocessing consists of missing-value imputation followed by feature transformation, and the same statistics learned during training are automatically applied during prediction. This behavior ensures that training and serving see consistent feature values even when prediction rows contain nulls or previously unseen categories.
Missing-data handling in BigQuery ML treats NULL values during training as missing data, while prediction treats both NULL values and unseen values as missing. Numeric columns replace nulls with the column mean calculated from the original input data in both training and prediction. One-hot and multi-hot encoded columns map nulls to an added category, while unseen values receive a weight of 0 during prediction. TIMESTAMP columns use a mixed approach where the generated Unix time column uses mean imputation and other extracted fields use a null category, and each field of a STRUCT column is imputed according to its own type.
The following table compares imputation behavior by column type for training and prediction:
| Column type | Training imputation | Prediction imputation |
|---|---|---|
| Numeric | NULL replaced with column mean | NULL replaced with column mean |
| One-hot / Multi-hot encoded | NULL mapped to added category | NULL mapped to added category; unseen value weight is 0 |
TIMESTAMP | Unix time uses mean; extracted fields use null category | Unix time uses mean; extracted fields use null category |
STRUCT | Each field imputed by its type | Each field imputed by its type |
Default feature transformations in BigQuery ML depend on input data type and model type. Numeric types including INT64, NUMERIC, BIGNUMERIC, and FLOAT64 are standardized and centered at zero for most models, which regularizes scale differences before training. Non-numerical, non-array columns such as BOOL, STRING, BYTES, DATE, DATETIME, and TIME receive one-hot encoding for most models, which creates a separate feature for each unique value. Non-numerical ARRAY columns receive multi-hot encoding, which creates a separate feature for each unique element in the array.
Exam tip: Boosted tree and random forest models skip standardization and use label encoding instead of one-hot encoding, while k-means models control standardization with the STANDARDIZE_FEATURES option.
Manual feature engineering with the TRANSFORM clause is custom preprocessing defined inside CREATE MODEL that runs in addition to automatic preprocessing. The clause takes raw input columns, applies manual preprocessing functions, and passes only the transformed outputs to training, so the model never sees the untransformed values. The ML.TRANSFORM function then returns those preprocessed rows for inspection, which makes training data and prediction-time serving data transparent and reproducible.
Manual preprocessing functions divide by how they read rows and preserve training-to-serving consistency. Scalar functions operate on a single row, such as bucketizing a value. Table-valued functions operate on all rows and output a table, such as retrieving features at a point in time. Analytic functions operate on all rows but return a result per row based on statistics collected across the full dataset, and they always require an empty OVER() clause so BigQuery ML can capture the statistics during training and reapply the same statistics during prediction.
Common manual functions for normalization, encoding, and cleanup include:
A transform-only model decouples preprocessing from model fitting when teams need to version and reuse transformation logic independently. The transform-only model contains only the TRANSFORM clause and outputs transformed tables without training a predictor. Downstream training jobs then depend on the transform-only model for consistent features, which avoids maintaining multiple custom implementations across projects.
Reusable Python and SQL pipelines assemble preprocessing steps and estimators into versioned workflows that automate training, evaluation, and deployment. BigQuery DataFrames provides the bigframes.ml library for Python-based preprocessing, where transformers from bigframes.ml.preprocessing and bigframes.ml.compose prepare data for estimators. The bigframes.ml.pipeline.Pipeline class chains multiple transforms with a final estimator so preprocessing and modeling deploy together, while bigframes.ml.model_selection splits data with train_test_split, KFold, or cross_validate for robust evaluation.
Production orchestration on Google Cloud routes pipeline tasks through dependencies so repeatable steps can be scheduled and monitored. A typical BigQuery ML development workflow follows an ordered sequence:
CREATE MODEL statement.TRANSFORM.Three orchestration options support different complexity and governance needs for ML pipelines. Vertex AI Pipelines structures work as a directed acyclic graph (DAG) of containerized tasks where outputs from one task flow as inputs to the next task, which suits portable multi-step MLOps with BigQuery ML components. GoogleSQL procedural language runs multi-statement queries with shared state and IF and WHILE logic, which suits less complex SQL pipelines that can be saved and scheduled for retraining and monitoring. Dataform develops, tests, versions, and schedules complex SQL transformation suites, which suits ELT-heavy feature pipelines that require version control and documentation before model training.
Optimizing data storage and partitioning for ML workloads means choosing where data lives, what file format it uses, and how it is divided so iterative training and batch prediction scan less data, run faster, and cost less. BigQuery (opens in a new tab) separates storage, compute, and memory into independently scaled services, while Cloud Storage (opens in a new tab) holds data-lake files that feed training jobs directly or through BigQuery tables. The right combination of columnar formats, Hive-style partitioning, BigQuery native storage, and read APIs determines whether repeated feature queries and scoring jobs stay fast and affordable.
Separated storage, compute, and memory in BigQuery is a design where compute, memory, and storage scale independently instead of as fixed nodes. Compute is measured in slots, which are units of query-processing capacity managed by Google in reservations assigned to projects, folders, or organizations. Memory comes from a remote distributed service connected to slots by a petabit network, and table data lives in Google's distributed file system where it is automatically compressed, encrypted, replicated, and distributed without consuming query slots. Because storage growth to dozens of petabytes does not require adding compute, teams can keep large training tables and prediction outputs online while sizing slots only for query and BigQuery ML workload concurrency.
Columnar file formats in Cloud Storage store processed data for efficient analytical access during feature engineering and model training. Parquet and Optimized Row Columnar (ORC) organize data by column rather than by row, which allows efficient storage and faster access for analytical workloads compared to row-oriented JavaScript Object Notation (JSON) or comma-separated values (CSV) files. A Hive partitioned layout places files in directory prefixes keyed by partitioning columns, so queries that filter on those columns can prune partitions and skip entire directories. File design must also balance the number of files against file size, because too many tiny files increases metadata and listing overhead while very large files can limit parallelism for distributed readers.
The following table compares storage and query behavior for ML scans:
| Format group | Storage behavior | Query behavior for ML scans |
|---|---|---|
| Parquet, ORC | Columnar encoding with compression and persisted column statistics used to plan efficient execution | Much better analytic performance because only needed columns are read and partitions can be pruned |
| JSON, CSV | Row-oriented text without columnar encoding or advanced pruning | Slower analytic performance because full rows and files are typically scanned |
Partitioning, clustering, and BigQuery native storage add controls that external files alone cannot match for repeated training queries. When queries against BigLake tables that read external Parquet, ORC, JSON, or CSV files cannot meet service-level agreement (SLA) requirements and cannot be tuned further, the supported path is to convert the exposed data to BigQuery storage and redefine authorized views to point at the new BigQuery tables. This migration generally does not disrupt consumers or require query changes, but it unlocks optimizations unavailable to BigLake tables, including materialized views with different partitioning and clustering than the base tables and acceleration with the Business Intelligence (BI) Engine. In practice, data flows from Cloud Storage ingestion buckets through processing into curated BigQuery tables, and the serving layer depends on those tables for consistent, pruned, and clustered access during batch prediction.
Exam tip: A BigQuery multi-region dataset location does not provide cross-region replication or regional redundancy — data is stored in a single region within that geography — while a Cloud Storage multi-region or dual-region bucket does replicate data at rest across its regions.
Read paths for training and batch prediction determine how much filtering happens before data reaches training code and how access is controlled. The BigQuery Storage Read API can read data from both BigQuery tables and BigLake tables, supports filtering and fine-grained access control, and is a good option for stable analytics or ML consumers that repeatedly scan large feature sets. The Cloud Storage JSON or XML APIs read bucket objects directly, which is useful only when consumers cannot use the SQL interface or when the bucket holds formats not supported by the Storage Read API. Direct bucket access does not allow filtering or fine-grained access control, so it is viable mainly for stable, small-sized datasets measured in gigabytes, and copying bucket data into consumer projects is discouraged because multiple copies increase storage cost plus maintenance and lineage overhead.
Query execution, monitoring, and cost control for repeated jobs reward early filtering and partition pruning for iterative training queries. First, BigQuery builds an execution tree that breaks the query into stages with steps that can run in parallel. Then stages exchange intermediate data through a fast distributed shuffle tier that uses network and memory to move data to workers, while additional workers monitor progress and dynamically adjust the query plan as results arrive. Only after planning completes does BigQuery write final results to persistent storage and return them, which lets the next identical training-data query serve cached results. Teams control cost and performance for this repeated pattern with on-demand pricing that charges for bytes scanned versus capacity-based pricing that uses reserved slots, plus query-plan inspection in the console, INFORMATION_SCHEMA.JOBS views, custom quotas, and billing alerts — for example, a stage that writes far more output than other stages signals that a filter should move earlier to reduce scanned and shuffled data.
Data versioning and reproducibility for ML experiments is the practice of linking every training run to the exact code, dataset snapshot, transformations, parameters, and metrics that produced it. On Google Cloud, this linkage is built from Vertex ML Metadata (opens in a new tab) for experiment-level lineage, Knowledge Catalog (opens in a new tab) for organization-wide data governance, and Model Registry for model versions, combined with reproducible storage and pipeline practices.
Lineage tracking across data, code, and artifacts connects data sources, transformations, parameters, metrics, and dataset and model artifacts so any experiment can be audited, debugged, and rerun. Vertex ML Metadata logs metadata about data sources, transformations, model parameters, and experiment results, and Experiments on Vertex AI integrates with it to build linkage across those objects. Vertex AI TensorBoard visualizes and compares runs by metrics such as loss and accuracy, model graph, and embeddings, while audit logs record who accessed or modified data and models and when.
Knowledge Catalog provides the governance layer around pipeline lineage and discovery. Metadata from supported Google Cloud sources is automatically ingested into the universal catalog, while sources outside Google Cloud require custom entries. Technical metadata is enriched with business metadata through aspects, and BigQuery adds column-level lineage for fine-grained tracking. Lineage from Vertex AI Pipelines artifacts can be searched in Knowledge Catalog for debugging, troubleshooting, and root-cause analysis, with access controlled so data scientists can search and use trusted assets.
The following table compares what each governance tool tracks and when to use it:
| Tool | What it tracks and versions | Use when |
|---|---|---|
| Vertex ML Metadata | Parameters, metrics, dataset snapshots, transformations, and model artifacts per experiment | Reproducing or comparing training runs and proving which data produced which model |
| Knowledge Catalog | Data entries, aspects, business glossary, data quality, and pipeline artifact lineage | Discovering trusted datasets and tracing data flow across projects and data marts |
| Model Registry | Versions of each stored model | Managing model iterations from experimentation through deployment |
Version control for code and documents uses Git, and pipeline definitions use pipeline versioning in Vertex AI Pipelines or Kubeflow Pipelines. Together, Git plus metadata plus registry versions mean code changes, data changes, and model changes each have an independent, queryable history.
Repeatable training inputs with managed datasets and materialized storage require separating ML training storage from operational sources and freezing the data actually used for training. Data flows from source systems such as logs, devices, or scraped documents into storage optimized for ML training, separate from the operational source. For structured and semi-structured data, that destination is BigQuery, and for maximum speed and reproducibility the training input should be materialized data rather than views or subqueries.
Vertex AI managed datasets create a clear link between that frozen data and custom-trained models. A managed dataset provides descriptive statistics and automatic or manual splitting into train, test, and validation sets, and data is read out through the BigQuery Storage API for artifact tracking. Managed datasets are not required when a team wants full control over splitting logic inside training code or when lineage between data and model is not critical to the application.
Unstructured data follows the same freeze-and-group principle in Cloud Storage. Images, video, and audio are combined into large container formats such as sharded TFRecord files for TensorFlow or Avro files for other frameworks, because large files improve read and write throughput. Aim for files of at least 100 MB with between 100 and 10,000 shards, and use buckets and directories to group shards for management.
Exam tip: Choose a managed dataset when lineage between data and model must be tracked automatically; skip it when custom in-code splitting or full control over the split is required.
Training-serving skew happens when features computed for offline training differ from features served for online prediction across model iterations. Vertex AI Feature Store (opens in a new tab) reduces this risk by creating, maintaining, sharing, and serving ML features in a central location that is optimized for low-latency workloads. Feature data lives in a BigQuery table or view, and BigQuery retains historical feature data so offline training can reuse the same definitions used online.
Use of the Feature Store depends on two objects: the team first creates an online store instance, then defines feature views on top of BigQuery data. Data flows from BigQuery historical storage to offline training jobs and from the online store to serving paths, so both paths resolve the same feature logic. Scheduled monitoring of features and feature groups detects drift after deployment, and centralized features can be reused across different models and projects instead of re-engineering the same transformations.
Reusable data products extend the same idea beyond a single project. Curated datasets published as data products are discovered through Knowledge Catalog and securely exchanged through BigQuery sharing, including data exchanges, listings, and data clean rooms for sensitive data. This reuse accelerates model development and keeps iterations anchored to governed, versioned inputs.
Standardized environments and automated pipelines ensure the same code and data produce the same result regardless of who runs the experiment. Vertex AI Workbench instances provide a secure, reproducible way to access data and AI services for writing code, starting jobs, running queries, and checking status. Best practice is to create one instance per team member, and multiple instances per person when projects have different dependencies, treating each instance as a virtual workspace that can be stopped when not in use.
Automated training pipelines enforce standardization and remove manual variation between iterations. Vertex AI Pipelines orchestrates complex ML workflows as separate containerized tasks, where each step manages data flow to the next step only after its dependencies complete. The pipeline definition controls order of operations for transformation, training, and deployment, and pipeline versioning preserves each workflow revision. Combined with Git for source tracking, the Vertex AI SDK for Python for consistent programmatic runs, and automated data quality scans plus anomaly detection in BigQuery for input validation, the full path from raw data to versioned model remains consistent, observable, and repeatable.
Automatic preprocessing in BigQuery ML applies missing-value imputation followed by feature transformation during CREATE MODEL, and the same statistics learned during training are automatically applied during prediction. Numeric columns replace NULL values with the column mean, one-hot and multi-hot encoded columns map NULLs to an added category while unseen prediction values receive a weight of 0, TIMESTAMP columns use mean imputation for Unix time and a null category for extracted fields, and each field of a STRUCT column is imputed according to its own type.
The TRANSFORM clause applies custom preprocessing inside CREATE MODEL and passes only the transformed outputs to training, so the model never sees the untransformed values, with analytic functions requiring an empty OVER() clause so training statistics can be reused at prediction time. A transform-only model contains only the TRANSFORM clause and outputs transformed tables without training a predictor, which lets downstream training jobs depend on it for consistent features without maintaining multiple custom implementations.
Vertex AI Feature Store should be used when offline training and online prediction must resolve the same feature logic from a central location optimized for low-latency workloads. Feature data lives in a BigQuery table or view, with BigQuery retaining historical feature data for offline training and the online store serving prediction paths after the team creates an online store instance and defines feature views on top of BigQuery data.
A data engineering team is building a scalable feature preprocessing pipeline using Apache Beam on Google Cloud Dataflow. The pipeline must preprocess numerical features by scaling them to a fixed range [min_value, max_value] and convert categorical text columns into integer indices for model training.
To prevent training-serving skew, the exact transformation parameters (such as the computed feature boundaries and vocabulary mappings) generated during the initial training run must be deterministically preserved and reused during subsequent model evaluation and batch inference pipelines.
Which approach should the team implement in Apache Beam to meet these requirements?
Apply Apache Beam's MLTransform with ScaleByMinMax and vocabulary transforms, configuring write_artifact_location during the training data pipeline and read_artifact_location during evaluation and inference pipelines.
Use RunInference with a custom ModelHandler and execute min-max scaling dynamically inside the with_preprocess_fn closure based on each incoming mini-batch.
Deploy a Google-provided Dataflow template and use a JavaScript User-Defined Function (UDF) to compute rolling min-max boundaries and string hashes prior to BigQuery storage.
Use CombineGlobally transforms to calculate minimum, maximum, and distinct vocabulary values, export these values to Cloud Storage, and load them as side inputs inside a standard ParDo transform.
Last updated