Challenge - 5 Problems
Snowflake Python Stored Procedure Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ service_behavior
intermediate2:00remaining
Understanding Python Stored Procedure Output in Snowflake
What will be the output of this Snowflake Python stored procedure when called?
CREATE OR REPLACE PROCEDURE test_proc()
RETURNS STRING
LANGUAGE PYTHON
AS
$$
def run():
return 'Hello from Snowflake!'
$$;Attempts:
2 left
💡 Hint
Remember that the function inside the procedure must return a value explicitly.
✗ Incorrect
In Snowflake Python stored procedures, the function named 'run' is executed and its return value is returned by the procedure. Here, 'run' returns the string 'Hello from Snowflake!'.
❓ Configuration
intermediate2:00remaining
Correct Syntax for Defining a Python Stored Procedure in Snowflake
Which of the following is the correct way to define a Python stored procedure in Snowflake that returns an integer 42?
Attempts:
2 left
💡 Hint
The procedure must define a run() function that returns the correct type.
✗ Incorrect
Option A correctly defines a Python stored procedure with a run() function returning integer 42. Option A misses the run() function. Option A returns nothing (print outputs to console, not return). Option A returns a string instead of integer.
❓ Architecture
advanced2:00remaining
Best Practice for Handling Exceptions in Snowflake Python Stored Procedures
You want to ensure your Python stored procedure in Snowflake handles errors gracefully and returns a meaningful message instead of failing silently or crashing. Which approach is best?
Attempts:
2 left
💡 Hint
Think about how to provide clear feedback from your procedure to callers.
✗ Incorrect
Catching exceptions inside the run() function and returning error messages as strings allows the procedure to communicate errors clearly without crashing. Letting exceptions propagate may cause abrupt failures. Print statements do not affect return values.
❓ security
advanced2:00remaining
Security Consideration When Using Python Stored Procedures in Snowflake
Which of the following is a key security best practice when creating Python stored procedures in Snowflake?
Attempts:
2 left
💡 Hint
Think about the principle of least privilege.
✗ Incorrect
Assigning minimal required privileges to the procedure and avoiding high-privilege roles like ACCOUNTADMIN reduces security risks. Storing credentials in code or disabling access controls are insecure practices.
🧠 Conceptual
expert2:00remaining
Behavior of Variable Scope in Snowflake Python Stored Procedures
Consider this Python stored procedure in Snowflake:
What is the value returned when calling scope_test()?
CREATE OR REPLACE PROCEDURE scope_test()
RETURNS STRING
LANGUAGE PYTHON
AS
$$
x = 'outer'
def run():
x = 'inner'
return x
$$;What is the value returned when calling scope_test()?
Attempts:
2 left
💡 Hint
Remember how Python handles variable scope inside functions.
✗ Incorrect
The run() function defines a local variable x = 'inner' and returns it. The outer x is not returned. Variable shadowing is allowed and does not cause syntax errors.