|
| 1 | +--- |
| 2 | +title: "Lightdash YAML" |
| 3 | +sidebarTitle: Lightdash YAML |
| 4 | +description: "Use Lightdash without a dbt project by defining your semantic layer directly in YAML files." |
| 5 | +--- |
| 6 | + |
| 7 | +<Frame> |
| 8 | + <iframe width="100%" height="420" src="https://www.loom.com/embed/d7cab1a72e2a40f088998c4fb387e185" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen /> |
| 9 | +</Frame> |
| 10 | + |
| 11 | +## What is Lightdash YAML? |
| 12 | + |
| 13 | +Lightdash YAML allows you to use Lightdash without an existing dbt project. Instead of defining your semantic layer within dbt model YAML files, you define it directly in standalone YAML files that point to tables in your data warehouse. |
| 14 | + |
| 15 | +This approach lets you leverage Lightdash's powerful features without needing to adopt dbt first. |
| 16 | + |
| 17 | +## Why use Lightdash YAML? |
| 18 | + |
| 19 | +Lightdash has always operated with dbt at its core. Traditionally, customers have active dbt projects, and Lightdash builds its semantic layer within that dbt context. |
| 20 | + |
| 21 | +However, not every team uses dbt. If you're interested in Lightdash features like: |
| 22 | + |
| 23 | +- **AI agents** that can answer questions about your data |
| 24 | +- **A semantic layer** with consistent metric definitions |
| 25 | +- **Self-service analytics** for your business users |
| 26 | + |
| 27 | +...but you don't have dbt set up, Lightdash YAML provides a path forward. You can define your semantic layer directly and start using Lightdash immediately, without the overhead of adopting dbt. |
| 28 | + |
| 29 | +## dbt vs Lightdash YAML: which should you use? |
| 30 | + |
| 31 | +| Scenario | Recommendation | |
| 32 | +|----------|----------------| |
| 33 | +| You already have a dbt project | Use the standard [dbt integration](/references/integrations/dbt-projects) | |
| 34 | +| You're planning to adopt dbt soon | Consider setting up dbt first, then connecting to Lightdash | |
| 35 | +| You don't use dbt and want to try Lightdash quickly | Use Lightdash YAML | |
| 36 | +| You want AI agents or semantic layer features without dbt | Use Lightdash YAML | |
| 37 | +| You have tables in your warehouse ready to explore | Use Lightdash YAML | |
| 38 | + |
| 39 | +The good news: if you start with Lightdash YAML and later decide to adopt dbt, the YAML formats are compatible, so migration is straightforward. |
| 40 | + |
| 41 | +## Getting started with Lightdash YAML |
| 42 | + |
| 43 | +### Prerequisites |
| 44 | + |
| 45 | +Before you begin, make sure you have: |
| 46 | + |
| 47 | +1. The [Lightdash CLI installed](/guides/cli/how-to-install-the-lightdash-cli) |
| 48 | +2. [Authenticated with Lightdash](/guides/cli/cli-authentication) |
| 49 | +3. Credentials for your data warehouse (e.g., Snowflake) |
| 50 | +4. Tables in your warehouse that you want to explore |
| 51 | + |
| 52 | +### Step 1: Create your project configuration |
| 53 | + |
| 54 | +At the root of your project, create a `lightdash.config.yml` file to specify your warehouse type: |
| 55 | + |
| 56 | +```yaml |
| 57 | +warehouse: |
| 58 | + type: snowflake |
| 59 | +``` |
| 60 | +
|
| 61 | +Replace `snowflake` with your warehouse type (e.g., `bigquery`, `databricks`, `redshift`, `postgres`, `trino`). |
| 62 | + |
| 63 | +### Step 2: Create your first model |
| 64 | + |
| 65 | +Lightdash YAML uses the same syntax as the [Lightdash semantic layer in dbt](/references/integrations/dbt-projects), but instead of nesting everything under `meta` tags, all configuration is at the top level of the file. |
| 66 | + |
| 67 | +Create a directory structure for your Lightdash project: |
| 68 | + |
| 69 | +```bash |
| 70 | +mkdir -p lightdash/models |
| 71 | +``` |
| 72 | + |
| 73 | +Create a YAML file for your first model. For example, `./lightdash/models/users.yml`: |
| 74 | + |
| 75 | +```yaml |
| 76 | +# Metadata |
| 77 | +type: model |
| 78 | +name: users |
| 79 | +
|
| 80 | +# Table definition |
| 81 | +sql_from: 'DB.SCHEMA.USERS' |
| 82 | +
|
| 83 | +# Metric definitions |
| 84 | +# For more configuration see: https://docs.lightdash.com/references/metrics |
| 85 | +metrics: |
| 86 | + user_count: |
| 87 | + type: count_distinct |
| 88 | + sql: ${TABLE}.USER_ID |
| 89 | + description: Total unique users |
| 90 | +
|
| 91 | +# Dimension definitions |
| 92 | +# For more configuration see: https://docs.lightdash.com/references/dimensions |
| 93 | +dimensions: |
| 94 | + - name: subscription_type |
| 95 | + sql: ${TABLE}.SUBSCRIPTION |
| 96 | + type: string |
| 97 | +
|
| 98 | + - name: signed_up_at |
| 99 | + sql: ${TABLE}.SIGNED_UP |
| 100 | + type: date |
| 101 | + time_intervals: |
| 102 | + - DAY |
| 103 | + - WEEK |
| 104 | + - MONTH |
| 105 | +``` |
| 106 | + |
| 107 | +Update the configuration: |
| 108 | + |
| 109 | +- Set `sql_from` to the fully qualified name of your table (e.g., `DATABASE.SCHEMA.TABLE`) |
| 110 | +- Update the dimensions to match the columns in your table |
| 111 | +- Add metrics that make sense for your data |
| 112 | + |
| 113 | +### Step 3: Validate your YAML |
| 114 | + |
| 115 | +Check your YAML files for errors by running: |
| 116 | + |
| 117 | +```bash |
| 118 | +lightdash lint |
| 119 | +``` |
| 120 | + |
| 121 | +This command validates your configuration and reports any issues before you deploy. |
| 122 | + |
| 123 | +### Step 4: Deploy your project |
| 124 | + |
| 125 | +Create your Lightdash project by deploying with the CLI: |
| 126 | + |
| 127 | +```bash |
| 128 | +lightdash deploy --create --no-warehouse-credentials |
| 129 | +``` |
| 130 | + |
| 131 | +The `--no-warehouse-credentials` flag tells Lightdash that you're deploying without warehouse credentials embedded in the CLI. After deploying, you'll need to configure your warehouse connection in the Lightdash UI: |
| 132 | + |
| 133 | +1. Go to **Settings** (gear icon in the top right) |
| 134 | +2. Under **Current project**, click **Connection settings** |
| 135 | +3. Configure your **Warehouse connection** with your database credentials |
| 136 | + |
| 137 | +<Frame> |
| 138 | +  |
| 139 | +</Frame> |
| 140 | + |
| 141 | +For detailed instructions on configuring your warehouse connection, see [Connect to a warehouse](/get-started/setup-lightdash/connect-project#1-connect-to-a-warehouse). |
| 142 | + |
| 143 | +### Step 5: Update your project |
| 144 | + |
| 145 | +After your initial deployment, you can edit your `.yml` files and redeploy changes: |
| 146 | + |
| 147 | +```bash |
| 148 | +lightdash deploy --no-warehouse-credentials |
| 149 | +``` |
| 150 | + |
| 151 | +## Developing with AI copilots |
| 152 | + |
| 153 | +If you're developing with Cursor, Claude Code, Kilo Code, or another AI copilot, you can speed up your workflow significantly. |
| 154 | + |
| 155 | +### Recommended setup |
| 156 | + |
| 157 | +1. **Provide the schema reference:** Give your copilot this link to the Lightdash YAML format specification: |
| 158 | + ``` |
| 159 | + https://raw.githubusercontent.com/lightdash/lightdash/refs/heads/main/packages/common/src/schemas/json/model-as-code-1.0.json |
| 160 | + ``` |
| 161 | + |
| 162 | +2. **Use validation:** Prompt your copilot to always run `lightdash lint` after making any changes to catch errors early. |
| 163 | + |
| 164 | +3. **Share your warehouse schema:** Give your copilot access to your warehouse schema. This makes it very fast to generate YAML files that match your actual table structures. |
| 165 | + |
| 166 | +<Tip> |
| 167 | +With access to your warehouse schema, AI copilots can auto-generate dimension and metric definitions for entire tables in seconds. |
| 168 | +</Tip> |
| 169 | + |
| 170 | +## Next steps |
| 171 | + |
| 172 | +Once you've deployed your Lightdash YAML project: |
| 173 | + |
| 174 | +- [Explore your data](/get-started/exploring-data/using-explores) in the Lightdash UI |
| 175 | +- [Create metrics](/get-started/develop-in-lightdash/how-to-create-metrics) to define your key business calculations |
| 176 | +- [Set up AI agents](/guides/ai-agents) to enable natural language queries |
| 177 | +- Learn about the [semantic layer reference](/references/metrics) for advanced configuration options |
0 commit comments