@@ -1047,3 +1047,34 @@ def test_model_grants_engine_specific_bigquery() -> None:
10471047 assert grants_config is not None
10481048 assert grants_config ["bigquery.dataviewer" ] == ["user@domain.com" ]
10491049 assert grants_config ["select" ] == ["analyst@company.com" ]
1050+
1051+
1052+ def test_ephemeral_model_with_global_grants (create_empty_project ):
1053+ dbt_project_dir , dbt_model_dir = create_empty_project ()
1054+
1055+ yaml = YAML ()
1056+ dbt_project_config = {
1057+ "name" : "test_project" ,
1058+ "version" : "1.0.0" ,
1059+ "config-version" : 2 ,
1060+ "profile" : "test" ,
1061+ "model-paths" : ["models" ],
1062+ "models" : {"test_project" : {"grants" : {"select" : ["reporter" , "analyst" ]}}},
1063+ }
1064+ dbt_project_file = dbt_project_dir / "dbt_project.yml"
1065+ with open (dbt_project_file , "w" , encoding = "utf-8" ) as f :
1066+ yaml .dump (dbt_project_config , f )
1067+
1068+ ephemeral_model_sql = """
1069+ {{ config(materialized='ephemeral') }}
1070+ SELECT 1 as id
1071+ """
1072+ ephemeral_model_file = dbt_model_dir / "ephemeral_model.sql"
1073+ with open (ephemeral_model_file , "w" , encoding = "utf-8" ) as f :
1074+ f .write (ephemeral_model_sql )
1075+
1076+ context = Context (paths = dbt_project_dir )
1077+ model = context .get_model ('"local"."main"."ephemeral_model"' )
1078+
1079+ assert model .kind .is_embedded
1080+ assert model .grants is None # grants config is skipped for ephemeral / embedded models
0 commit comments