Overview
Assignment can be set or retrieved directly in SQL. This is useful when doing analysis (querying directly fromexperimentation.assignments
or if wanting to implement an experiment directly in SQL.
Roles
A user must be assigned of the following application roles to execute any of the examples described on this page:admin
editor
scientist
Get assignments
To get assignments for a given subject, perform a select against theassignments
table:
Get or make assignments
Gets an assignment or makes one if it doesn’t exist:Examples
Manually get or create a single assignment
This example gets an assignment for user with IDuser_0001
in experiment home-cta
.
Get an assignment for each user_id
value in a table
Split test different Cortex models
This example demonstrates how you can run a SQL query that produces an output from Cortex’sCOMPLETE
method, testing different model versions for various customers. Winning Variant is used to determine which model should be used per customer ID. Later, we would tie business KPIs (i.e., revenue, churn, returns, etc) back to each variant to see which model should be deployed.
We have the following declared for this example:
- A 50/50 test between control (
llama3.2-1b
model) and treatment (claude-3-5-sonnet
) - The Winning Variant experiment ID is
cortex-test
- The ID of your user in this example is
abc123