@@ -53,11 +53,12 @@ def deploy(
53
53
force : bool ,
54
54
) -> SnowflakeCursor :
55
55
# TODO: what to do with force?
56
- if not path .joinpath ("dbt_project.yml" ).exists ():
56
+ dbt_project_path = path .joinpath ("dbt_project.yml" )
57
+ if not dbt_project_path .exists ():
57
58
raise ClickException (f"dbt_project.yml does not exist in provided path." )
58
59
59
60
if dbt_version is None :
60
- with path . joinpath ( "dbt_project.yml" ) .open () as fd :
61
+ with dbt_project_path .open () as fd :
61
62
dbt_project_config = yaml .safe_load (fd )
62
63
try :
63
64
dbt_version = dbt_project_config ["version" ]
@@ -77,11 +78,18 @@ def deploy(
77
78
cli_console .step (f"Copied { len (results )} files" )
78
79
79
80
with cli_console .phase ("Creating DBT project" ):
80
- query = f"CREATE OR REPLACE DBT PROJECT { name } FROM { stage_name } DBT_VERSION='{ dbt_version } ' DBT_ADAPTER_VERSION='{ dbt_adapter_version } '"
81
+ staged_dbt_project_path = self ._get_dbt_project_stage_path (stage_name )
82
+ query = f"""CREATE OR REPLACE DBT PROJECT { name }
83
+ FROM { stage_name } MAIN_FILE='{ staged_dbt_project_path } '
84
+ DBT_VERSION='{ dbt_version } ' DBT_ADAPTER_VERSION='{ dbt_adapter_version } '"""
81
85
return self .execute_query (query )
82
86
83
87
def execute (self , dbt_command : str , name : str , * dbt_cli_args ):
84
88
query = f"EXECUTE DBT PROJECT { name } { dbt_command } "
85
89
if dbt_cli_args :
86
90
query += " " + " " .join ([arg for arg in dbt_cli_args ])
87
91
return self .execute_query (query )
92
+
93
+ @staticmethod
94
+ def _get_dbt_project_stage_path (stage_name ):
95
+ return "/" .join ([stage_name , "dbt_project.yml" ])
0 commit comments