← All guides

GUIDES · SNOWFLAKE · DATABRICKS

Train a model from a Snowflake or Databricks table, and fill new rows with its answers

If the rows your team categorizes already live in Snowflake or Databricks, you don't need to export a file. Connect the warehouse once, and StayCharted reads the tables you list. A model trains on the rows that already have an answer. It then fills new rows, and every answer, with its confidence and a needs-review flag, lands in one results table in your warehouse. Join it to your own table on the row's ID, in your own SQL. StayCharted only reads the tables you list. The one thing it writes is its results table, in a schema you name for it. It never changes a table of yours.

By StayCharted ·

Before you start

  • An Essentials or Business workspace. The Owner connects the warehouse; Builders choose a listed table to train or fill from.
  • Snowflake: a role that can create a user and a role and grant on the tables, such as ACCOUNTADMIN, and a virtual warehouse for StayCharted's queries.
  • Databricks: a workspace with Unity Catalog, a SQL warehouse (serverless or pro), and permission to create a service principal and grant on the catalogs.
  • The queries run on your compute, so Snowflake or Databricks bills them as usual.

Step 1. Connect the warehouse

In StayCharted, open Settings → Warehouses and choose Snowflake or Databricks.

Snowflake Databricks
Where Your account identifier, as in your account URL (orgname-accountname) Your workspace URL
Compute The virtual warehouse StayCharted's queries run on The SQL warehouse ID, from its Connection details tab
Sign-in A service user that signs in with a key pair StayCharted makes. No password. A service principal: its application ID and an OAuth secret you make for it
Tables StayCharted may read One per line, as DATABASE.SCHEMA.TABLE. Views work too. One per line, as catalog.schema.table
Results A schema for StayCharted's results table, such as ANALYTICS.STAYCHARTED A schema, such as main.staycharted

Press Connect and show the grant SQL.

Step 2. Run the grant SQL

StayCharted shows the SQL that gives it exactly what you listed, and nothing else. Copy it and run it in your warehouse.

Snowflake (a Snowsight worksheet, as ACCOUNTADMIN or a role that can create users and roles):

  • creates the results schema if it isn't there;
  • creates a role and a service user (TYPE = SERVICE) for StayCharted, and sets the public half of the key StayCharted made. The private key stays in StayCharted, encrypted, and is never shown;
  • grants the role to SYSADMIN, as Snowflake recommends for custom roles, so your admins can read the results table;
  • grants USAGE on the virtual warehouse, the databases and the schemas, SELECT on the tables you listed, and CREATE TABLE in the results schema.

Databricks (the SQL editor, as an admin of these catalogs):

  • creates the results schema if it isn't there;
  • grants USE CATALOG and USE SCHEMA, SELECT on the tables you listed, and CREATE TABLE in the results schema, to the service principal.

Also give the service principal Can use on the SQL warehouse, from the warehouse's Permissions button.

Step 3. Test

Press Test. StayCharted signs in, reads the columns of each table you listed, and creates its results table. Each line says what worked, or the warehouse's own words when something didn't, such as a missing grant.

Step 4. Train a model from a table

Start a new model and choose Or read the rows from a Snowflake or Databricks table. Pick the table, tick the columns the model should read, and choose the column with the answers your team gave. StayCharted shows the table's columns and a few rows first.

Rows with no answer are left out. The rows become the model's training file, exactly as an uploaded spreadsheet would. From there it's the usual steps: check the data, train, and read the report on rows the model never saw.

Step 5. Fill new rows from a table

On the model's Use tab, under Fill a spreadsheet, choose From a warehouse table.

  1. Pick the table, and the column that identifies each row (its ID).
  2. Leave Only rows this model hasn't answered yet ticked. StayCharted then reads only rows with no answer from this model in the results table, so a weekly fill picks up only what was added since.
  3. Press Read the rows, then Run and fill in categories.

The model reads the same columns it was trained on, matched by name. If the table names them differently, StayCharted asks which column holds each. One fill reads up to your plan's rows per file to fill; when a table has more, the next fill picks up the rest.

When the fill finishes, the answers are in your results table, and the completed file is in StayCharted too. Answers below your review cutoff are flagged NEEDS_REVIEW and wait in the Review Queue for a person.

Step 6. Use the answers in your own SQL

The results table has one row per row answered and model:

Column What it holds
SOURCE_TABLE The table the row came from
SOURCE_KEY The row's ID, as text
CATEGORY The model's answer
CONFIDENCE From 0 to 1
NEEDS_REVIEW True when the answer was below your review cutoff, or blank
MODEL_ID, MODEL_NAME, MODEL_VERSION Which model, and which of its training runs, answered
FILL_ID, FILLED_AT Which fill wrote it, and when

A row answered again is updated in place. The model's Training files tab shows the exact SQL to join its answers back to your table. In Snowflake it looks like this:

Show SQL example
SELECT t.*, r.CATEGORY, r.CONFIDENCE, r.NEEDS_REVIEW
FROM ANALYTICS.SUPPORT.TICKETS t
LEFT JOIN ANALYTICS.STAYCHARTED.STAYCHARTED_RESULTS r
  ON r.SOURCE_KEY = CAST(t.TICKET_ID AS VARCHAR)
 AND r.SOURCE_TABLE = 'ANALYTICS.SUPPORT.TICKETS'
 AND r.MODEL_ID = '<your model ID>';

To let another role or group read the results, grant SELECT on the results table to it.

Common questions

Does StayCharted change my tables?

No. It only reads the tables you list. The one table it writes is its results table, in the schema you named for it.

Does my data leave Snowflake or Databricks?

The rows a model trains on and the rows it fills are read into StayCharted to be answered, the same as an uploaded file. They're kept in your organization's own database area, used only for your models, and deleted on the schedule on our security page.

Security and retention

Who pays for the queries?

They run on the virtual warehouse or SQL warehouse you chose, so your Snowflake or Databricks account bills them as usual. Training and fills count toward your StayCharted plan as a file would.

Do I need a password or a personal access token?

No. Snowflake uses a key pair that StayCharted makes; you set only the public half on the service user. Databricks uses a service principal with an OAuth secret. Both are kept encrypted and never shown again.

Our account only allows known IP addresses. Can we still connect?

Yes, once StayCharted's addresses are on your allow list. Contact us for them.

Which plans?

Essentials and Business.

Put it into practice

Text classification in Snowflake and Databricks →

Connect your object storage →

Security and your data →

Compare plans →

Snowflake is a trademark of Snowflake Inc. Databricks is a trademark of Databricks, Inc. StayCharted is not affiliated with either.