Prepare and test your skills
Prepare and test your skills
Identifying trends with BigQuery (opens in a new tab) and Jupyter notebooks means using SQL to summarize large tables and Python to explore and chart the results. BigQuery stores and processes the table data, while a notebook provides the interactive place where code, tables, and charts stay together. Data flows from BigQuery tables to query results to notebook DataFrames and then to charts and dashboards.
Writing GoogleSQL queries for reports means filtering, joining, and aggregating rows into counts, sums, and averages. BigQuery uses GoogleSQL as its preferred ANSI-standard dialect, which supports joins, aggregation and analytic functions, operators, and conditional expressions. The older legacy SQL dialect remains only for existing queries that already use it. Filtering keeps only needed rows, which reduces bytes scanned and improves speed and cost, aggregation collapses detail rows into totals by day, region, or customer, and joining combines related tables such as customers and orders on shared keys. BigQuery supports unenforced foreign keys that describe intended relationships for optimization but do not block mismatched values or enforce integrity. Reusable logic comes from user-defined functions (UDFs) written in SQL or JavaScript and from positional parameters that run the same query with different values. Queries can also reach outside data through external tables and federated queries:
Running queries with BigQuery interfaces means sending the same SQL text through different tools that create query jobs on managed storage and compute. Queries can run as interactive queries for fast results or as batch queries for larger jobs that can wait. A dry run estimates bytes scanned before running, which helps control cost under on-demand pricing based on bytes scanned. BigQuery keeps a history of executed queries, and the INFORMATION_SCHEMA.JOBS view retains all jobs submitted in the last 6 months.
Speeding up reports in BigQuery means using storage and caching designs so repeated queries scan less data and return faster. Partitioned tables divide a large table by time or integer ranges so queries that filter on the partition column skip unneeded partitions. Clustering stores data ordered on disk so queries that filter on clustered columns retrieve matching rows faster, including string columns. Tables can require a partition filter so every query must include the partition column and avoid accidental full-table scans. Materialized views store cached persistent results for queries that run often. BigQuery provides Smart Tuning materialized views that always return current data and support automatic query rewrite even when the query refers to the base table. BI Engine is the fast, in-memory analysis service for low-latency dashboards and interactive exploration. Search Indexes and Vector Indexes, which can be automatic or managed, speed specific lookup and search workloads.
| Option | What it provides | Choose when |
|---|---|---|
| Partitioned tables | Pruned storage by time or integer range | Reports always filter a large table by date or integer range |
| Materialized views | Cached results with automatic rewrite | Same aggregations or joins are queried repeatedly |
| BI Engine | Fast in-memory analysis | Dashboards need low-latency exploration |
Exam tip: BigQuery partitions only by dates and integers; use clustering for string columns that need faster filtered retrieval.
A Colab Enterprise notebook is a BigQuery Studio code asset powered by Dataform that supports SQL, Python, and common data packages. The notebook provides the frontend where code is written, while an attached runtime provides the compute that executes cells. BigQuery stores and processes the table data, so the notebook depends on both the runtime and BigQuery to work. Creating the notebook requires project access, including roles such as BigQuery User and Colab Enterprise User. A new notebook is created and connected in this order:
{my_threshold} in WHERE x > {my_threshold}.Visualizing DataFrames means turning rows in a pandas DataFrame into charts inside the notebook. The kernel runs Python that selects columns and passes them to a plotting library, which renders the figure below the cell. Clear titles, axis labels, and consistent scales help connect the visual to the underlying columns. Common choices are line charts for change over time, bar charts for category comparison, histograms for distribution, box plots for spread and outliers, scatter plots for two-variable relationships, and heatmaps for table patterns.
| Library | Primary style | Choose when |
|---|---|---|
| Matplotlib | Low-level control of figures and axes | Chart needs custom layout or precise formatting |
| Seaborn | Statistical plots with clean defaults | Goal is distributions, correlations, or category comparisons |
| Altair | Declarative, interactive charts | Audience benefits from hovering, filtering, or zooming |
Scaling processing means choosing a Spark backend that matches control versus simplicity. Managed Service for Apache Spark offers a serverless model that provisions on demand and a cluster-based model where the analyst controls size and machine types. A Spark Connect session links a notebook to a serverless session through the Python connector, built from a session template with runtime version 2.3 or later and notebook type Spark Connect. DIRECT writes use the BigQuery Storage Write API to write directly to BigQuery, while INDIRECT writes first write to a Cloud Storage bucket and then to BigQuery. A conda environment isolates packages as its own kernel, a notebook schedule automates repeated runs, and deleting a schedule stops future runs but keeps past executions. |
Calculating metrics with SQL means grouping rows by product, store, region, or time to reveal patterns. A query reads rows, groups them, and returns counts by category, averages by group, and correlations between numeric features. Segmenting gives each segment its own row for comparison, while exploring distributions shows which categories appear most often. BigQuery Studio supports this work with a SQL editor, embedded Python notebooks, PySpark editor, asset version history, and Knowledge Catalog profiling. When a query runs, BigQuery builds an execution tree that breaks work into stages, moves intermediate data through a fast distributed shuffle, and writes final results to storage.
Finding data quality issues means protecting analysis from bad conclusions. Missing values appear as nulls and are found by counting nulls, outliers appear far above or below normal, and anomalies appear as unexpected breaks in trends. Cleaning removes or corrects problem points, and wrangling creates analysis-ready features such as one-hot or label encoding. For large data, this work uses distributed processing with BigQuery ML, BigQuery DataFrames, or Managed Service for Apache Spark. The Data Science Agent, a Gemini-powered assistant in the notebook, can then generate Python or SQL from prompts using CSV files or BigQuery tables selected with the table selector or @mention.
Visualizing data in Looker (opens in a new tab) means turning saved Explore queries into interactive dashboards that answer business questions. Data flows from an Explore query into a saved Look or tile, and from one or more tiles into a dashboard where viewers filter and explore. Dashboards combine charts, text, filters, and layout so one page can show the same question from different angles.
A Look is a saved Explore query plus its chart that can be reused later or added to dashboards. The flow moves from an Explore query to a saved Look, and then from the Look to one or more dashboard tiles. Saving a Look preserves both the query and the visualization, so teams reuse the same definition without rebuilding it. A user-defined dashboard is created and edited in the Looker interface and stored in a folder, while a LookML dashboard is defined in code in a .dashboard.lookml file and kept in version control. To view either type, a person needs View access for its folder and access to the models behind its tiles.
A blank user-defined dashboard is created from a folder where you have Manage Access, Edit access:
Dashboard tiles are the building blocks that display queries, Looks, text, or custom apps. The first tile takes the full page width, and later tiles are sized to one-third width and placed in rows underneath. Tiles can be moved by dragging, resized, renamed, or edited to change the visualization or query.
| Tile type | What it holds | Choose when |
|---|---|---|
| Query tile | Independent query that belongs to the dashboard | Tile must survive if source Look is deleted and avoid folder clutter |
| Look-linked tile | Query linked to a saved Look in same folder | One Look should feed many dashboards so all update together |
| Text tile | Heading or explanation with Text or Markdown | Page needs labels or guidance for viewers |
| Extension tile | Custom application inside the tile | Page needs interactive behavior beyond a chart |
| User-defined dashboards are rearranged in the interface, while LookML dashboards are updated by editing dashboard and element parameters in code. A LookML dashboard can be copied to a folder as a user-defined dashboard, and a user-defined dashboard can generate LookML for a LookML dashboard. Creators work in edit mode with Add, Filters, Settings, Quick layout, Style, Cancel, and Save, and they drag tiles by the six-dot handle. Text tiles add headings, tabs group related tiles, and themes change fonts and colors. Dashboards with slow rendering should be split into smaller dashboards because more tiles need more browser resources. |
Dashboard filters and cross-filters let one dashboard serve many questions. A creator adds a dashboard filter in edit mode, chooses which field it controls, and uses Tiles to Update to choose which tiles it applies to. A viewer selection then flows from the filter control to each connected tile, such as narrowing by date, region, or product. Cross-filtering is ad hoc filtering where a viewer clicks a data point in one tile and all other tiles filter to that value. Cross-filters cannot be saved, but they can be shared by sharing the URL. Tiles also support drilling to see granular detail, open Explore rows, follow links, or run data actions.
The Looker Scheduler sends instant or recurring deliveries from dashboards, Looks, and Explores to destinations inside and outside Looker. A schedule can run after a datagroup triggers and rebuilds relevant persistent derived tables (PDTs), so recipients get fresh data. Delivery depends on data access, because a user can only schedule models and data they can see. Built-in destinations are Email, Webhook, Amazon S3 bucket, and SFTP server. Dashboards deliver as PDF, visualization (PNG), or CSV ZIP, while Looks and Explores deliver as CSV, XLSX, JSON variants, Text, or HTML. Deliveries without schedule_without_limit permission are limited to 5,000 rows. Data-driven alerts watch a tile for change, require create_alerts permission plus tile access, and folder access is separate: View opens content while Manage Access, Edit changes content and sharing.
Exam tip: A query tile is independent and survives if its source Look is deleted, while a Look-linked tile stays connected and shows an error if its source Look is deleted.
Choosing between Looker and Looker Studio means matching governance, speed, and sharing needs. Looker is a governed enterprise business intelligence platform that defines metrics once in a central model. Looker Studio is a no-cost, self-service reporting tool that builds fast, flexible reports directly from data sources. In every Looker deployment, data remains in-database and is not copied to the Looker instance.
Looker is the right choice when the work needs governance for key metrics, robust permissions, sharing with scheduling and alerting, operational analytics, embedding and API integration, or custom applications. Looker can be customer-managed in Google Cloud, hosted in another cloud, or hosted on customer servers. Looker (Google Cloud core) offers the same features with deeper Google Cloud integration, including provisioning from the Google Cloud console. Looker Studio is the right choice for self-service visuals, flexible ad hoc reporting, access to more than 1,000 data sources, web embedding, one-off reports, or single-source datasets. A Looker Studio report is a multi-page asset with charts, controls, text, shapes, and images, using embedded sources editable by report editors or reusable sources shared across reports.
Looker connects as a governed modeling layer that queries live data without storing a copy. Data flows from the database to Looker when a user runs an Explore, and Looker generates SQL against the source. Direct connections include BigQuery, Spanner, Cloud SQL for MySQL, and Cloud SQL for PostgreSQL. Looker Studio connects as a lightweight layer that attaches directly through named connectors, so data flows from the source directly to the report. Using a governed Looker model inside Looker Studio lets one Looker Explore become a Studio data source, inheriting definitions and permissions. That path requires explore permission to connect and access_data plus clear_cache_refresh for viewers, with 12-hour default freshness, 5-minute query timeout, 5,000-row chart limit, 75,000-row export limit, and job label requestor:looker_studio on BigQuery queries.
Manipulating simple LookML parameters means editing settings that control what users see and how Looker queries the database. Every change alters the SQL that Looker generates, changing both the field picker and the rows in reports. A dimension is a groupable row-level attribute such as product name or created date, declared with dimension: field_name plus type and sql, often sql: ${TABLE}.column_name ;;. A measure aggregates many rows with functions such as COUNT, SUM, AVG, MIN, MAX, count_distinct, or percent_of_previous, often reusing a dimension like sql: ${amount} ;; with type: sum. A dimension group creates multiple time dimensions such as date, week, month, quarter, and year from one column.
| Field kind | What it describes | Main SQL effect |
|---|---|---|
| Dimension | Row-level attribute for grouping | Adds column to SELECT and GROUP BY, filters in WHERE |
| Measure | Aggregation such as count or sum | Adds aggregate to SELECT, filters in HAVING |
| Filter | Limit on rows or grouped values | Adds conditions to WHERE or HAVING without always adding a column |
An Explore provides the starting point for a query and serves as the FROM in SQL terms. Explores are declared in a model file with the explore parameter, which sets the connection and included views. The declaration explore: orders makes Orders queryable, and nested join blocks define how other views attach with sql_on, such as sql_on: ${orders.customer_id} = ${customers.id} ;;. Looker generates the LEFT JOIN only when selected fields require that view. Optimizing presentation uses label for friendly names, description for meaning, and group label for picker organization. value_format applies a one-time Excel-style string such as "$#,##0.00", while value_format_name applies a shared built-in or custom named_value_format such as usd. |
Defining and using machine learning models on Google Cloud means matching the data shape and team skills to the right training path. BigQuery ML (opens in a new tab) trains and predicts with SQL where large structured tables already live, while AutoML trains on labeled images, text, and other unstructured data without custom model code. Data flows from BigQuery tables directly to a BigQuery ML model and back to BigQuery tables, while data flows from labeled examples to an AutoML model that learns only from those examples.
BigQuery ML fits SQL workflows because training, evaluation, and prediction all run inside BigQuery with GoogleSQL. An analyst who can write SELECT can train without notebooks or deployment servers, and BigQuery handles scaling where data already lives. Choose BigQuery ML when labeled history exists in the warehouse and results need to flow back to tables for dashboards.
| Use case | Business question | Why BigQuery ML fits |
|---|---|---|
| Customer segmentation | Which customers behave similarly? | Clustering learns groups from frequency, spend, recency, and region |
| Churn prediction | Which customers are likely to leave? | Classification learns churn or no churn from usage history |
| Demand forecasting | What sales volume comes next? | Time-series and regression predict numbers without moving data |
AutoML fits labeling tasks where each image or text item needs a class or detected object. The model cannot understand label names alone, so labels such as door and door_with_knob look unrelated unless images show the difference. Choose AutoML when the team can supply labeled examples but does not want to write feature engineering or model-selection code. Provide many representative examples with different angles and resolutions, add explicit examples for similar labels, and remove classes with very few examples. Evaluation reviews precision, recall, and the confusion matrix on held-out data: low precision and recall points to too little data or inconsistent labels, while perfect scores can mean test data is too easy. Iteration follows review metrics, update data or setup, train a new model, and compare models. |
Using pretrained large language models from BigQuery means letting SQL call models hosted outside BigQuery. A Cloud resource connection authorizes BigQuery to send requests to Vertex AI, and a remote model resource points to a foundation model such as Gemini. Data flows from BigQuery tables to the remote endpoint for inference in Vertex AI, and results flow back into query results or tables. The connection definition is encrypted and stored in the BigQuery connection service, and BigQuery holds the trust boundary between the user and the external system.
Connection type controls the destination that traffic flows from BigQuery toward, including Amazon Simple Storage Service and Azure Blob Storage through BigQuery Omni, Apache Spark for Python procedures, Spanner and Cloud SQL and AlloyDB for federated queries, and Google Cloud resources for Vertex AI remote models and BigLake. No connection is required for Bigtable and Google Drive. Authentication for a Cloud resource connection uses a system service account that BigQuery creates automatically. The administrator copies the service account ID and grants it Vertex AI permission, and grants users permission to use the connection. Creation follows select the Cloud resource type, create the connection in a location, copy the service account ID, and reference the connection in CREATE MODEL. The connection and dataset should be in the same location, such as multi-region US.
A remote model registers a Vertex AI model as a BigQuery model without training data in BigQuery. The basic form is CREATE OR REPLACE MODEL PROJECT_ID.DATASET_ID.MODEL_NAME REMOTE WITH CONNECTION CONNECTION_PATH OPTIONS (ENDPOINT = 'ENDPOINT'). Use DEFAULT when a default connection exists, or the full path PROJECT_ID.REGION.CONNECTION_ID. The dataset location must match the connection location, and the Vertex AI model must be available in that location. Gemini, embedding, Claude, and Mistral models use a pretrained name such as gemini-2.0-flash, Llama models use an OpenAI-style path, and custom endpoints use a full URL plus INPUT and OUTPUT clauses. Generative AI functions then work with text in queries for generation, summarization, extraction, classification, and embeddings, while task-specific functions use Cloud AI APIs for translation, document processing, transcription, and vision.
A standard ML project moves in order from data collection to training to evaluation to prediction. Raw data flows into storage, clean tables flow into training, a trained model flows into evaluation, and only acceptable quality flows into prediction. BigQuery ML supports this lifecycle with SQL so training data does not move elsewhere. Cloud Storage archives original raw files as the durable record, BigQuery stores structured training-ready tables, and Dataflow reads raw records, applies cleansing, and writes clean rows to BigQuery. Keeping the raw copy separate from the prepared copy protects the project because tables can be rebuilt from the archive.
| Service | Primary role | Choose when |
|---|---|---|
| BigQuery | Prepared tables and in-database ML | Data is cleansed and needs SQL plus training |
| Dataflow | Processing and cleansing | Data needs filtering, mapping, or streaming transforms |
| Cloud Storage | Raw archival | Original backup or file must be preserved |
| Continuous collection keeps BigQuery fresh through Pub/Sub streaming, MySQL change capture, and Datastream movement through Dataflow templates. Centralized governance makes datasets reusable: Knowledge Catalog unifies data into lakes and zones with access control and quality, BigQuery sharing publishes listings and clean rooms, and Agent Platform Feature Store serves the same features for online and offline use. The reuse layer depends on the collection layer because only governed datasets can be safely shared. |
Exam tip: Keep raw files in Cloud Storage and training-ready tables in BigQuery; Dataflow is the pipeline that transforms the first into the second.
Executing SQL to create and evaluate models means using CREATE MODEL and evaluation functions instead of Python. Training data stays in BigQuery tables or views, and the trained model is stored in a dataset like a table or view. The workflow moves from training query to stored model to predictions and explanations:
OPTIONS such as MODEL_TYPE, and supply rows with AS SELECT.TRANSFORM logic.NUM_TRIALS.ML.PREDICT.project.dataset.model, sets MODEL_TYPE, and ends with the training query. Classification and regression use INPUT_LABEL_COLS, matrix factorization uses USER_COL, ITEM_COL, and RATING_COL, and time-series models use TIME_SERIES_TIMESTAMP_COL and TIME_SERIES_DATA_COL. Split options such as DATA_SPLIT_METHOD control rows reserved for evaluation. Internally trained models train entirely inside BigQuery and support dry runs, including linear and logistic regression, k-means, matrix factorization, principal component analysis (PCA), contribution analysis, and ARIMA_PLUS. Externally trained models train in Agent Platform with TensorFlow, XGBoost, or AutoML, remote models reference a deployed HTTPS endpoint, and imported models load Open Neural Network Exchange (ONNX) or TensorFlow files from Cloud Storage.
Linear regression, logistic regression, and k-means differ by question and label need. Linear regression predicts a numeric value such as house price and requires a real-valued numeric label that is not infinity or NaN. Logistic regression predicts a category such as spam or low, medium, or high value and requires a categorical label with up to 50 unique values. K-means clustering assigns groups such as customer segments, needs no label, and uses all input data. ML.EVALUATE takes a stored model and evaluation data and returns summary statistics, where accuracy, precision, and recall are higher-is-better and mean squared error is lower-is-better. ML.METRICS differs because it scores actual and predicted columns directly without a stored model.Inference with BigQuery ML models means applying a trained model to new data to generate predictions, forecasts, or anomaly flags. Batch inference scores many rows where data already lives, so data flows from BigQuery tables into the model and back to BigQuery tables. Teams can work through the console, bq tool, REST API, or Colab Enterprise notebooks. The batch job and tables must be in the same region. A typical batch workflow preserves order from preparation to delivery:
TimesFM, ARIMA_PLUS, and ARIMA_PLUS_XREG. Queries set horizon for future points and confidence level for intervals. Choose ARIMA_PLUS_XREG when external regressors matter, and TimesFM or ARIMA_PLUS when only history matters. Anomaly detection flags breaks from baseline: supervised detection with ML.PREDICT applies when labeled training examples exist, while unsupervised detection applies with no labels. TimesFM uses AI.DETECT_ANOMALIES for time series, while ARIMA_PLUS and ARIMA_PLUS_XREG use ML.DETECT_ANOMALIES. For independent rows, ML.DETECT_ANOMALIES uses k-means distance, autoencoder loss, or PCA loss. BigQuery sources must be no larger than 100 GB, and CSV sources need a header row, quoted strings, and limits of 10 GB per object and 100 GB total.Organization in Model Registry means keeping models, versions, metadata, and deployment history in one central place. A single registered model can hold multiple versions, each with its own version ID, files, and evaluation results. The registry connects stored metadata to organizing, evaluating, deploying to an endpoint for online inference, creating batch inferences, and viewing version details. Registration copies a BigQuery ML model's reference and metadata into the registry for versioning and deployment. The ordered flow is to create the model in BigQuery ML with SQL, choose which models to register, and then manage and deploy the registered model.
| Model type | Can register in Model Registry | Can deploy in Agent Platform |
|---|---|---|
| Standard BigQuery ML models | Yes | Yes, after registration to an endpoint |
| Remote models | No | No |
| Imported XGBoost, ARIMA_PLUS, and ARIMA_PLUS_XREG | Yes | No |
A model version alias is a mutable name that points to one specific version inside a single model. Applications fetch by alias instead of version ID, so the name stays stable while the version moves. The default alias is used when no version is specified, is assigned to the first version, and exactly one version must carry it at all times. Custom aliases such as staging and production label lifecycle stages, and moving an alias promotes a model. Reusing an alias removes it from the old version. Alias names must be unique by model, non-numerical, and match [a-z][a-z0-9-]{0,126}[a-z0-9]. Copying moves a version to another project or region as a new model or new version, deletion requires undeploying first and deleting the BigQuery ML model first, and a model monitor stays tied to one fixed version. |
Continue with this study guide: 2.3 Define, train, evaluate, and use ML models
INFORMATION_SCHEMA.JOBS for 6 months, and speeds repeated queries with time or integer partitioning, clustering, Smart Tuning materialized views, and BI Engine in-memory analysis.{my_threshold}.CREATE MODEL, evaluate with ML.EVALUATE, and predict with ML.PREDICT, where linear regression needs a numeric label, logistic regression needs a categorical label up to 50 values, and k-means needs no label.A query tile is an independent query that belongs to the dashboard and survives if its source Look is deleted, while a Look-linked tile stays linked to a saved Look and shows an error if that Look is deleted. A Look is a saved Explore query plus its chart that can be reused or added to dashboards.
Use Looker when you need governed enterprise business intelligence with metrics defined once in a central model, robust permissions, scheduling and alerting, operational analytics, and embedding and API integration. Use Looker Studio when you need a no-cost self-service reporting tool for fast flexible ad hoc or one-off reports directly from data sources, including access to more than 1,000 data sources and web embedding. In every Looker deployment, data remains in-database and is not copied to the Looker instance.
Partitioned tables divide a large table by time or integer ranges so queries that filter on the partition column skip unneeded partitions, and clustering further speeds retrieval on filtered columns. Materialized views store cached persistent results for frequently run aggregations or joins and support automatic query rewrite even when the query refers to the base table, with Smart Tuning materialized views always returning current data. BI Engine is the fast in-memory analysis service for low-latency dashboards and interactive exploration.
In BigQuery ML, linear regression requires a real-valued numeric label that is not infinity or NaN, logistic regression requires a categorical label with up to 50 unique values, and k-means clustering requires no label and uses all input data. Linear regression predicts a numeric value such as house price, logistic regression predicts a category such as spam or low, medium, or high value, and k-means assigns groups such as customer segments.
Last updated