@@ -995,3 +995,34 @@ def test_model_grants_engine_specific_bigquery() -> None:
995995 assert grants_config is not None
996996 assert grants_config ["bigquery.dataviewer" ] == ["user@domain.com" ]
997997 assert grants_config ["select" ] == ["analyst@company.com" ]
998+
999+
1000+ def test_ephemeral_model_with_global_grants (create_empty_project ):
1001+ dbt_project_dir , dbt_model_dir = create_empty_project ()
1002+
1003+ yaml = YAML ()
1004+ dbt_project_config = {
1005+ "name" : "test_project" ,
1006+ "version" : "1.0.0" ,
1007+ "config-version" : 2 ,
1008+ "profile" : "test" ,
1009+ "model-paths" : ["models" ],
1010+ "models" : {"test_project" : {"grants" : {"select" : ["reporter" , "analyst" ]}}},
1011+ }
1012+ dbt_project_file = dbt_project_dir / "dbt_project.yml"
1013+ with open (dbt_project_file , "w" , encoding = "utf-8" ) as f :
1014+ yaml .dump (dbt_project_config , f )
1015+
1016+ ephemeral_model_sql = """
1017+ {{ config(materialized='ephemeral') }}
1018+ SELECT 1 as id
1019+ """
1020+ ephemeral_model_file = dbt_model_dir / "ephemeral_model.sql"
1021+ with open (ephemeral_model_file , "w" , encoding = "utf-8" ) as f :
1022+ f .write (ephemeral_model_sql )
1023+
1024+ context = Context (paths = dbt_project_dir )
1025+ model = context .get_model ('"local"."main"."ephemeral_model"' )
1026+
1027+ assert model .kind .is_embedded
1028+ assert model .grants is None # grants config is skipped for ephemeral / embedded models
0 commit comments