Question 16
You are tasked with building a Snowpark application that processes sensor data. The data arrives continuously and is ingested into a Snowflake table called 'RAW SENSOR DATA'. You need to create a Snowpark DataFrame that applies a user-defined function (UDF) to each row to enrich the data. The UDF, named 'ENRICH SENSOR DATA, is written in Python and resides in a stage called 'UDF STAGE. The UDF takes three arguments: 'timestamp', and 'raw_value', all of which are STRING type in Snowflake. Which of the following code snippets correctly defines and calls the UDF using Snowpark?
Question 17
You are tasked with deploying a Snowpark Python application that utilizes a third-party library, 'scikit-learn' , for machine learning tasks. The application will be executed as a Snowflake Stored Procedure. What are the necessary steps to ensure the 'scikit-learn' library is available within the Snowpark environment?
Question 18
A financial firm is using Snowpark Python to analyze stock trading data'. They have a DataFrame named 'trades' with columns 'trade_id', 'stock_symbol', 'trade_price', and 'trade_timestamp'. They want to identify potentially fraudulent trades based on the following criteria: 1. Trades where the 'trade_price' deviates significantly from the average price of that 'stock_symbol' over the past hour. 2. Trades originating from user accounts where the price is above $1000.3. Trades which has stock symbol 'XYZ'. The firm wants to apply multiple filters to the DataFrame to extract only the fraudulent trades and needs an efficient and concise approach using Snowpark. Which of the following code snippets, using 'trade_price' > 1000 as user identifier, MOST accurately and efficiently implements this filtering logic? Assume that a Snowflake user has a maximum amount they can spend on a trade, and therefore, the user ID is associated with 'trade_price'.
Question 19
A data engineering team wants to deploy a Snowpark Python stored procedure that aggregates sales data from a table 'SALES DATA and writes the results to a table 'AGGREGATED SALES. The stored procedure needs to be executed by various users with different roles. The team wants to ensure that users can only execute the stored procedure and cannot directly access the underlying 'SALES DATA' table. Which approach is most suitable for managing data access and security in this scenario, and what are the implications of using 'EXECUTE AS OWNER vs 'EXECUTE AS CALLER?
Question 20
You are using Snowpark Python to process a large dataset. You need to persist a DataFrame to a Snowflake table but want to ensure the operation is as efficient as possible and minimizes the data transfer overhead. The table already exists with the appropriate schema. Which of the following strategies would be the MOST efficient way to write the DataFrame to the existing table?
