@@ -1006,3 +1006,34 @@ def test_model_grants_engine_specific_bigquery() -> None:
10061006 assert grants_config is not None
10071007 assert grants_config ["bigquery.dataviewer" ] == ["user@domain.com" ]
10081008 assert grants_config ["select" ] == ["analyst@company.com" ]
1009+
1010+
1011+ def test_ephemeral_model_with_global_grants (create_empty_project ):
1012+ dbt_project_dir , dbt_model_dir = create_empty_project ()
1013+
1014+ yaml = YAML ()
1015+ dbt_project_config = {
1016+ "name" : "test_project" ,
1017+ "version" : "1.0.0" ,
1018+ "config-version" : 2 ,
1019+ "profile" : "test" ,
1020+ "model-paths" : ["models" ],
1021+ "models" : {"test_project" : {"grants" : {"select" : ["reporter" , "analyst" ]}}},
1022+ }
1023+ dbt_project_file = dbt_project_dir / "dbt_project.yml"
1024+ with open (dbt_project_file , "w" , encoding = "utf-8" ) as f :
1025+ yaml .dump (dbt_project_config , f )
1026+
1027+ ephemeral_model_sql = """
1028+ {{ config(materialized='ephemeral') }}
1029+ SELECT 1 as id
1030+ """
1031+ ephemeral_model_file = dbt_model_dir / "ephemeral_model.sql"
1032+ with open (ephemeral_model_file , "w" , encoding = "utf-8" ) as f :
1033+ f .write (ephemeral_model_sql )
1034+
1035+ context = Context (paths = dbt_project_dir )
1036+ model = context .get_model ('"local"."main"."ephemeral_model"' )
1037+
1038+ assert model .kind .is_embedded
1039+ assert model .grants is None # grants config is skipped for ephemeral / embedded models
0 commit comments