Free CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK Databricks CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK Practice Test Question

Loading demo links...

Showing 4–6 of 23 questions

Question 4 (Topic 1)

The code block shown below contains an error. The code block is intended to create a Python UDF assessPerformanceUDF() using the integer-returning Python function assessPerformance() and apply it to column customerSatisfaction in DataFrame storesDF. Identify the error. Code block: assessPerformanceUDF – udf(assessPerformance) storesDF.withColumn("result", assessPerformanceUDF(col("customerSatisfaction")))

Select an option, then click Submit answer.

  • The assessPerformance() operation is not properly registered as a UDF.
  • The withColumn() operation is not appropriate here – UDFs should be applied by iterating over rows instead.
  • UDFs can only be applied vie SQL and not through the DataFrame API.
  • The return type of the assessPerformanceUDF() is not specified in the udf() operation.
  • The assessPerformance() operation should be used on column customerSatisfaction rather than the assessPerformanceUDF() operation.
Question 5 (Topic 1)

The code block shown below contains an error. The code block is intended to use SQL to return a new DataFrame containing column storeId and column managerName from a table created from DataFrame storesDF. Identify the error. Code block: storesDF.createOrReplaceTempView("stores") storesDF.sql("SELECT storeId, managerName FROM stores")

Select an option, then click Submit answer.

  • The createOrReplaceTempView() operation does not make a Dataframe accessible via SQL.
  • The sql() operation should be accessed via the spark variable rather than DataFrame storesDF.
  • There is the sql() operation in DataFrame storesDF. The operation query() should be used instead.
  • This cannot be accomplished using SQL – the DataFrame API should be used instead.
  • The createOrReplaceTempView() operation should be accessed via the spark variable rather than DataFrame storesDF.
Question 6 (Topic 1)

The code block shown below contains an error. The code block is intended to return a DataFrame containing a column openDateString, a string representation of Java’s SimpleDateFormat. Identify the error. Note that column openDate is of type integer and represents a date in the UNIX epoch format – the number of seconds since midnight on January 1st, 1970. An example of Java’s SimpleDateFormat is "Sunday, Dec 4, 2008 1:05 PM". A sample of storesDF is displayed below: Code block: storesDF.withColumn("openDateString", from_unixtime(col("openDate"), "EEE, MMM d, yyyy h:mm a", TimestampType()))

Select an option, then click Submit answer.

  • The from_unixtime() operation only accepts two parameters – the TimestampTime() arguments not necessary.
  • The from_unixtime() operation only works if column openDate is of type long rather than integer – column openDate must first be converted.
  • The second argument to from_unixtime() is not correct – it should be a variant of TimestampType() rather than a string.
  • The from_unixtime() operation automatically places the input column in java’s SimpleDateFormat – there is no need for a second or third argument.
  • The column openDate must first be converted to a timestamp, and then the Date() function can be used to reformat to java’s SimpleDateFormat.