Skip to main content

No project description provided

Project description

dagster-sqlmesh

WARNING: THIS IS A WORK IN PROGRESS

SQLMesh library for dagster integration.

Current features

  • A @sqlmesh_assets decorator akin to dagster-dbt's @dbt_assets decorator.
  • A SQLMeshResource that allows you to call sqlmesh from inside an asset (likely one defined by the @sqlmesh_assets decorator)
  • A SQLMeshDagsterTranslator that allows customizing the translation of sqlmesh models into dagster assets.

Basic Usage

This dagster sqlmesh adapter is intended to work in a similar pattern to that of dagster-dbt in the most basic case by using the @sqlmesh_assets

Assuming that your sqlmesh project is located in a directory /home/foo/sqlmesh_project, this is how you'd setup your dagster assets:

from dagster import (
    AssetExecutionContext,
    Definitions,
)
from dagster_sqlmesh import sqlmesh_assets, SQLMeshContextConfig, SQLMeshResource

sqlmesh_config = SQLMeshContextConfig(path="/home/foo/sqlmesh_project", gateway="name-of-your-gateway")

@sqlmesh_assets(config=sqlmesh_config)
def sqlmesh_project(context: AssetExecutionContext, sqlmesh: SQLMeshResource):
    yield from sqlmesh.run(context)

defs = Definitions(
    assets=[sqlmesh_project],
    resources={
        "sqlmesh": SQLMeshResource(config=sqlmesh_config),
    },
)

Contributing

We are very open to contributions!

In order to build the project you'll need the following:

  • python 3.11 or 3.12
  • node 18+
  • pnpm 8+

Note: this is a python project but some of our dependent tools are in typescript. As such all this is needed

Installing

To install everything you need for development just do the following:

poetry install
pnpm install

Running tests

We have tests that should work entirely locally. You may see a db.db file appear in the root of the repository when these tests are run. It can be safely ignored or deleted.

We run tests with pytest like so:

poetry run pytest

Running the "sample" dagster project

In the sample/dagster_project directory, is a minimal dagster project with the accompanying sqlmesh project from sample/sqlmesh_project configured as an asset. To run the sample dagster project deployment with a UI:

poetry run dagster dev -h 0.0.0.0 -f sample/dagster_project/definitions.py

If you'd like to materialize the dagster assets quickly on the CLI:

dagster asset materialize -f sample/dagster_project/definitions.py --select '*'

Note: The sqlmesh project that is in the sample folder has a dependency on a table that doesn't exist by default within the defined duckdb database. You'll notice there's a test_source asset in the dagster project. This asset will automatically populate that table in duckdb so that the sqlmesh project can be run properly. Before you run any materializations against the sqlmesh related assets in dagster, ensure that you've run the test_source at least once.

Future Plans

  • Create a new "loader" for sqlmesh and dagster definitions to allow for automatic creation of administrative jobs for sqlmesh (e.g. migrations). Additionally, we may want to have this generate assets outside of the multi_asset paradigm within dagster such that assets can have independent partitions. There is an existing issue for this in dagster itself.

Project details


Download files

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

Source Distribution

dagster_sqlmesh-0.2.0.tar.gz (21.7 kB view details)

Uploaded Source

Built Distribution

dagster_sqlmesh-0.2.0-py3-none-any.whl (24.8 kB view details)

Uploaded Python 3

File details

Details for the file dagster_sqlmesh-0.2.0.tar.gz.

File metadata

  • Download URL: dagster_sqlmesh-0.2.0.tar.gz
  • Upload date:
  • Size: 21.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.5 Darwin/23.2.0

File hashes

Hashes for dagster_sqlmesh-0.2.0.tar.gz
Algorithm Hash digest
SHA256 8b3d1ea32452d3a59f5d91fac5d3294ddcfcbea2cb01429dca12a7d9cb36a8a2
MD5 456864508289d9d0d72660f952f44b7c
BLAKE2b-256 1cadc792a171d38e2c16f630956183a839b45927f06614896f00324f522969eb

See more details on using hashes here.

File details

Details for the file dagster_sqlmesh-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: dagster_sqlmesh-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 24.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.5 Darwin/23.2.0

File hashes

Hashes for dagster_sqlmesh-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fc5da7aa24f8a3e8f88b0c205584a70a94860d6f071dd629f95a19481e295af9
MD5 e247dbe95d569165a5b947cd4c6751e6
BLAKE2b-256 cdedf67e0f56169b70571ca4e0dd7054dbcb1be6f6e3e3cde4ed3ef50a2980a6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page