What you will be able to do
- Set the role, warehouse, database and schema that dashboard queries run under
- Write tile queries with predictable column names, sorting and filtering
- Predict how row access policies and Dynamic Data Masking change what each dashboard viewer sees
- List what a BI tool needs to connect to Snowflake
Key concept
Dashboard session context — Every Snowsight dashboard query runs in its own session with an assigned role and warehouse. The role decides which objects the query can reach, which rows the policies return and which values are masked. The warehouse supplies the compute and gets the bill.
1.Setting the context before you query
Before a dashboard shows anything useful, you have to decide where its queries run and as whom. In Snowsight, each dashboard has a context selector. You use it to choose the role and the warehouse for every query behind the tiles. The role is the security identity: it decides which databases, schemas and tables the queries can read. The warehouse is the compute that runs them. Running a query in a worksheet records both: its Query Details show the role used and the warehouse used to execute it.
The database and schema are the other half of the context. Once a worksheet's context is set to a database (and optionally a schema), you can refer to tables by their short names. Without that context, you have to fully qualify every object as DATABASE.SCHEMA.OBJECT. The Snowflake sample query used later in this lesson does this: it names SNOWFLAKE_SAMPLE_DATA.TPCH_SF1.ORDERS in full, so it runs no matter which database is currently selected.
This matters when you pick the data source. If a table is visible only through a secondary role, a dashboard won't see it. The dashboard's primary role needs the privileges itself. The role also affects who can use the dashboard later: to view a shared dashboard, a user must use the same role as the session context of its queries. So pick a role your audience actually has, not your most privileged personal role.
Checkpoint 1 of 5· Check yourself
In Snowsight, where do you set the role and warehouse that a dashboard's tile queries run with?
The context selector on the dashboard sets the role and warehouse for all its queries. A filter's role and warehouse are used only to refresh that filter's own list of values.
“Use the context selector to specify the role and warehouse to use for running the queries in the dashboard.”Source: docs.snowflake.com
2.Writing tile queries: naming, sorting and filtering
Each tile is a worksheet query. You write it like any other worksheet SQL. To run one statement, put the cursor in it and select Run. To run everything, use Run All. End each statement with a single semicolon, because Snowsight doesn't support multiple statements in a single API call.
Naming columns. Charts are bound to column names. If an alias changes, the chart can no longer find the column, and you have to point the chart at the new name. Column aliases are identifiers, so the identifier rules apply. A double-quoted alias such as "Net Revenue (USD)" is a delimited identifier: it's case-sensitive and can contain spaces and special characters. Any later reference must spell it exactly as created, including the double quotes. A CTE that refers to net_revenue_usd won't match it. A consistent convention that avoids quoted aliases with spaces or mixed case (for example net_revenue_usd) keeps names stable across tiles and wrapper queries.
Sorting and filtering. Put the sort order in the query with ORDER BY, and the row selection in a WHERE clause. You can also sort a result column through the column options in the results grid. That sort applies to the whole result, not just the first 10,000 rows, so it's a transformation that costs compute on the same warehouse that ran the query. Display-only formatting doesn't cost anything: thousands separators, percentages, decimal precision and date formatting. Filters such as :daterange are covered in the companion lesson on charts and filters.
Checkpoint 2 of 5· Exam question
A new Snowsight dashboard for the finance team will run twelve tiles against the FINANCE_MART database. The owner wants it to run reliably for viewers. Select TWO items that must be in place for the tile queries to execute.(Select 2)
Correct answers: A, B — The warehouse chosen in the context selector is one the selected role can USAGE-operate, so tile queries have compute to run on.; The role selected in the dashboard context selector holds SELECT privileges on every table or view the tiles query.
- A. Correct. Every tile query needs a warehouse, and the selected role must hold USAGE on it, otherwise the tile fails or never starts.
- B. Correct. Tile queries run under the role chosen in the context selector, so that role needs SELECT on each referenced object or the tile returns an authorization error.
- C. Incorrect. ACCOUNTADMIN is not required and would violate least privilege; any role with the right object grants is enough.
- D. Incorrect. Snowsight has no per-viewer profile database setting that is applied to dashboard tiles; context comes from the dashboard and tile settings.
- E. Incorrect. A standard single-cluster warehouse can run dashboard tiles; multi-cluster only helps with heavy concurrency and is not a requirement.
Checkpoint 3 of 5· Check yourself
A tile query aliases a column as "Net Revenue (USD)". A wrapper query refers to it as net_revenue_usd and fails. Why?
A double-quoted alias is a delimited identifier. Any reference to it must match its exact spelling and case, inside the double quotes.
“Delimited identifiers (i.e. identifiers enclosed in double quotes) are case-sensitive”Source: docs.snowflake.com
3.How row access policies and masking change what viewers see
Because the session role is part of every tile query, governance policies can make two people looking at the same tile see different results. Snowflake has two kinds of policy that act at query time:
| Aspect | Row access policy | Dynamic Data Masking |
|---|---|---|
| What it controls | Which rows are returned | Whether a column value appears in plain text |
| Effect on a tile | Rows (and so totals) disappear for some roles | Values show as plain text, partly masked or fully masked |
| Object type | Schema-level object | Schema-level masking policy |
| Applies to | Tables and views | Table and view columns |
A row access policy is a Boolean expression bound to columns. At runtime, Snowflake builds a secure inline view and returns only the rows for which the policy returns TRUE. The simplest policy checks the current role:
CREATE OR REPLACE ROW ACCESS POLICY rap_it
AS (empl_id varchar) RETURNS BOOLEAN ->
'it_admin' = current_role()
;If a dashboard on such a table runs as any role other than it_admin, it gets no rows. That isn't a broken dashboard; the policy is working. Policies can also use a mapping table, for example sales managers matched to regions, so each manager sees only their region's revenue. The policy expression is evaluated with the policy owner's role, so the viewer doesn't need access to the mapping table. Owning the table doesn't get you around the policy either: the object owner is also subject to it.
Dynamic Data Masking works on columns instead. A masking policy is applied wherever the column appears in a query. Depending on the policy conditions and the role, the viewer sees the plain-text value, a partially masked value or a fully masked value. Masking can even stop ACCOUNTADMIN or SECURITYADMIN from seeing data they have no need to see. For a dashboard, this means a tile's row count can stay the same while its values look different from one role to the next.
Checkpoint 4 of 5· Match them up
Match each observation on a dashboard tile to its most likely cause
Tap a term, then the definition that fits it.
Row access policies remove rows. Masking policies change column values at query time. Dashboards ignore secondary roles.
“Snowflake query operators may see the plain-text value, a partially masked value, or a fully masked value.”Source: docs.snowflake.com
4.Connecting external BI tools
Snowsight isn't the only place to build reports. External BI tools connect through Snowflake's drivers, for example the JDBC driver for tools that support JDBC and the ODBC driver for ODBC-based applications. Whatever the tool, it needs the same context you set in Snowsight. The one required setting is your Snowflake account identifier. You may also need to specify the warehouse, database, schema and role. Snowsight collects these for you: open the user menu and select Connect a tool to Snowflake to see the Account Details dialog.
Power BI is a useful example. With single sign-on, the Power BI service uses an embedded Snowflake driver and opens the session with the user's default role. So the default role decides what the report can read and which policies apply. By default, ACCOUNTADMIN, ORGADMIN, GLOBALORGADMIN and SECURITYADMIN are blocked from opening a Snowflake session through Power BI.
Checkpoint 5 of 5· Check yourself
Which setting must always be supplied when configuring a third-party BI tool to connect to Snowflake?
The account identifier is always required. The warehouse, database, schema and role may also be needed, depending on the tool.
“To configure a client, driver, library, or third-party application to connect to Snowflake, you must specify your Snowflake account identifier.”Source: docs.snowflake.com
Exam traps
Each one states something that sounds right. Open it to see what is actually true.
1.A dashboard can use privileges from my secondary roles, as a worksheet session can.Why is that wrong?
Dashboards run only with the primary role. DEFAULT_SECONDARY_ROLES is ignored.
Covered in Setting the context before you query
2.A viewer whose role can't read a row access policy's mapping table will get an error on the dashboard.Why is that wrong?
The policy is evaluated with the policy owner's role, so the viewer only sees the rows the policy allows and needs no access to the mapping table.
Covered in How row access policies and masking change what viewers see
3.Power BI SSO sessions use whatever role the report author chose in Snowsight.Why is that wrong?
Snowflake creates the Power BI session with the user's default role.
Covered in Connecting external BI tools
Sources
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.
“To view shared dashboards, the Snowflake user must use the same role as the session context for the queries that drive the dashboard.”
↩︎ Setting the context before you query“The queries that drive dashboards in Snowsight use unique sessions with assigned roles and warehouses.”
↩︎ Key concept“Dashboards run exclusively with the user’s primary role, regardless of the value set for DEFAULT_SECONDARY_ROLES.”
↩︎ Exam trap 1“Dashboards run exclusively with the user’s primary role, regardless of the value set for DEFAULT_SECONDARY_ROLES.”
↩︎ Prediction“Use the context selector to specify the role and warehouse to use for running the queries in the dashboard.”
↩︎ Checkpoint - 2.
“you can reference objects in the schema without fully qualifying the object names in your query”
↩︎ Setting the context before you query“For example, when you sort a column by ascending or descending order using the column options, the changes affect all of your results”
↩︎ Writing tile queries: naming, sorting and filtering - 3.
“If a column name changes, you must update the chart to use the new column name.”
↩︎ Writing tile queries: naming, sorting and filtering - 4.
“the identifier must be specified exactly as created, including the double quotes”
↩︎ Writing tile queries: naming, sorting and filtering“Delimited identifiers (i.e. identifiers enclosed in double quotes) are case-sensitive”
↩︎ Checkpoint - 5.
“Snowflake generates the query output for the user, and the query output only contains rows based on the policy definition evaluating to TRUE.”
↩︎ How row access policies and masking change what viewers see“This approach also includes the object owner”
↩︎ How row access policies and masking change what viewers see“Snowflake evaluates the policy expression by using the role of the policy owner, not the role of the operator who executed the query.”
↩︎ Exam trap 2 - 6.
“uses masking policies to selectively mask plain-text data in table and view columns at query time”
↩︎ How row access policies and masking change what viewers see“Snowflake query operators may see the plain-text value, a partially masked value, or a fully masked value.”
↩︎ Checkpoint - 7.
“In addition, you might need to specify the warehouse, database, schema, and role that should be used.”
↩︎ Connecting external BI tools“To configure a client, driver, library, or third-party application to connect to Snowflake, you must specify your Snowflake account identifier.”
↩︎ Checkpoint - 8.
“Connect to Snowflake from most client tools/applications that support JDBC.”
↩︎ Connecting external BI tools - 9.
“By default, the ACCOUNTADMIN, ORGADMIN, GLOBALORGADMIN, and SECURITYADMIN system roles are blocked from using Microsoft Power BI to instantiate a Snowflake session.”
↩︎ Connecting external BI tools“creates a Snowflake session for the Power BI service using the user’s default role.”
↩︎ Exam trap 3