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

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

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

Which of the following code blocks returns a one-column DataFrame for which every row contains an array of all integer numbers from 0 up to and including the number given in column predError of

DataFrame transactionsDf, and null if predError is null?

Sample of DataFrame transactionsDf:

1.+-------------+---------+-----+-------+---------+----+

2.|transactionId|predError|value|storeId|productId| f|

3.+-------------+---------+-----+-------+---------+----+

4.| 1| 3| 4| 25| 1|null|

5.| 2| 6| 7| 2| 2|null|

6.| 3| 3| null| 25| 3|null|

7.| 4| null| null| 3| 2|null|

8.| 5| null| null| null| 2|null|

9.| 6| 3| 2| 25| 2|null|

10.+-------------+---------+-----+-------+---------+----+


A.

1.def count_to_target(target):

2. if target is None:

3. return

4.

5. result = [range(target)]

6. return result

7.

8.count_to_target_udf = udf(count_to_target, ArrayType[IntegerType])

9.

10.transactionsDf.select(count_to_target_udf(col('predError')))


B.

1.def count_to_target(target):

2. if target is None:

3. return

4.

5. result = list(range(target))

6. return result

7.

8.transactionsDf.select(count_to_target(col('predError')))


C.

1.def count_to_target(target):

2. if target is None:

3. return

4.

5. result = list(range(target))

6. return result

7.

8.count_to_target_udf = udf(count_to_target, ArrayType(IntegerType()))

9.

10.transactionsDf.select(count_to_target_udf('predError'))

(Correct)


D.

1.def count_to_target(target):

2. result = list(range(target))

3. return result

4.

5.count_to_target_udf = udf(count_to_target, ArrayType(IntegerType()))

6.

7.df = transactionsDf.select(count_to_target_udf('predError'))


E.

1.def count_to_target(target):

2. if target is None:

3. return

4.

5. result = list(range(target))

6. return result

7.

8.count_to_target_udf = udf(count_to_target)

9.

10.transactionsDf.select(count_to_target_udf('predError'))


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.