0
0
Snowflakecloud~10 mins

Why Snowpark brings code to the data in Snowflake - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a Snowpark session.

Snowflake
from snowflake.snowpark import Session

connection_parameters = {
    "account": "[1]",
    "user": "user_name",
    "password": "password",
    "role": "SYSADMIN",
    "warehouse": "COMPUTE_WH",
    "database": "MY_DB",
    "schema": "PUBLIC"
}
session = Session.builder.configs(connection_parameters).create()
Drag options to blanks, or click blank then click option'
Amy_warehouse
Bmy_account
Cmy_database
Dmy_schema
Attempts:
3 left
💡 Hint
Common Mistakes
Using warehouse or database names instead of the account identifier.
Leaving the account parameter empty.
2fill in blank
medium

Complete the code to create a DataFrame from a Snowflake table.

Snowflake
df = session.table("[1]")
Drag options to blanks, or click blank then click option'
Amy_table
Bmy_warehouse
Cmy_database
Dmy_schema
Attempts:
3 left
💡 Hint
Common Mistakes
Using warehouse or database names instead of the table name.
Omitting quotes around the table name.
3fill in blank
hard

Fix the error in the code to apply a filter on the DataFrame.

Snowflake
filtered_df = df.filter(df["AGE"] [1] 30)
Drag options to blanks, or click blank then click option'
A==
B=>
C=
D>
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' instead of '==' or '>'.
Using '=>' which is invalid syntax.
4fill in blank
hard

Fill both blanks to select columns and show the first 5 rows.

Snowflake
result = df.select([1]).limit([2]).collect()
Drag options to blanks, or click blank then click option'
A"NAME", "AGE"
B5
C10
D"SALARY"
Attempts:
3 left
💡 Hint
Common Mistakes
Selecting only one column when multiple are needed.
Using limit(10) instead of limit(5).
5fill in blank
hard

Fill all three blanks to create a new column with a calculation and filter rows.

Snowflake
from snowflake.snowpark.functions import col

new_df = df.withColumn("AGE_PLUS_SALARY", col("AGE") [1] col("SALARY")).filter(col("AGE_PLUS_SALARY") [2] [3])
Drag options to blanks, or click blank then click option'
A+
B>
C1000
D-
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-' instead of '+' for addition.
Using '<' instead of '>' for filtering.
Using a wrong threshold value.