CertSafari
    Snowflake SnowPro Advanced: Data Analyst (DAA-C01)· Lessons

    Domain 1 · Lesson 7/19

    Geospatial, Cortex AI and ML functions in Snowflake

    Given a scenario, use Snowflake functions.

    9 min read
    2.43% of exam
    6 sources
    Published 20 Oct 2026
    Docs as of 4 Oct 2026

    What you will be able to do

    • Build GEOGRAPHY or GEOMETRY values and measure distance, containment and intersection with ST_ functions
    • Choose the Cortex AI function for a text task and estimate what drives its token cost
    • Match a business question to Forecasting, Anomaly Detection, Classification or Top Insights

    1.Spatial values and ST_ functions

    Snowflake stores locations and shapes in two data types, GEOGRAPHY and GEOMETRY. The geospatial functions, most of them prefixed ST_, build those values, measure them, and test how they relate to each other. The two types answer distance questions differently, and a scenario often hinges on which one is in use. For GEOGRAPHY, ST_DISTANCE returns the great-circle distance in meters. For GEOMETRY, it returns the Euclidean distance in whatever units the coordinates were defined in. It raises an error if two GEOMETRY inputs have different SRIDs.

    Distance between two GEOGRAPHY points one degree apart on the equator (about 111 km)sql
    WITH d AS
      ( ST_DISTANCE(ST_MAKEPOINT(0, 0), ST_MAKEPOINT(1, 0)) )
    SELECT d / 1000 AS kilometers, d / 1609 AS miles;

    Some functions work with only one of the two types, so pick the constructor that matches the type you need. ST_MAKEPOINT builds a GEOGRAPHY point, and ST_MAKEGEOMPOINT builds a GEOMETRY point. To parse stored text or binary, use TO_GEOGRAPHY or ST_GEOGRAPHYFROMWKT. The TRY_ variants work the same way when the source data may be malformed. Once you have values, the relationship functions answer the usual business questions.

    Spatial question to function
    QuestionFunctionType support
    Build a point from coordinatesST_MAKEPOINT / ST_MAKEGEOMPOINTGEOGRAPHY / GEOMETRY
    Parse WKT text into a shapeST_GEOGRAPHYFROMWKT, TO_GEOGRAPHYGEOGRAPHY
    How far apart are two shapes?ST_DISTANCEBoth
    Are they within a given distance?ST_DWITHINGEOGRAPHY only
    Does one shape contain the other?ST_CONTAINS, ST_WITHIN, ST_COVERSBoth
    Do two shapes overlap at all?ST_INTERSECTSBoth
    Size of a polygon or lineST_AREA, ST_LENGTH, ST_PERIMETERBoth
    Bucket points into hexagonal cellsH3_POINT_TO_CELLGEOGRAPHY only

    Most ST_ functions are scalar and return one value per row. ST_COLLECT, ST_UNION_AGG and ST_INTERSECTION_AGG also have aggregate forms, which combine the shapes from many rows into a single value.

    Checkpoint 1 of 5· Check yourself

    A table holds customer and store locations as GEOGRAPHY points. You want a TRUE/FALSE flag for whether a store lies within 500 meters of a customer. Which function fits?

    Sources12

    2.Cortex AI functions on text columns

    Cortex AI functions run large language models from inside a SQL statement, so you can score, translate or summarize a text column without moving the data out of Snowflake. To call them, a role needs the USE AI FUNCTIONS account-level privilege and either the CORTEX_USER or the AI_FUNCTIONS_USER database role. Most of them work like scalar functions, returning one result per row. AI_AGG and AI_SUMMARIZE_AGG are aggregates: they read many rows and return one result, and they aren't limited by the model's context window.

    Text task to Cortex AI function
    Task on a text columnFunction
    Score how positive or negative each review isAI_SENTIMENT
    Shorten each documentAI_SUMMARIZE
    One summary across all ticketsAI_SUMMARIZE_AGG
    Translate each messageAI_TRANSLATE
    Assign each row one of your own labelsAI_CLASSIFY
    Pull named fields out of text or filesAI_EXTRACT
    Keep only rows that meet a plain-language conditionAI_FILTER
    Mask PIIAI_REDACT
    Any other generative promptAI_COMPLETE

    AI_FILTER returns TRUE or FALSE, so you can use it in a WHERE clause or a JOIN … ON condition. AI_COMPLETE takes the model name as its first argument, and each model in a query shows up on its own row in the usage history.

    Two AI_COMPLETE calls with different models, billed per modelsql
    SELECT AI_COMPLETE('mistral-7b', 'Is a hot dog a sandwich'), AI_COMPLETE('mistral-large', 'Is a hot dog a sandwich');

    Cost depends on tokens, and a token is roughly four characters of text. Functions that generate text, such as AI_COMPLETE, AI_SUMMARIZE and AI_TRANSLATE, bill both input and output tokens. The task-specific functions also add a hidden prompt to your text, so you're billed for more tokens than you supplied. You also keep paying for the warehouse while the query runs. A larger warehouse doesn't make these calls faster, so Snowflake recommends nothing larger than MEDIUM. To check a prompt's size before a large run, use AI_COUNT_TOKENS. To see where credits went, query CORTEX_FUNCTIONS_USAGE_HISTORY in ACCOUNT_USAGE.

    Checkpoint 2 of 5· Check yourself

    A support team wants a single summary drawn from tens of thousands of ticket rows, and the combined text is far larger than a model's context window. Which function suits this?

    Sources34

    3.Choosing an ML function for the question

    Snowflake's ML functions train a model on your data and return predictions or insights. Snowflake picks a suitable type of model for each feature, so you don't need to be a machine-learning expert. The deciding factor is the question being asked. Two of the features work on time series and learn how a metric changes over time. The other two don't need time-series data.

    Business question to ML function
    QuestionML functionNeeds time-series data
    What will next quarter's sales be?ForecastingYes
    Which daily values look unusual?Anomaly DetectionYes
    Which category will this customer fall into?ClassificationNo
    Which segments drove the change in the metric?Top InsightsNo

    Forecasting projects future metric values from past trends. Anomaly Detection flags values that differ from what the model expects. Classification sorts rows into two or more classes using their most predictive features. Top Insights finds the dimensions and values that affect a metric in surprising ways, which makes it the answer to 'why did revenue drop in March?'

    ML Classification and AI_CLASSIFY both produce labels, but they work differently. Classification trains a model on the features in your rows. AI_CLASSIFY asks a language model to put text or images into categories you name. ML functions cost both storage and compute: storage for the model instances created during training, and compute that grows with the amount of data used to train and predict.

    Checkpoint 3 of 5· Exam question

    An analyst queries a table orders (customer_id, order_id, order_ts, amount) and needs exactly one row per customer: the most recent order. The team wants a single query block with no subquery or CTE. Which change achieves this?

    Checkpoint 4 of 5· Exam question

    A finance dashboard reads table payments where some rows have a NULL amount because the charge is still pending. The business wants the average ticket to treat pending payments as zero, and also a count of payments that already have a recorded amount. Select TWO expressions that together meet both requirements.(Select 2)

    0 of 2 selected

    Checkpoint 5 of 5· Exam question

    A table events has a VARIANT column payload whose items key holds an array of objects, each with sku and qty. An analyst must return one output row per array element together with the parent event_id. Which approach does this?

    Sources5

    Sources

    (6)

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 1.
      “Geospatial functions operate on GEOGRAPHY and GEOMETRY and convert GEOGRAPHY and GEOMETRY values to and from other representations (such as VARCHAR).”
      ↩︎ Spatial values and ST_ functions
    2. 2.
      “Returns the minimum great circle distance between two GEOGRAPHY or the minimum Euclidean distance between two GEOMETRY objects.”
      ↩︎ Spatial values and ST_ functions
      “For GEOGRAPHY input values, the distance is in meters.”
      ↩︎ Spatial values and ST_ functions
      “For GEOMETRY input values, the distance is computed with the same units used to define the input coordinates.”
      ↩︎ Exam trap 1
    3. 3.
      “your role needs the USE AI FUNCTIONS account-level privilege and one of the CORTEX_USER or AI_FUNCTIONS_USER database roles.”
      ↩︎ Cortex AI functions on text columns
      “AI_SUMMARIZE_AGG: Aggregates a text column and returns a summary across multiple rows.”
      ↩︎ Cortex AI functions on text columns
      “Cortex AI Functions are optimized for throughput.”
      ↩︎ Cortex AI functions on text columns
      “Aggregates a text column and returns a summary across multiple rows. This function isn’t subject to context window limitations.”
      ↩︎ Checkpoint
    4. 4.
      “Snowflake Cortex AI functions incur compute cost based on the number of tokens processed.”
      ↩︎ Cortex AI functions on text columns
      “As a result, the billed token count is higher than the number of tokens in the text you provide.”
      ↩︎ Cortex AI functions on text columns
      “Snowflake recommends using a warehouse size no larger than MEDIUM when calling Snowflake Cortex AI Functions.”
      ↩︎ Cortex AI functions on text columns
      “Using a larger warehouse than necessary does not increase performance, but can result in unnecessary costs.”
      ↩︎ Exam trap 2
      “AI_CLASSIFY labels, descriptions, and examples are counted as input tokens for each record processed, not just once for each AI_CLASSIFY call.”
      ↩︎ Prediction
    5. 5.
      “Forecasting predicts future metric values from past trends in time-series data.”
      ↩︎ Choosing an ML function for the question
      “Anomaly Detection flags metric values that differ from typical expectations.”
      ↩︎ Choosing an ML function for the question
      “Classification sort rows into two or more classes based on their most predictive features.”
      ↩︎ Choosing an ML function for the question
      “The storage costs you incur reflect storage of the ML model instances created during the training step.”
      ↩︎ Choosing an ML function for the question
      “Top Insights helps you find dimensions and values that affect the metric in surprising ways.”
      ↩︎ Exam trap 3

    Also cited

    Ready to test yourself?

    Practise the 8 questions on this subdomain.

    Spotted a mistake, or was something unclear? Tell us.