SPS-C01 SnowPro Specialty: Snowpark Practice Questions
Prepare for SPS-C01 with more than an answer.
- Exam fee
- $225 USD
- Time limit
- 85 minutes
- Questions on the exam
- 55
- Passing score
- 750 (scaled 0-1000) (scale 0-1000)
- Level
- Specialty
- Valid for
- 2 years
Domains covered on the exam 4
- Snowpark Concepts15%
- Snowpark API for Python30%
- Snowpark for Data Transformations35%
- Snowpark Performance Optimization20%
- 1
A machine learning engineer needs to process thousands of unstructured PDF documents stored in an internal Snowflake stage named
@DOC_STAGE. They are writing a Python UDF that will utilize theSnowflakeFileobject to read these files.Which syntax correctly opens a file dynamically passed into the UDF?
Show answer details
Correct answer: D
To read unstructured data files natively within Snowpark UDFs, UDTFs, or Stored Procedures, you must use the
SnowflakeFileclass fromsnowflake.snowpark.files. The correct syntax to open a file stream based on a scoped URL or stage location isSnowflakeFile.open(file_url, 'rb'). Standard Pythonopen()cannot directly resolve Snowflake stage URLs. - 2
A data analyst has performed local data cleansing using the
pandaslibrary on their laptop. They now have a pandas DataFrame namedpdf_dataand want to upload it to Snowflake for further processing using Snowpark. Which Snowpark method efficiently converts the pandas DataFrame into a Snowpark DataFrame?Show answer details
Correct answer: C
The
session.create_dataframe()method in Snowpark is highly versatile. It can accept a local Python list, dictionary, or a pandas DataFrame as its input. When passing a pandas DataFrame, Snowpark automatically infers the schema and uploads the local data to Snowflake, returning a server-side Snowpark DataFrame. - 3
A developer is reading a set of JSON files from an internal stage using the
session.readobject. To optimize performance and ensure strict typing, the developer wants to explicitly define the schema rather than relying on schema inference. Which Snowpark object should be used to define this explicit schema before calling the.readmethod?Show answer details
Correct answer: D
In Snowpark, schemas are explicitly defined using the
StructTypeclass, which contains a collection ofStructFieldobjects. EachStructFielddefines the column name, the Snowpark DataType (e.g.,IntegerType(),StringType()), and a boolean indicating if it is nullable. ThisStructTypeis then passed to the.schema()method of theDataFrameReader. - 4
A data engineer writes a Snowpark Python script that connects to Snowflake, initializes a DataFrame via
df = session.table("SALES"), applies a filterdf = df.filter(col("AMOUNT") > 1000), and adds a new columndf = df.with_column("TAX", col("AMOUNT") * 0.1). After executing these lines in a Jupyter Notebook, the engineer checks the Snowflake Query History but sees no queries corresponding to these operations. What is the primary reason for this behavior?Show answer details
Correct answer: A
Snowpark operations on DataFrames use lazy evaluation. Transformations (like filter, select, with_column) only build up a logical query plan on the client side. The actual SQL query is not compiled, sent, or executed on the Snowflake virtual warehouse until an action method (such as .show(), .collect(), .count(), or .save_as_table()) is called to evaluate the DataFrame.
- 5
A data architecture team is migrating legacy ETL pipelines to Snowflake using Snowpark. They have two distinct requirements:
- Process a column containing a comma-separated string of product codes, parsing it and returning multiple distinct rows for each product code.
- Create a control-flow orchestration script that sequentially truncates a staging table, executes a MERGE statement, and initiates a task failure alert if exceptions occur.
Which TWO Snowpark key objects should the team implement to satisfy these respective requirements? (Select TWO)
Show answer details
Correct answer: B, D
A UDTF (User-Defined Table Function) is the correct object for requirement 1, as it takes zero, one, or multiple input rows and returns a tabular output (multiple rows/columns), which is necessary for parsing a single string into multiple rows. A Stored Procedure is the correct object for requirement 2, as it allows for control-flow logic, transaction management, and orchestrating multiple SQL operations natively within the Snowflake engine.
- 6
When developing a Snowpark application, a data scientist uses the standard Python
math.sqrt()function within a local for-loop to calculate values before applying them to a DataFrame, as opposed to usingsnowflake.snowpark.functions.sqrt()directly on the DataFrame columns. What is the fundamental architectural difference between these two approaches?Show answer details
Correct answer: B
Snowpark's architecture clearly distinguishes between client-side and server-side execution. Standard Python functions (like
math.sqrt) executed in loops run on the client environment where the script is hosted, forcing data to be transferred out of Snowflake into local memory. Conversely, Snowpark functions (likesnowflake.snowpark.functions.sqrt) translate into SQL and execute natively on the server side within Snowflake's highly scalable virtual warehouses, avoiding data movement.
