Malloy Documentation
search

The Malloy VS Code Extension is the primary authoring environment for Malloy models. It includes schema browsing, query execution, language auto-complete, documentation, and result visualizations.


Installation

  1. Download Visual Studio Code: If you don't already have it, download Visual Studio Code

  2. Open the Extensions panel: Press Cmd+Shift+X (Mac) or Ctrl+Shift+X (Windows/Linux). Or open the Command Palette (Cmd+Shift+P / Ctrl+Shift+P) and type "Extensions: Install Extensions"

  3. Install Malloy: Search for "Malloy" and click Install

    Or install directly from the VS Code Marketplace.

  4. Try the samples: Clone the malloy-samples repository:

    Option A: In VS Code, use Clone Git Repository from the Start screen and enter:

    https://github.com/malloydata/malloy-samples.git

    Option B: From the command line:

    git clone https://github.com/malloydata/malloy-samples.git
    cd malloy-samples
    code .

    DuckDB is built into the extension, so you can run queries immediately—try opening any .malloy file in the faa or ecommerce folders.


VS Code Web (github.dev)

The Malloy Extension also works in VS Code Web environments like github.dev. Press . on any GitHub repository page to open it in the browser-based editor, then install the Malloy extension.

Limitation: VS Code Web only supports DuckDB with local files (CSV, JSON, Parquet). For BigQuery, Snowflake, or PostgreSQL, use VS Code Desktop.


Configuring Connections

There are two ways to configure database connections:

  1. malloy-config.json (recommended) — a project-level config file checked into source control

  2. VS Code Settings — user-level configuration via the Connections sidebar

When both exist, config file connections take priority. Settings connections are used as a fallback for any connection names not defined in the config file. For example, if malloy-config.json defines a duckdb connection but not bigquery, the config file's duckdb is used while bigquery falls through to VS Code settings.

Connections Sidebar

The Malloy Connections sidebar shows the effective connections for the file you are currently editing, grouped by source:

  • Config — Connections from the malloy-config.json that applies to the active file. These are read-only in the editor; click the file icon on the group header to open the JSON file for editing.

  • Settings — User-defined connections from VS Code settings. Editable through the connection editor. If a settings connection has the same name as a config connection, it appears as "(shadowed)" since the config version takes priority.

  • Defaults — One entry per supported database type, using built-in defaults. Click to create a new settings connection from the default.

The sidebar updates automatically as you switch between files, so it always reflects the connections that would be used if you ran a query from the current file. Click any connection to open the connection editor, or use the + button to create a new connection.

Project Configuration: malloy-config.json

Place a malloy-config.json file in your project directory. The extension finds the config that applies to the current file by walking up from the file's directory toward the workspace root. It uses the first malloy-config.json it encounters. This means you can place a config file at the workspace root for project-wide connections, or in a subdirectory to override connections for files in that subtree. In multi-root workspaces, each workspace root has its own independent config search.

The extension also reads persistence manifests from the config's manifestPath directory. When the builder (malloy-cli build) writes a manifest, VS Code picks it up on the next compile — no restart needed.

Using with malloy-cli build: Both tools need to share the same config file so they read and write the same manifest. There are two ways to set this up:

  • Global config (simplest): Point the malloy.globalConfigDirectory setting at ~/.config/malloy (or your platform's config directory). The CLI uses this location by default — no flags needed. Both tools share the manifest automatically.

  • Project config: Put malloy-config.json at your project root. The extension finds it automatically. Pass --config . to the CLI. Both tools share the project-local manifest.

See Configuration for the full config file format, connection type properties, manifest path, setup SQL, and environment variables.

VS Code Settings

You can also configure connections through the Connections sidebar or the command palette:

  1. Open Command Palette: Cmd+Shift+P (Mac) or Ctrl+Shift+P (Windows/Linux)

  2. Type: Malloy: Edit Connections

  3. Click Add Connection and select your database type

  4. Fill in the connection details

Sensitive values (passwords, tokens) are stored securely in your system keychain.

Connection Editor

The connection editor lets you view and manage individual connections:

  • Test — Verify the connection works with the current settings

  • Duplicate — Create a copy of an existing connection

  • Delete — Remove a settings connection

Config file connections open in a read-only view. You can still test them, but edit the JSON file directly to change settings.

Connection Settings

Setting Description Default
malloy.globalConfigDirectory Directory containing a global malloy-config.json, used as a fallback when no workspace config file exists (e.g. ~/.config/malloy) ""
malloy.projectConnectionsOnly Only use workspace config file connections — hides global config, settings, and defaults false

Database-Specific Setup

DuckDB

DuckDB runs locally with zero configuration. It reads Parquet, CSV, and JSON files.

// Local files (relative to .malloy file)
source: flights is duckdb.table('data/flights.parquet')
source: users is duckdb.table('../users.csv')

// URLs
source: remote_data is duckdb.table('https://example.com/data.parquet')

MotherDuck

Set your token as an environment variable before launching VS Code:

export MOTHERDUCK_TOKEN=your_token_here

Or configure via Malloy: Edit Connections with databasePath set to md:.

BigQuery

OAuth (recommended for development):

gcloud auth login --update-adc
gcloud config set project my-project-id --installation

Then add a BigQuery connection via Malloy: Edit Connections. Leave the service account field empty to use gcloud credentials.

Service account:

In Malloy: Edit Connections, click "Pick file" to select your service account JSON key.

Snowflake

Both password and RSA key authentication are supported via Malloy: Edit Connections.

You can also use Snowflake's connections.toml file:

Location: ~/.snowflake/connections.toml

[default]
account = "myorg-myaccount"
user = "analyst"
password = "your_password"
warehouse = "compute_wh"
database = "analytics"
schema = "public"

PostgreSQL

Add a PostgreSQL connection via Malloy: Edit Connections. Enter host, port, database, username, and password. The password is stored securely in your system keychain.

MySQL

MySQL connections can be configured in malloy-config.json or via environment variables — see Configuration.

Trino and Presto

Add a Trino or Presto connection via Malloy: Edit Connections. Enter the server URL and port.


Next Steps