nerdexam
Snowflake

SOL-C01 · Question #315

You are developing a Snowflake Notebook to perform data transformations using Snowpark. As part of the transformation, you need to filter a DataFrame based on a dynamically generated SQL expression. Y

Sign in or unlock SOL-C01 to reveal the answer and full explanation for question #315. The question stem and answer options stay visible for context.

Querying and Performance

Question

You are developing a Snowflake Notebook to perform data transformations using Snowpark. As part of the transformation, you need to filter a DataFrame based on a dynamically generated SQL expression. You have a Python dictionary 'filter_conditionS where keys are column names and values are the filter values. You want to construct a SQL 'WHERE clause from this dictionary and apply it to the DataFrame. However, the value types are mixed (strings, integers, dates). Which of the following approaches best handles the various data types and securely constructs the filter expression? A. B. C. D. E.

Exhibits

SOL-C01 question #315 exhibit 1
SOL-C01 question #315 exhibit 2

Options

  • AIterate over the dictionary and use the filter() method with a Column object constructed using col() and lit() functions, handling type casting for each value type
  • BConvert the dictionary to a SQL string by iterating over key-value pairs, quoting strings and formatting dates appropriately, then use filter() with the constructed SQL string
  • CUse the pandas DataFrame filter functionality after converting the Snowpark DataFrame to pandas, then convert back to Snowpark DataFrame
  • DCreate a stored procedure that accepts the filter conditions as parameters and returns the filtered results as a new DataFrame

Unlock SOL-C01 to see the answer

You've previewed enough free SOL-C01 questions. Unlock SOL-C01 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.

Topics

#Snowpark#DataFrame Filtering#Dynamic SQL#Data Type Handling
Full SOL-C01 Practice