Step 3: Domain Context
Why Domain Context Before Entities?
3a: Domain Task Instructions
---
type: task-instructions
domain: "*"
tasks: "text-to-sql"
---
# SQL Generation Rules
## Always Apply
- Always exclude test accounts: filter `is_test_account = false` unless the user explicitly asks about test accounts
- Always exclude deleted accounts: filter `is_deleted = false` unless explicitly told otherwise
- Use `arr` as the revenue metric. Never use `total_paid` — it includes one-time professional services fees that inflate revenue
## Time and Fiscal Year
- The fiscal year starts February 1. Q1 = Feb–Apr, Q2 = May–Jul, Q3 = Aug–Oct, Q4 = Nov–Jan
- When filtering by quarter, use the fiscal definition above — not calendar quarters
- For cohort analysis, use `first_paid_at` as the customer start date, not the account creation date
## Query Patterns
- When asked about revenue trends, default to monthly granularity unless the user specifies otherwise
- Plan type values in the data are lowercase: 'starter', 'growth', 'enterprise' — filter accordingly
- For churn calculations, use the `churn_rate` metric on the `customer` entity directly — do not derive churn from subscription cancellation counts3b: Clarification Policy
3c: Output Format
Key Point
Last updated