To restrict a Snowflake Data Access share to specific games, create your own view per game filtered on game_name, then grant Snowflake roles access to that view instead of the raw share.
Problem - I want my teams to be able to use Data Access to query their data in Snowflake, but I want to restrict access to only the specific projects that the teams are responsible for.
Solution -
In order to limit the games that your Snowflake users have access to, you'll need to restrict access to the unity data share, and create your own views that partition the data based on the game name.
To do that you'll need to perform the following steps
- Create (or use and existing) a Snowflake Database & schema. In this example we use the DB
my_personal_dband the default schema ofpublic - Select the game names that you want to use. For efficiency I've added extra constraints to the query to reduce execution time, and cost
select distinct game_name from unity_unityliveops_unity_analytics_pda.shares.account_events
where event_name = 'gameStarted' and event_timestamp >= current_date - 30;3. Now that we've a list of game names, we can create a game-specific view. For this example, the last query included a game called hello_world_2000, and we're creating a view called events__hello_world_2000
CREATE OR REPLACE VIEW my_personal_db.public.events__hello_world_2000 as
SELECT * FROM UNITY_UNITYLIVEOPS_UNITY_ANALYTICS_PDA.shares.account_events WHERE game_name = 'hello_world_2000';4. Now that this is created, you will need to ensure that there is a ROLE setup for the users you want to be able to access this view. This is pure snowflake and we'd advise you to check in with their documentation if this section is out of date.
//create the role
CREATE ROLE hello_world_2000_developers;
//configure the role so that anyone with the role can access the view
GRANT SELECT ON VIEW events__hello_world_2000 TO ROLE hello_world_2000_developers;
//assign the role to a user (repeat as necessary)
GRANT ROLE hello_world_2000_developers TO USER user1;5. Once the permissions are setup, your users can now query the view in question!
select * from my_personal_db.public.events__hello_world_2000 ;
For any questions about this, please reach out to our Unity Support team.