The Malloy CLI is a command-line interface for running .malloysql and .malloy files. Use it to automate transformations, build pipelines, or compile Malloy queries to SQL.
Installation Options
Option 1: NPX (No Installation)
Run directly without installing:
npx malloy-cli --helpOption 2: Global Install via npm
npm install -g malloy-cli malloy-cli --help
Configure Connections
The CLI stores its own configuration separately from VS Code in ~/.config/malloy/config.json.
Note: The CLI does not support environment variables for connection configuration. Use the CLI commands below to manage connections.
Connection Commands
# List all connections malloy connections list # Create a new connection malloy connections create-<type> <name> # Test a connection malloy connections test <name> # Show connection details malloy connections show <name> # Delete a connection malloy connections delete <name>
Create a Connection
# For BigQuery malloy-cli connections create-bigquery <connection-name> # For Postgres malloy-cli connections create-postgres <connection-name> # For DuckDB malloy-cli connections create-duckdb <connection-name>
View options for each database type:
malloy-cli connections create-bigquery --helpBigQuery options:
-p, --project <id> GCP project ID -l, --location <region> Query location (default: "US") -k, --service-account-key-path <path> Path to service account JSON key -t, --timeout <milliseconds> Query timeout -m, --maximum-bytes-billed <bytes> Limit bytes scanned
Default Connections
Two connections are created automatically:
bigquery: Uses existing gCloud authenticationduckdb: Uses a built-in DuckDB instance
If your Malloy files reference these connection names, they work without explicit setup.
BigQuery with gCloud
If you already use gCloud:
gcloud auth login --update-adc malloy-cli connections create-bigquery my-bq
Basic Commands
Run Queries
Execute a query and return results:
# Run a named query from a Malloy file malloy-cli run path/to/model.malloy --query query_name # Run a MalloySQL file malloy-cli run transforms.malloysql
Compile to SQL
Get the generated SQL without executing:
malloy-cli compile path/to/model.malloy --query query_nameUseful for:
Debugging query logic
Copying SQL to other tools
Understanding what Malloy generates
Get Help
malloy-cli --help malloy-cli run --help malloy-cli compile --help
Next Steps
Database Support — Overview of all supported databases
Transform & Materialize — Use the CLI with MalloySQL for data transformations