0
0
Snowflakecloud~20 mins

SELECT with Snowflake functions - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Snowflake SELECT Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
service_behavior
intermediate
2:00remaining
Understanding the output of a SELECT with DATE_TRUNC
What is the output of this query when run on 2024-06-15 14:35:20?

SELECT DATE_TRUNC('month', '2024-06-15 14:35:20'::TIMESTAMP) AS truncated_date;
Snowflake
SELECT DATE_TRUNC('month', '2024-06-15 14:35:20'::TIMESTAMP) AS truncated_date;
A2024-06-01 00:00:00.000
B2024-06-15 00:00:00.000
C2024-01-01 00:00:00.000
D2024-06-15 14:35:20.000
Attempts:
2 left
💡 Hint
DATE_TRUNC cuts off smaller parts of the date to the start of the specified part.
🧠 Conceptual
intermediate
2:00remaining
Effect of TRY_CAST on invalid data
What will be the result of this query?

SELECT TRY_CAST('abc' AS INTEGER) AS result;
Snowflake
SELECT TRY_CAST('abc' AS INTEGER) AS result;
AError: invalid input syntax for integer
B0
Cabc
DNULL
Attempts:
2 left
💡 Hint
TRY_CAST returns NULL instead of error when conversion fails.
Configuration
advanced
2:30remaining
Using LATERAL FLATTEN to extract array elements
Given a table with a VARIANT column named data containing JSON arrays, which query correctly extracts each element as a separate row?

Assume table name is events and column is data.

Options:
Snowflake
SELECT value FROM events, LATERAL FLATTEN(input => data);
ASELECT FLATTEN(data) FROM events;
BSELECT data.value FROM events FLATTEN(data);
CSELECT value FROM events, LATERAL FLATTEN(input => data);
DSELECT value FROM events FLATTEN(input => data);
Attempts:
2 left
💡 Hint
LATERAL FLATTEN is used with FROM clause and input parameter.
security
advanced
2:00remaining
Preventing SQL injection with Snowflake functions
Which Snowflake function helps safely handle user input to prevent SQL injection when constructing dynamic SQL queries?
AIDENTIFIER()
BTO_VARCHAR()
CPARSE_JSON()
DTRY_CAST()
Attempts:
2 left
💡 Hint
This function safely treats input as an object name, not code.
Architecture
expert
3:00remaining
Optimizing query performance with clustering keys
You have a large Snowflake table frequently queried by a date column. Which approach best improves query performance for date range filters?
ACreate a materialized view without clustering
BDefine a clustering key on the date column
CUse a multi-cluster warehouse without clustering keys
DPartition the table by date using standard SQL partition syntax
Attempts:
2 left
💡 Hint
Clustering keys physically organize data to speed up range queries.