Databricks Certified Associate Developer for Apache Spark 3.0 Exam Databricks-Certified-Associate-Developer-for-Apache-Spark-3.0 Question # 1 Topic 1 Discussion

Databricks Certified Associate Developer for Apache Spark 3.0 Exam Databricks-Certified-Associate-Developer-for-Apache-Spark-3.0 Question # 1 Topic 1 Discussion

Databricks-Certified-Associate-Developer-for-Apache-Spark-3.0 Exam Topic 1 Question 1 Discussion:
Question #: 1
Topic #: 1

The code block displayed below contains an error. The code block should return a DataFrame in which column predErrorAdded contains the results of Python function add_2_if_geq_3 as applied to

numeric and nullable column predError in DataFrame transactionsDf. Find the error.

Code block:

1.def add_2_if_geq_3(x):

2. if x is None:

3. return x

4. elif x >= 3:

5. return x+2

6. return x

7.

8.add_2_if_geq_3_udf = udf(add_2_if_geq_3)

9.

10.transactionsDf.withColumnRenamed("predErrorAdded", add_2_if_geq_3_udf(col("predError")))


A.

The operator used to adding the column does not add column predErrorAdded to the DataFrame.


B.

Instead of col("predError"), the actual DataFrame with the column needs to be passed, like so transactionsDf.predError.


C.

The udf() method does not declare a return type.


D.

UDFs are only available through the SQL API, but not in the Python API as shown in the code block.


E.

The Python function is unable to handle null values, resulting in the code block crashing on execution.


Get Premium Databricks-Certified-Associate-Developer-for-Apache-Spark-3.0 Questions

Contribute your Thoughts:


Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.