@@ -1090,3 +1090,58 @@ def test_sqlmesh_model_kwargs_columns_override():
10901090 {"c" : ColumnConfig (name = "c" , data_type = "uinteger" )},
10911091 )
10921092 assert kwargs .get ("columns" ) == {"c" : exp .DataType .build (exp .DataType .Type .UINT )}
1093+
1094+
1095+ def test_empty_vars_config (tmp_path ):
1096+ """Test that a dbt project can be loaded with an empty vars config."""
1097+ dbt_project_dir = tmp_path / "test_project"
1098+ dbt_project_dir .mkdir ()
1099+
1100+ # Create a minimal dbt_project.yml with empty vars
1101+ dbt_project_yml = dbt_project_dir / "dbt_project.yml"
1102+ dbt_project_yml .write_text ("""
1103+ name: test_empty_vars
1104+ version: "1.0.0"
1105+ profile: test_empty_vars
1106+
1107+ models:
1108+ +start: Jan 1 2022
1109+
1110+ # Empty vars section - various ways to specify empty
1111+ vars:
1112+ """ )
1113+
1114+ # Create a minimal profiles.yml
1115+ profiles_yml = dbt_project_dir / "profiles.yml"
1116+ profiles_yml .write_text ("""
1117+ test_empty_vars:
1118+ outputs:
1119+ dev:
1120+ type: duckdb
1121+ schema: test
1122+ target: dev
1123+ """ )
1124+
1125+
1126+ # Create a simple model
1127+ model = dbt_project_dir / "models" / "some_model.sql"
1128+ model .parent .mkdir (parents = True , exist_ok = True )
1129+ model .write_text ("SELECT 1 as id" )
1130+
1131+ # Load the project
1132+ from sqlmesh .dbt .context import DbtContext
1133+ from sqlmesh .dbt .project import Project
1134+ from sqlmesh .core .config import Config
1135+
1136+ context = DbtContext (project_root = dbt_project_dir , sqlmesh_config = Config ())
1137+
1138+ # This should not raise an error even with empty vars
1139+ project = Project .load (context )
1140+
1141+ # Verify the project loaded successfully
1142+ assert project .packages ["test_empty_vars" ] is not None
1143+ assert project .packages ["test_empty_vars" ].name == "test_empty_vars"
1144+
1145+ # Verify the variables are empty (not causing any issues)
1146+ assert project .packages ["test_empty_vars" ].variables == {}
1147+ assert project .context .variables == {}
0 commit comments