Complete the code to create a Snowpark session.
from snowflake.snowpark import Session connection_parameters = { "account": "my_account", "user": "my_user", "password": "my_password", "role": "SYSADMIN", "warehouse": "COMPUTE_WH", "database": "MY_DB", "schema": "PUBLIC" } session = Session.[1](connection_parameters)
Use Session.connect() to create a Snowpark session with the given connection parameters.
Complete the code to create a DataFrame from a table named 'EMPLOYEES'.
df = session.table([1])The table name must be a string with the exact case as in Snowflake, so use double quotes around uppercase 'EMPLOYEES'.
Fix the error in the code to filter rows where the 'AGE' column is greater than 30.
filtered_df = df.filter(df[[1]] > 30)
Column names in Snowpark DataFrames are case sensitive and should be passed as strings with the exact case, so use double quotes around 'AGE'.
Fill both blanks to select the 'NAME' column and sort the DataFrame by 'SALARY' descending.
result_df = df.select([1]).order_by([2].desc())
Select columns by passing the column expression like df["NAME"]. To sort descending, use df["SALARY"].desc().
Fill all three blanks to create a new column 'BONUS' as 10% of 'SALARY', filter rows where 'BONUS' is greater than 5000, and show the result.
from snowflake.snowpark.functions import col result = df.with_column("BONUS", [1]).filter([2] > 5000) result.[3]()
Create the 'BONUS' column by multiplying the 'SALARY' column by 0.1. Then filter rows where 'BONUS' is greater than 5000 using col("BONUS"). Finally, use show() to display the result.