Skip to main content

dagster-malloy

dagster-malloy is an unofficial community integration library providing Dagster support for Malloy models (.malloy) and notebooks (.malloynb).

Features

  • Malloy as Dagster assets: Expose Malloy queries, dashboards and notebooks as Dagster assets including rich metadata (compiled SQL, Malloy source code, column schema, row preview, code references, and execution duration).

  • Complete data lineage: Automatically resolve Malloy source dependencies — including joined sources — to build a complete asset graph visible in the Dagster UI.

  • Materialization: Queries are compiled and executed via malloy-cli or the malloy Python SDK. Results are surfaced as Apache Arrow, enabling zero-copy handoff to downstream assets.

  • Data quality checks: Write validation queries directly in Malloy and have them run automatically as Dagster asset checks. Failed checks block downstream materializations, appear in the Dagster UI timeline, and are tracked in the asset health history — without any extra orchestration code.

    # Verify Customer IDs are non-null
    query: check_valid_customer_ids is orders -> {
      where: customer_id is null
      aggregate: invalid_count is count()
    }
    

Dagster Asset Lineage Graph

Quickstart

Try dagster-malloy using:

uvx dagster-malloy-demo

This generates a sample project (./malloy_demo) and launches the Dagster UI at http://127.0.0.1:3000.

Installation

uv add dagster-malloy

To enable DataFrame outputs via pandas:

uv add "dagster-malloy[pandas]"

To enable the in-process Python SDK backend:

uv add "dagster-malloy[python-backend]"

Usage

1. Loading Malloy assets

Use load_malloy_assets to discover and construct Dagster assets from .malloy files or .malloynb notebooks in a directory:

from pathlib import Path
from dagster import Definitions
from dagster_malloy import load_malloy_assets, MalloyResource

malloy_assets = load_malloy_assets(path=Path(__file__).parent / "models")

defs = Definitions(
    assets=[malloy_assets],
    resources={
        "malloy": MalloyResource(
            execution_mode="auto",  # 'cli' (default), 'python', or 'auto'
        ),
    },
)

2. Execution engines

dagster-malloy supports two execution backends via MalloyResource:

  1. cli (Default / Recommended): Executes compilation and query execution using malloy-cli / npx malloy-cli.
  2. python: Executes queries in-process using the malloy Python SDK (malloy.Runtime).
  3. auto: Selects cli if malloy-cli or npx is on $PATH, otherwise falls back to python.
resource = MalloyResource(
    execution_mode="cli",
    cli_path="npx malloy-cli",  # Custom CLI executable path
    config_path="path/to/malloy-config.json",
)

3. Custom translator (MalloyTranslator)

Subclass MalloyTranslator to customize asset keys, tags, group names, metadata, or upstream dependencies:

from dagster import AssetKey
from dagster_malloy import MalloyTranslator, MalloyTranslatorData, load_malloy_assets


class CustomMalloyTranslator(MalloyTranslator):
    def get_asset_key(self, data: MalloyTranslatorData) -> AssetKey:
        return AssetKey(["analytics", data.query_info.name])

    def get_group_name(self, data: MalloyTranslatorData) -> str:
        return "malloy_models"


malloy_assets = load_malloy_assets(
    path="./models",
    translator=CustomMalloyTranslator(),
)

4. Data quality checks

Use build_malloy_asset_checks to discover check queries in a .malloy file and register them as Dagster AssetCheckResult checks attached to a target asset:

from dagster import AssetKey
from dagster_malloy import build_malloy_asset_checks

checks = build_malloy_asset_checks(
    file_path="./models/sales.malloy",
    target_asset_key=AssetKey(["sales", "customer_analytics"]),
)

A query is recognised as a check if it's name starts with check_, test_, assert_ (eg. query: check_valid_ids is ...) or if it's annotated with # @check, # @test or # @assert before the query definition.

A check passes when the query returns zero rows, or when the first row contains invalid_count = 0 or fail_count = 0.

Example Project

A self-contained runnable example project is available in dagster_malloy_demo with instructions to run locally.

To clone and run the example locally:

git clone https://github.com/mathisdrn/dagster-malloy.git
cd dagster-malloy/dagster_malloy_demo
uv run generate_data.py
uv run dg dev -f definitions.py

Open http://127.0.0.1:3000 to view the asset catalog and lineage graph.

Contributing

Contributions, issues, and pull requests are welcome! Feel free to open an issue or submit a pull request on GitHub.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dagster_malloy-0.1.7.tar.gz (498.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dagster_malloy-0.1.7-py3-none-any.whl (151.1 kB view details)

Uploaded Python 3

File details

Details for the file dagster_malloy-0.1.7.tar.gz.

File metadata

  • Download URL: dagster_malloy-0.1.7.tar.gz
  • Upload date:
  • Size: 498.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.2 {"installer":{"name":"uv","version":"0.12.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for dagster_malloy-0.1.7.tar.gz
Algorithm Hash digest
SHA256 5758edf9155a8fd217fe52a5998a8a3c88b68d7d4dd924992b909eb2dee53c62
MD5 8f2bfb562f9b9de7f78030a4685d8e55
BLAKE2b-256 ebf56c986af606a61660a9047b4576cefec55c092944b089ac0194f731fd02ae

See more details on using hashes here.

File details

Details for the file dagster_malloy-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: dagster_malloy-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 151.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.2 {"installer":{"name":"uv","version":"0.12.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for dagster_malloy-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 dcd30ac194aec2d85f76346a8a3e8108945b6144c9044301609574b31321a422
MD5 646f56371a49d4b198e468ebb0b797cf
BLAKE2b-256 b0384d1a43f4f8eaf090348b6cb4462211c095d8b83868bf30c6c8f857eaf9bd

See more details on using hashes here.

Release history Release notifications | RSS feed

0.2.7

2 files

0.2.6

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.1

2 files

0.2.0

2 files

0.1.9

2 files

0.1.8

2 files

This release

0.1.7 This release

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page