Exam Certified Data Engineer Associate All QuestionsBrowse all questions from this exam
Question 63

A data engineer has a Python variable table_name that they would like to use in a SQL query. They want to construct a Python code block that will run the query using table_name.

They have the following incomplete code block:

____(f"SELECT customer_id, spend FROM {table_name}")

Which of the following can be used to fill in the blank to successfully complete the task?

    Correct Answer: E

    To execute a SQL query in a Spark environment using a Python variable, the correct method is to use spark.sql. This method allows you to run SQL queries directly on Spark DataFrames. Therefore, spark.sql(f"SELECT customer_id, spend FROM {table_name}") is the correct way to construct the code block.

Discussion
meow_akkOption: E

E is correct you use spark.sql to execute python comamands

benni_aleOption: E

E is correct

azure_bimonsterOption: E

E is correct