📖 Scenario: You work as a data engineer in a company that uses Snowflake for data warehousing. Your team wants to track the flow of data between tables to understand where data comes from and where it goes. This helps in debugging and auditing data pipelines.
🎯 Goal: Build a simple data lineage tracking setup in Snowflake by creating tables, adding a configuration variable, writing a query to capture lineage, and finally creating a view to show the lineage.
📋 What You'll Learn
Create a source table with sample data
Create a target table to receive data
Add a configuration variable to hold the current timestamp
Write a query to insert data from source to target while capturing lineage
Create a view that shows the lineage information
💡 Why This Matters
🌍 Real World
Tracking data lineage helps companies understand data flow, troubleshoot issues, and comply with regulations.
💼 Career
Data engineers and analysts use lineage tracking to maintain data quality and transparency in data pipelines.
Progress0 / 4 steps
1
Create source and target tables
Create a table called source_data with columns id INT and value STRING. Insert three rows with ids 1, 2, 3 and values 'A', 'B', 'C'. Then create an empty table called target_data with the same columns.
Snowflake
Hint
Use CREATE OR REPLACE TABLE to create tables and INSERT INTO to add rows.
2
Add a configuration variable for timestamp
Create a variable called current_time and set it to the current timestamp using CURRENT_TIMESTAMP().
Snowflake
Hint
Use SET variable_name = value; to create a variable in Snowflake.
3
Insert data with lineage tracking
Insert data from source_data into target_data. Add a new column load_time to target_data to store the value of current_time for lineage tracking. Alter target_data to add load_time TIMESTAMP before inserting.
Snowflake
Hint
Use ALTER TABLE to add a column. Use INSERT INTO ... SELECT ... to copy data with the timestamp.
4
Create a view to show data lineage
Create a view called data_lineage_view that selects id, value, and load_time from target_data to show the lineage information.
Snowflake
Hint
Use CREATE OR REPLACE VIEW view_name AS SELECT ... to create the view.
Practice
(1/5)
1. What is the main purpose of data lineage tracking in Snowflake?
easy
A. To increase storage capacity automatically
B. To show where data comes from and how it moves
C. To encrypt data at rest
D. To create user accounts
Solution
Step 1: Understand data lineage concept
Data lineage tracks the origin and flow of data through systems.
Step 2: Match with Snowflake purpose
Snowflake uses lineage to show data source and movement, not storage or encryption.
Final Answer:
To show where data comes from and how it moves -> Option B
Quick Check:
Data lineage = data origin and flow [OK]
Hint: Data lineage means tracking data origin and flow [OK]
Common Mistakes:
Confusing lineage with storage management
Thinking lineage is about encryption
Mixing lineage with user management
2. Which Snowflake command helps you explore data lineage by showing object dependencies?
easy
A. SHOW OBJECT DEPENDENCIES
B. SHOW USERS
C. DESCRIBE TABLE
D. CREATE WAREHOUSE
Solution
Step 1: Identify command for lineage
SHOW OBJECT DEPENDENCIES lists how objects depend on each other, revealing lineage.
Hint: Use SHOW OBJECT DEPENDENCIES to see lineage [OK]
Common Mistakes:
Using SHOW USERS for lineage
Confusing DESCRIBE TABLE with lineage
Thinking CREATE WAREHOUSE shows dependencies
3. Given the following Snowflake query:
SHOW OBJECT DEPENDENCIES LIKE 'SALES_DATA';
What does this query return?
medium
A. List of users who accessed SALES_DATA
B. List of warehouses running SALES_DATA queries
C. List of tables with similar names to SALES_DATA
D. List of objects that depend on or are used by SALES_DATA
Solution
Step 1: Understand SHOW OBJECT DEPENDENCIES usage
This command shows dependencies related to the specified object, here SALES_DATA.
Step 2: Interpret LIKE filter
LIKE 'SALES_DATA' filters to objects named SALES_DATA, showing their dependencies.
Final Answer:
List of objects that depend on or are used by SALES_DATA -> Option D
Quick Check:
SHOW OBJECT DEPENDENCIES LIKE = dependency list [OK]
Hint: SHOW OBJECT DEPENDENCIES lists related objects [OK]
Common Mistakes:
Thinking it shows user access logs
Confusing with warehouse usage
Assuming it lists similar table names
4. You run SHOW OBJECT DEPENDENCIES LIKE 'CUSTOMER_ORDERS'; but get no results. What is a likely reason?
medium
A. The object name is misspelled or does not exist
B. You need to create a warehouse first
C. SHOW OBJECT DEPENDENCIES does not work on tables
D. Your user lacks SELECT permission on CUSTOMER_ORDERS
Solution
Step 1: Check object existence
No results usually mean the object name is wrong or missing in the database.
Step 2: Verify command applicability and permissions
SHOW OBJECT DEPENDENCIES works on tables; warehouse creation is unrelated; lack of SELECT permission does not hide dependencies.
Final Answer:
The object name is misspelled or does not exist -> Option A
Quick Check:
No results = wrong or missing object name [OK]
Hint: Check spelling and existence if no dependencies show [OK]
Common Mistakes:
Assuming warehouse needed for lineage
Thinking permissions block SHOW OBJECT DEPENDENCIES
Believing tables can't have dependencies
5. You want to track data lineage for a complex pipeline involving multiple views and tables in Snowflake. Which approach best ensures accurate lineage tracking?
hard
A. Only track lineage for base tables, ignoring views
B. Manually document dependencies in a spreadsheet
C. Use SHOW OBJECT DEPENDENCIES and automate lineage extraction with Snowflake metadata queries
D. Rely on user memory to recall data flow
Solution
Step 1: Understand lineage complexity
Complex pipelines need automated, accurate tracking to avoid errors and omissions.
Step 2: Evaluate options for accuracy and scalability
Manual docs and memory are error-prone; ignoring views misses dependencies; using SHOW OBJECT DEPENDENCIES with automation is best practice.
Final Answer:
Use SHOW OBJECT DEPENDENCIES and automate lineage extraction with Snowflake metadata queries -> Option C
Quick Check:
Automate lineage with SHOW OBJECT DEPENDENCIES for accuracy [OK]
Hint: Automate lineage extraction using SHOW OBJECT DEPENDENCIES [OK]
Common Mistakes:
Relying on manual documentation only
Ignoring views in lineage tracking
Trusting memory instead of tools
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.