Before you beginSet up the Maple Market governance lab
Follow data forward and separate design from access evidence
The team plans to rename SALES.AMOUNT. A dashboard currently calls the output REVENUE. Its name does not tell you where the number came from. Lineage follows objects and columns from source to target. Looking downstream shows what a change could affect. Looking upstream shows where a report got its values.
OBJECT_DEPENDENCIES reports supported references such as a view over a table. It does not record data copied into a new table with CREATE TABLE AS SELECT or a MERGE. GET_LINEAGE and Snowsight can show supported movement and dependencies, subject to permissions and coverage. ACCESS_HISTORY answers a different question: who used which object or column on a recorded, successful operation?
- Validated deliveryMove accepted data to CORE.SALES
- CORE.SALESView depends on base data to SALES_BY_REGION
- SALES_BY_REGIONAudit recorded queries to Query history and access history
- Validated delivery
- The quality gate checks the source batch.
- CORE.SALES
- AMOUNT and REGION.
- SALES_BY_REGION
- REVENUE is SUM(AMOUNT).
- Query history and access history
- Independent evidence of observed use.
Build a reporting view and inspect downstream impact
The owner creates a secure reporting view after row access is in place. Confirm EU 200, IN 100 and US 150 when read as the owner before the repair. A regional role sees only its own region’s aggregate because the base table applies its row policy. The view contains no email.
USE ROLE M18_OWNER;
CREATE SECURE VIEW LS_M18_GOV_LAB.CORE.SALES_BY_REGION AS
SELECT REGION, SUM(AMOUNT) AS REVENUE, COUNT(*) AS SALES_COUNT
FROM LS_M18_GOV_LAB.CORE.SALES
GROUP BY REGION;
GRANT SELECT ON VIEW LS_M18_GOV_LAB.CORE.SALES_BY_REGION TO ROLE M18_ANALYST;
SELECT REGION, REVENUE, SALES_COUNT
FROM LS_M18_GOV_LAB.CORE.SALES_BY_REGION ORDER BY REGION;Check which object depends on SALES
In an isolated Enterprise lab, give only the approved auditor the documented SNOWFLAKE database roles. They expose account metadata and may reveal queries beyond this lab, so do not extend them to consumer roles. The audit queries are scoped to the disposable database. OBJECT_DEPENDENCIES can lag up to three hours.
USE ROLE ACCOUNTADMIN;
GRANT DATABASE ROLE SNOWFLAKE.GOVERNANCE_VIEWER TO ROLE M18_AUDITOR;
GRANT DATABASE ROLE SNOWFLAKE.OBJECT_VIEWER TO ROLE M18_AUDITOR;Find the affected reporting view
As M18_AUDITOR, use the approved warehouse and run this query. After metadata arrives, expect a row from SALES to SALES_BY_REGION. Check dependent SQL and consumers before changing or renaming a source column.
| SOURCE_OBJECT | DEPENDENT_OBJECT |
|---|---|
| SALES | SALES_BY_REGION |
SELECT REFERENCED_OBJECT_NAME AS SOURCE_OBJECT,
REFERENCING_OBJECT_NAME AS DEPENDENT_OBJECT, DEPENDENCY_TYPE
FROM SNOWFLAKE.ACCOUNT_USAGE.OBJECT_DEPENDENCIES
WHERE REFERENCED_DATABASE = 'LS_M18_GOV_LAB'
AND REFERENCED_SCHEMA = 'CORE'
AND REFERENCED_OBJECT_NAME = 'SALES'
AND REFERENCING_DATABASE = 'LS_M18_GOV_LAB';Read native lineage at object and column level
As M18_OWNER use GET_LINEAGE to see a downstream edge a single hop away. Enterprise or higher is required. Use VIEW LINEAGE on the account and privileges on in-scope objects and their parent containers. It is commonly granted to PUBLIC by default. Where it has been revoked, ask for a scoped approval. A metadata-only role can use REFERENCES on those objects. No sales data grant is needed for the object-dependency query above.
For a column check, open SALES in Snowsight’s Catalog and its Lineage tab. Select AMOUNT and inspect the downstream REVENUE field. Confirm in the view definition that it is SUM(AMOUNT). Some edges are absent or concealed without enough access. Compare repository definitions, external transformations and report owners before approving a breaking change.
SELECT SOURCE_OBJECT_NAME, TARGET_OBJECT_NAME, DISTANCE
FROM TABLE(SNOWFLAKE.CORE.GET_LINEAGE(
'LS_M18_GOV_LAB.CORE.SALES', 'TABLE', 'DOWNSTREAM', 1))
ORDER BY TARGET_OBJECT_NAME;Record a sensitive read and inspect who queried it
In a new Support test session, use the approved warehouse and run this read. A query tag gives the tester a safe label for later lookup. Use only fictional identifiers and no raw sensitive values in metadata. Save the actual query ID from Snowsight. The expected output is customer 101 and its fictional full email. The test session resets its query tag afterward.
USE ROLE M18_SUPPORT;
USE SECONDARY ROLES NONE;
ALTER SESSION SET QUERY_TAG = 'maple_m18_contact_review';
SELECT CUSTOMER_ID, EMAIL
FROM LS_M18_GOV_LAB.CORE.CUSTOMER_CONTACT
WHERE CUSTOMER_ID = 101;
ALTER SESSION UNSET QUERY_TAG;Look up the recorded event and sensitive column
As M18_AUDITOR, run the bounded query. FLATTEN makes one row per object and its nested columns from the recorded base objects. Join query history by query ID for the active primary role. The representative row identifies the test login, M18_SUPPORT and CUSTOMERS.EMAIL. When debugging a missing row, check time bounds, tag, login, grants and whether the operation is covered.
ACCESS_HISTORY can lag up to 180 minutes and retains up to a year in Account Usage. The direct object may be the contact view while the base object is CUSTOMERS. Some intermediate views are omitted. A referenced column in a plan can be logged even if not returned verbatim. ACCESS_HISTORY does not prove that the user received the raw value.
| QUERY_ID | USER_NAME | ROLE_NAME | BASE_OBJECT | ACCESSED_COLUMN |
|---|---|---|---|---|
| Q_DEMO_101 | M18_TEST_SUPPORT | M18_SUPPORT | LS_M18_GOV_LAB.CORE.CUSTOMERS |
SELECT A.QUERY_ID, A.QUERY_START_TIME, A.USER_NAME, Q.ROLE_NAME,
O.VALUE:objectName::VARCHAR AS BASE_OBJECT,
C.VALUE:columnName::VARCHAR AS ACCESSED_COLUMN
FROM SNOWFLAKE.ACCOUNT_USAGE.ACCESS_HISTORY A
JOIN SNOWFLAKE.ACCOUNT_USAGE.QUERY_HISTORY Q ON Q.QUERY_ID = A.QUERY_ID,
LATERAL FLATTEN(INPUT => A.BASE_OBJECTS_ACCESSED) O,
LATERAL FLATTEN(INPUT => O.VALUE:columns) C
WHERE A.QUERY_START_TIME >= DATEADD('hour', -24, CURRENT_TIMESTAMP())
AND Q.START_TIME >= DATEADD('hour', -24, CURRENT_TIMESTAMP())
AND Q.QUERY_TAG = 'maple_m18_contact_review'
AND O.VALUE:objectName::VARCHAR = 'LS_M18_GOV_LAB.CORE.CUSTOMERS'
AND C.VALUE:columnName::VARCHAR = 'EMAIL'
ORDER BY A.QUERY_START_TIME DESC;Investigate a denied or unexpected read
If the same column appears under an analyst role, compare it with the approved access matrix. The analyst’s expected result can be masked. Check the query ID, policy binding, reader context and whether the request used an alternate object. Treat account-history query text as sensitive. Save only the evidence needed for the review.
A failed SELECT belongs in query history rather than ACCESS_HISTORY. Run the employee-table denial from the regional test, save its query ID and ask the auditor to read status and error code after the metadata arrives. For an immediate own-session check, use Snowsight Query History. Do not infer that nobody tried a read just because Access History has no row.
SELECT QUERY_ID, USER_NAME, ROLE_NAME, EXECUTION_STATUS, ERROR_CODE
FROM SNOWFLAKE.ACCOUNT_USAGE.QUERY_HISTORY
WHERE START_TIME >= DATEADD('hour', -24, CURRENT_TIMESTAMP())
AND QUERY_ID IN ('<saved_query_id>');Turn audit and Trust Center findings into follow-up work
A monthly evidence review can compare tagged restricted columns, deployed policy bindings, approved roles and sampled access. Record the last verified date, the owner, the exception and its review date. Review data quality incidents separately because a security finding cannot tell you whether the revenue is correct.
Trust Center scanners look for potential account risks, such as over-privileged roles. Use the approved TRUST_CENTER_VIEWER application role for read-only review. If an enabled scanner reports a violation, assign an owner, check the current configuration and verify the next scanner run after the approved fix. A detection is a recorded event to investigate. A quiet dashboard covers only the scanners and scope in use, so keep your query and policy evidence. No scanner activation is required for this lab.
Interview practice
Explain the decision and the evidence you would use to test it.
What is data lineage?
It is the path of data and dependencies. I would use it to see that SALES.AMOUNT feeds the REVENUE output before changing the source.
Which query tells you who accessed an email?
I inspect ACCESS_HISTORY for the base column and join by query ID to QUERY_HISTORY for the role. I compare the record with the approved role and underlying policy.
Why might a dependency report miss an important consumer?
A copied table or external tool may not appear as a supported object dependency. I would use lineage and access evidence as well as orchestration code and the downstream owner’s records. I would also allow for metadata lag.
Words used in this lesson
- Data lineage
- The path from a source object or field to what uses or receives its data.
- ACCESS_HISTORY
- Successful operations and the objects or columns that they accessed, within coverage.
- OBJECT_DEPENDENCIES
- Metadata about supported references between objects.
See how it works
Choose a step to explore the idea at your own pace.
Open the interactive explanation
Snowflake data lineage, ACCESS_HISTORY and governance auditing
Sales lineage and separate evidence of a read
Trace AMOUNT to REVENUE during a safe schema review.
Automatic playback is off for reduced motion. Select any step or use Previous and Next. Illustrations explain behavior; they are not live measurements.
Read the complete diagram explanation
- Sales lineage and separate evidence of a read
Trace AMOUNT to REVENUE during a safe schema review.
Validated delivery → CORE.SALES → SALES_BY_REGION → Query history and access history
Try the SQL or command
Read → predict → run in your learning environment → compare. You can also learn by reading without an account.
New to SQL? Where to run it and how to read it
A query is a question written in SQL. Snowflake runs it and returns a result table. This website shows examples; it does not connect to your account.
- No account yet? Read and predict the output first. Follow the account and Snowsight lesson when you are ready.
- For SQL practice, use a learning account in Snowsight and select an authorized role and warehouse. A role determines permissions; a warehouse supplies processing power. Follow the example’s database/schema setup when it refers to stored objects.
- Read the entire example, including comments beginning with
--. Run the selected statement or labeled block in the stated order. Examples labeled Python, shell or HTTP belong in that client, not in a SQL editor. - Compare values and row counts with the explained result. If an example deliberately causes an error, follow its rollback and cleanup steps before continuing.
- SELECT / FROM
- Choose the values to return / identify their input.
- VALUES / COLUMN1
- VALUES supplies tiny example rows. COLUMN1 means their first column, COLUMN2 their second.
- AS / WITH
- AS gives a result a readable name. WITH names a temporary query step within one statement.
- NULL / ::
- NULL means missing or unknown. The :: notation converts a value to a named data type.
- Session
- One connection and its settings. Keep related transaction steps in the same session.
- Database.schema.table
- A full address for stored data. It is separate from the warehouse that processes queries.
Need the L2_OBJECTS_LAB setup? Open the first database-object lesson →
Help with common practice errors
- No active warehouse: select a warehouse your role can use. Do not assume you need to create a new one.
- Object missing or not authorized: check the full name, required setup and active role. Ask the account owner for access if needed.
- Object already exists: setup may already have run. Read the current state or choose a fresh lab name consistently; do not add OR REPLACE blindly.
- Different result: check whether an earlier INSERT or UPDATE changed the data. VALUES examples provide their own fresh input for each statement.
Before running this lesson
All records are fictional. Outputs are expected or simulated. Live practice needs an authorized scratch account, test roles, an approved warehouse and the editions listed in the lesson.
Check your understanding
Choose an answer, then check your reasoning. This is practice, not a scored test.
Try it yourself
Before changing SALES.AMOUNT, list two checks and one reason they could miss a report.
Compare your reasoning
Check object dependencies and field-level lineage, then review external consumers with owners. A copied table or external system may not appear in all metadata.
Connect this lesson to the learning path
Official sources and curriculum
Module 18 · See module scope
By Rohit Ray · Independent educational lesson · Explore this visual lab