Question 111
You are working with a Snowpark DataFrame named 'sales df' containing sales data including columns 'product id', 'sale date', and 'sale_amount'. You want to create a new DataFrame 'filtered df that only includes rows where the 'product id' is present in a list of approved product IDs and the 'sale_amount' is greater than the average sale amount. You have already calculated the average sale amount and stored it in a variable named 'avg_sale amount'. Which of the following code snippets correctly achieves this?
Question 112
A data engineering team is building a Snowpark pipeline to process IoT sensor data'. They want to create a UDF that uses a 3rd-party Python library (not available in Snowflake's Anaconda channel) to analyze the sensor readings. The UDF needs to be efficiently deployed and managed within Snowflake. Which of the following approaches represents the MOST robust and scalable way to register and deploy this UDF using Snowpark?
Question 113
You have a Python function that calculates a complex statistical measure on a given row of a DataFrame. You want to apply this function to each row of a Snowpark DataFrame in a distributed manner. Which of the following is the MOST efficient way to achieve this?
Question 114
You are developing a Snowpark application that performs complex data transformations on a large dataset using a UDF written in Scala.
After deploying the application, you observe that the performance is significantly slower than expected. Analyzing the query history in Snowflake, you identify that the UDF execution time is unusually high. Which of the following actions would be MOST effective in improving the performance of the UDF, considering Snowpark's execution context and Snowflake's query processing?
After deploying the application, you observe that the performance is significantly slower than expected. Analyzing the query history in Snowflake, you identify that the UDF execution time is unusually high. Which of the following actions would be MOST effective in improving the performance of the UDF, considering Snowpark's execution context and Snowflake's query processing?
Question 115
You have a DataFrame 'df in Snowpark containing order data, including a VARIANT column named 'order details'. The 'order detailS column contains a nested JSON structure with fields like 'customer id' (always a string), 'items' (an array of item IDs, sometimes numbers, sometimes strings), and 'total amount' (inconsistent data type - sometimes string, sometimes number). You need to perform the following transformations: 1. Extract the "customer_id' and cast it to an integer. 2. Extract the first item ID from the 'items' array, attempting to cast it to an integer, handling potential casting errors. 3. Extract the 'total_amount' and cast it to a decimal (precision 10, scale 2), handling potential casting errors. Which of the following code snippets correctly implements these transformations using Snowpark?
