@@ -1026,3 +1026,34 @@ def test_model_grants_engine_specific_bigquery() -> None:
10261026 assert grants_config is not None
10271027 assert grants_config ["bigquery.dataviewer" ] == ["user@domain.com" ]
10281028 assert grants_config ["select" ] == ["analyst@company.com" ]
1029+
1030+
1031+ def test_ephemeral_model_with_global_grants (create_empty_project ):
1032+ dbt_project_dir , dbt_model_dir = create_empty_project ()
1033+
1034+ yaml = YAML ()
1035+ dbt_project_config = {
1036+ "name" : "test_project" ,
1037+ "version" : "1.0.0" ,
1038+ "config-version" : 2 ,
1039+ "profile" : "test" ,
1040+ "model-paths" : ["models" ],
1041+ "models" : {"test_project" : {"grants" : {"select" : ["reporter" , "analyst" ]}}},
1042+ }
1043+ dbt_project_file = dbt_project_dir / "dbt_project.yml"
1044+ with open (dbt_project_file , "w" , encoding = "utf-8" ) as f :
1045+ yaml .dump (dbt_project_config , f )
1046+
1047+ ephemeral_model_sql = """
1048+ {{ config(materialized='ephemeral') }}
1049+ SELECT 1 as id
1050+ """
1051+ ephemeral_model_file = dbt_model_dir / "ephemeral_model.sql"
1052+ with open (ephemeral_model_file , "w" , encoding = "utf-8" ) as f :
1053+ f .write (ephemeral_model_sql )
1054+
1055+ context = Context (paths = dbt_project_dir )
1056+ model = context .get_model ('"local"."main"."ephemeral_model"' )
1057+
1058+ assert model .kind .is_embedded
1059+ assert model .grants is None # grants config is skipped for ephemeral / embedded models
0 commit comments