@@ -732,3 +732,34 @@ def test_model_grants_engine_specific_bigquery() -> None:
732732 assert grants_config is not None
733733 assert grants_config ["bigquery.dataviewer" ] == ["user@domain.com" ]
734734 assert grants_config ["select" ] == ["analyst@company.com" ]
735+
736+
737+ def test_ephemeral_model_with_global_grants (create_empty_project ):
738+ dbt_project_dir , dbt_model_dir = create_empty_project ()
739+
740+ yaml = YAML ()
741+ dbt_project_config = {
742+ "name" : "test_project" ,
743+ "version" : "1.0.0" ,
744+ "config-version" : 2 ,
745+ "profile" : "test" ,
746+ "model-paths" : ["models" ],
747+ "models" : {"test_project" : {"grants" : {"select" : ["reporter" , "analyst" ]}}},
748+ }
749+ dbt_project_file = dbt_project_dir / "dbt_project.yml"
750+ with open (dbt_project_file , "w" , encoding = "utf-8" ) as f :
751+ yaml .dump (dbt_project_config , f )
752+
753+ ephemeral_model_sql = """
754+ {{ config(materialized='ephemeral') }}
755+ SELECT 1 as id
756+ """
757+ ephemeral_model_file = dbt_model_dir / "ephemeral_model.sql"
758+ with open (ephemeral_model_file , "w" , encoding = "utf-8" ) as f :
759+ f .write (ephemeral_model_sql )
760+
761+ context = Context (paths = dbt_project_dir )
762+ model = context .get_model ('"local"."main"."ephemeral_model"' )
763+
764+ assert model .kind .is_embedded
765+ assert model .grants is None # grants config is skipped for ephemeral / embedded models
0 commit comments