88 AssetKey ,
99 Definitions ,
1010 MaterializeResult ,
11+ ResourceParam ,
1112 asset ,
1213 define_asset_job ,
1314)
2728SQLMESH_CACHE_PATH = os .path .join (SQLMESH_PROJECT_PATH , ".cache" )
2829DUCKDB_PATH = os .path .join (CURR_DIR , "../../db.db" )
2930
30- sqlmesh_config = SQLMeshContextConfig (
31+ class CustomSQLMeshContextConfig (SQLMeshContextConfig ):
32+ custom_key : str
33+
34+ def get_translator (self ):
35+ return RewrittenSQLMeshTranslator (self .custom_key )
36+
37+ sqlmesh_config = CustomSQLMeshContextConfig (
3138 path = SQLMESH_PROJECT_PATH ,
3239 gateway = "local" ,
40+ custom_key = "custom_sqlmesh_prefix"
3341)
3442
35-
3643class RewrittenSQLMeshTranslator (SQLMeshDagsterTranslator ):
3744 """A contrived SQLMeshDagsterTranslator that flattens the catalog of the
3845 sqlmesh project and only uses the table db and name
@@ -85,7 +92,7 @@ def test_source() -> pl.DataFrame:
8592 )
8693
8794
88- @asset (deps = [AssetKey (["sqlmesh " , "full_model" ])])
95+ @asset (deps = [AssetKey (["custom_sqlmesh_prefix " , "full_model" ])])
8996def post_full_model () -> pl .DataFrame :
9097 """An asset that depends on the `full_model` asset from the sqlmesh project.
9198 This is used to test that the sqlmesh assets are correctly materialized and
@@ -109,7 +116,7 @@ def post_full_model() -> pl.DataFrame:
109116 enabled_subsetting = True ,
110117)
111118def sqlmesh_project (
112- context : AssetExecutionContext , sqlmesh : SQLMeshResource , sqlmesh_config : SQLMeshContextConfig
119+ context : AssetExecutionContext , sqlmesh : SQLMeshResource , sqlmesh_config : ResourceParam [ SQLMeshContextConfig ]
113120) -> t .Iterator [MaterializeResult [t .Any ]]:
114121 yield from sqlmesh .run (context , config = sqlmesh_config )
115122
0 commit comments