Snowflake Cortex and Gen AI cheat sheet
COMPLETE, Analyst, Search, embeddings, and token cost for SnowPro Specialty Gen AI.
Placement
complete / classify in an incremental model- Materialize the label once. Dashboard refresh is a token bill and a non-deterministic metric.
version the prompt + model- Store prompt_id / model_name next to the output so you can rerun safely.
never COMPLETE in a BI explore- Looker/Tableau calling Cortex per tile is how FinOps pages you.
Cortex functions
SNOWFLAKE.CORTEX.COMPLETE(model, prompt)- Text generation / classification. Batch on changed rows only.
SNOWFLAKE.CORTEX.SENTIMENT / SUMMARIZE / TRANSLATE- Task-specific helpers. Still cost tokens — incrementalize.
SNOWFLAKE.CORTEX.EMBED_TEXT_* (model, text)- Store vectors with a model version. A new model invalidates the index.
Analyst vs Search
Cortex Analyst- Answers over a semantic model you define. Wrong grain = invented revenue.
Cortex Search- Retrieval over indexed text/embeddings. Use for tickets and docs, not SUM(amount).
RAG vs text-to-SQL- RAG retrieves documents. Text-to-SQL needs a semantic layer or it hallucinates joins.
Cost and safety
tokens times rows- Filter on updated_at. Cache embeddings. Do not re-embed unchanged text nightly.
masking still applies- Redact PII before COMPLETE. An LLM call is another consumer of the column.
Document AI- Extract to bronze, sample a human review, then typed silver. Not an untested gold column.
Interview one-liners
Dashboard wants COMPLETE?- No. ELT column, versioned prompt, BI reads the label.
Analyst doubled revenue- Check the semantic model grain and joins — same as a fan-out SQL bug.
Upgrade embedding model- Rebuild the vector index. Do not mix two models in one search service.
From DataLane — tutorials at/blog, practice SQL live in theplayground.