Docsity

Databricks Certified Associate Developer for Apache Spark 3.0 – Python, Exams of Computer Science

Toggle sidebar
bg1
1
Practice Exam
Databricks Certified Associate Developer for Apache Spark 3.0 – Python
NOTE: ANSWERS KEY PROVIDED ON LAST PAGES
Overview
This is a practice exam for the Databricks Certified Associate Developer for Apache Spark 3.0 -
Python exam. The questions here are retired questions from the actual exam that are
representative of the questions one will receive while taking the actual exam. After taking this
practice exam, one should know what to expect while taking the actual Associate Developer for
Apache Spark 3.0 - Python exam.
Just like the actual exam, it contains 60 multiple-choice questions. Each of these questions has
one correct answer. The correct answer for each question is listed at the bottom in the Correct
Answers section.
There are a few more things to be aware of:
1.
This practice exam is for the Python version of the actual exam, but it’s incredibly similar to
the Scala version of the actual exam, as well. There is a practice exam for the Scala version,
too.
2.
There is a two-hour time limit to take the actual exam.
3.
In order to pass the actual exam, testers will need to correctly answer at least 42 of the 60
questions.
4.
During the actual exam, testers will be able to reference a PDF version of the Apache Spark
documentation. Please use this version of the documentation while taking this practice
exam.
5.
During the actual exam, testers will not be able to test code in a Spark session. Please do
not use a Spark session when taking this practice exam.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b

Partial preview of the text

Download Databricks Certified Associate Developer for Apache Spark 3.0 – Python and more Exams Computer Science in PDF only on Docsity!

PracticeExam Databricks Certified Associate Developer for Apache Spark 3.0 – Python NOTE: ANSWERS KEY PROVIDED ON LAST PAGES Overview This is a practice exam for the Databricks Certified Associate Developer for Apache Spark 3.0 - Python exam. The questions here are retired questions from the actual exam that are representative of the questions one will receive while taking the actual exam. After taking this practice exam, one should know what to expect while taking the actual Associate Developer for Apache Spark 3.0 - Python exam. Just like the actual exam, it contains 60 multiple-choice questions. Each of these questions has one correct answer. The correct answer for each question is listed at the bottom in the Correct Answers section. There are a few more things to be aware of:

  1. This practice exam is for the Python version of the actual exam, but it’s incredibly similar to the Scala version of the actual exam, as well. There is a practice exam for the Scala version, too.
  2. There is a two-hour time limit to take the actual exam.
  3. In order to pass the actual exam, testers will need to correctly answer at least 42 of the 60 questions.
  4. During the actual exam, testers will be able to reference a PDF version of the Apache Spark documentation. Please use this version of the documentation while taking this practice exam.
  5. During the actual exam, testers will not be able to test code in a Spark session. Please do not use a Spark session when taking this practice exam.
  1. These questions are representative of questions that are on the actual exam, but they are no longer on the actual exam. Exam Questions Question 1 Which of the following statements about the Spark driver is incorrect? A. The Spark driver is the node in which the Spark application's main method runs to coordinate the Spark application. B. The Spark driver is horizontally scaled to increase overall processing throughput. C. The Spark driver contains the SparkContext object. D. The Spark driver is responsible for scheduling the execution of data by various worker nodes in cluster mode. E. The Spark driver should be as close as possible to worker nodes for optimal performance. Question 2 Which of the following describes nodes in cluster-mode Spark? A. Nodes are the most granular level of execution in the Spark execution hierarchy. B. There is only one node and it hosts both the driver and executors. C. Nodes are another term for executors, so they are processing engine instances for performing computations. D. There are driver nodes and worker nodes, both of which can scale horizontally. E. Worker nodes are machines that host the executors responsible for the execution of tasks. Question 3 Which of the following statements about slots is true? A. There must be more slots than executors. B. There must be more tasks than slots. C. Slots are the most granular level of execution in the Spark execution hierarchy. D. Slots are not used in cluster mode. E. Slots are resources for parallelization within a Spark application.

D. There will be a lot of overhead associated with managing resources for data processing within each task. E. There might be risk of out-of-memory errors depending on the size of the executors in the cluster. Question 8 Which of the following operations will trigger evaluation? A. DataFrame.filter() B. DataFrame.distinct() C. DataFrame.intersect() D. DataFrame.join() E. DataFrame.count() Question 9 Which of the following describes the difference between transformations and actions? A. Transformations work on DataFrames/Datasets while actions are reserved for native language objects. B. There is no difference between actions and transformations. C. Actions are business logic operations that do not induce execution while transformations are execution triggers focused on returning results. D. Actions work on DataFrames/Datasets while transformations are reserved for native language objects. E. Transformations are business logic operations that do not induce execution while actions are execution triggers focused on returning results. Question 10 Which of the following DataFrame operations is always classified as a narrow transformation? A. DataFrame.sort() B. DataFrame.distinct() C. DataFrame.repartition() D. DataFrame.select() E. DataFrame.join() Question 11 Spark has a few different execution/deployment modes: cluster, client, and local. Which of the following describes Spark's execution/deployment mode?

A. Spark's execution/deployment mode determines where the driver and executors are physically located when a Spark application is run B. Spark's execution/deployment mode determines which tasks are allocated to which executors in a cluster C. Spark's execution/deployment mode determines which node in a cluster of nodes is responsible for running the driver program D. Spark's execution/deployment mode determines exactly how many nodes the driver will connect to when a Spark application is run E. Spark's execution/deployment mode determines whether results are run interactively in a notebook environment or in batch Question 12 Which of the following cluster configurations will ensure the completion of a Spark application in light of a worker node failure? Note: each configuration has roughly the same compute power using 100GB of RAM and 200 cores. A. Scenario # B. They should all ensure completion because worker nodes are fault-tolerant. C. Scenario # D. Scenario # E. Scenario # Question 13 Which of the following describes out-of-memory errors in Spark? A. An out-of-memory error occurs when either the driver or an executor does not have enough memory to collect or process the data allocated to it.

D. DataFrame.coalesce(n) E. DataFrame.persist() Question 17 Which of the following data structures are Spark DataFrames built on top of? A. Arrays B. Strings C. RDDs D. Vectors E. SQL Tables Question 18 Which of the following code blocks returns a DataFrame containing only column storeId and column division from DataFrame storesDF? A. storesDF.select("storeId").select("division") B. storesDF.select(storeId, division) C. storesDF.select("storeId", "division") D. storesDF.select(col("storeId", "division")) E. storesDF.select(storeId).select(division) Question 19 Which of the following code blocks returns a DataFrame containing all columns from DataFrame storesDF except for column sqft and column customerSatisfaction? A sample of DataFrame storesDF is below: A. storesDF.drop("sqft", "customerSatisfaction")

B. storesDF.select("storeId", "open", "openDate", "division") C. storesDF.select(-col(sqft), - col(customerSatisfaction)) D. storesDF.drop(sqft, customerSatisfaction) E. storesDF.drop(col(sqft), col(customerSatisfaction)) Question 20 The below code shown block contains an error. The code block is intended to return a DataFrame containing only the rows from DataFrame storesDF where the value in DataFrame storesDF 's "sqft" column is less than or equal to 25,000. Assume DataFrame storesDF is the only defined language variable. Identify the error. Code block: storesDF.filter(sqft <= 25000) A. The column name sqft needs to be quoted like storesDF.filter("sqft" <= 25000). B. The column name sqft needs to be quoted and wrapped in the col() function like storesDF.filter(col("sqft") <= 25000). C. The sign in the logical condition inside filter() needs to be changed from <= to >. D. The sign in the logical condition inside filter() needs to be changed from <= to >=. E. The column name sqft needs to be wrapped in the col() function like storesDF.filter(col(sqft) <= 25000). Question 21 The code block shown below should return a DataFrame containing only the rows from DataFrame storesDF where the value in column sqft is less than or equal to 25,000 OR the value in column customerSatisfaction is greater than or equal to 30. Choose the response that correctly fills in the numbered blanks within the code block to complete this task. Code block: storesDF. 1 ( 2 3 4 ) A.

  1. filter
  2. (col("sqft") <= 25000)
  3. |
  4. (col("customerSatisfaction") >= 30) B.

Question 24 Which of the following code blocks returns a new DataFrame from DataFrame storesDF where column numberOfManagers is the constant integer 1? A. storesDF.withColumn("numberOfManagers", col(1)) B. storesDF.withColumn("numberOfManagers", 1) C. storesDF.withColumn("numberOfManagers", lit(1)) D. storesDF.withColumn("numberOfManagers", lit("1")) E. storesDF.withColumn("numberOfManagers", IntegerType(1)) Question 25 The code block shown below contains an error. The code block intends to return a new DataFrame where column storeCategory from DataFrame storesDF is split at the underscore character into column storeValueCategory and column storeSizeCategory. Identify the error. A sample of DataFrame storesDF is displayed below: Code block: (storesDF.withColumn( "storeValueCategory", col("storeCategory").split("")[0] ).withColumn( "storeSizeCategory", col("storeCategory").split("")[1] ) ) A. The split() operation comes from the imported functions object. It accepts a string column name and split character as arguments. It is not a method of a Column object.

B. The split() operation comes from the imported functions object. It accepts a Column object and split character as arguments. It is not a method of a Column object. C. The index values of 0 and 1 should be provided as second arguments to the split() operation rather than indexing the result. D. The index values of 0 and 1 are not correct — they should be 1 and 2, respectively. E. The withColumn() operation cannot be called twice in a row. Question 26 Which of the following operations can be used to split an array column into an individual DataFrame row for each element in the array? A. extract() B. split() C. explode() D. arrays_zip() E. unpack() Question 27 Which of the following code blocks returns a new DataFrame where column storeCategory is an all-lowercase version of column storeCategory in DataFrame storesDF? Assume DataFrame storesDF is the only defined language variable. A. storesDF.withColumn("storeCategory", lower(col("storeCategory"))) B. storesDF.withColumn("storeCategory", col("storeCategory").lower()) C. storesDF.withColumn("storeCategory", tolower(col("storeCategory"))) D. storesDF.withColumn("storeCategory", lower("storeCategory")) E. storesDF.withColumn("storeCategory", lower(storeCategory)) Question 28 The code block shown below contains an error. The code block is intended to return a new DataFrame where column division from DataFrame storesDF has been renamed to column state and column managerName from DataFrame storesDF has been renamed to column managerFullName. Identify the error. Code block:

A. storesDF.agg(approx_count_distinct(col("division")).alias("divi sionDistinct")) B. storesDF.agg(approx_count_distinct(col("division"), 0).alias("divisionDistinct")) C. storesDF.agg(countDistinct(col("division")).alias("divisionDist inct")) D. storesDF.select("division").dropDuplicates().count() E. storesDF.select("division").distinct().count()

Question 32 The code block shown below should return a new DataFrame with the mean of column sqft from DataFrame storesDF in column sqftMean. Choose the response that correctly fills in the numbered blanks within the code block to complete this task. Code block: storesDF. 1 ( 2 ( 3 ).alias("sqftMean")) A.

  1. agg
  2. mean
  3. col("sqft") B.
  4. mean
  5. col
  6. "sqft" C.
  7. withColumn
  8. mean
  9. col("sqft") D.
  10. agg
  11. mean
  12. "sqft" E.
  13. agg
  14. average
  15. col("sqft") Question 33 Which of the following code blocks returns the number of rows in DataFrame storesDF? A. storesDF.withColumn("numberOfRows", count()) B. storesDF.withColumn(count().alias("numberOfRows")) C. storesDF.countDistinct() D. storesDF.count() E. storesDF.agg(count())

B. There is no argument specified to the withReplacement parameter. C. The sample() operation does not sample without replacement — sampleby() should be used instead. D. The sample() operation is not reproducible. E. The first argument True sets the sampling to be with replacement. Question 38 Which of the following operations can be used to return the top n rows from a DataFrame? A. DataFrame.n() B. DataFrame.take(n) C. DataFrame.head D. DataFrame.show(n) E. DataFrame.collect(n) Question 39 The code block shown below should extract the value for column sqft from the first row of DataFrame storesDF. Choose the response that correctly fills in the numbered blanks within the code block to complete this task. Code block:

    1. 3 A.
  1. storesDF

  2. first

  3. col("sqft") B.

  4. storesDF

  5. first

  6. sqft C.

  7. storesDF

  8. first

  9. ["sqft"] D.

  10. storesDF

  11. first()

  1. sqft E.
  2. storesDF
  3. first()
  4. col("sqft") Question 40 Which of the following lines of code prints the schema of a DataFrame? A. print(storesDF) B. storesDF.schema C. print(storesDF.schema()) D. DataFrame.printSchema() E. DataFrame.schema() Question 41 In what order should the below lines of code be run in order to create and register a SQL UDF named "ASSESS_PERFORMANCE" using the Python function assessPerformance and apply it to column customerSatistfaction in table stores? Lines of code:
  5. spark.udf.register("ASSESS_PERFORMANCE", assessPerformance)
  6. spark.sql("SELECT customerSatisfaction, assessPerformance(customerSatisfaction) AS result FROM stores")
  7. spark.udf.register(assessPerformance, "ASSESS_PERFORMANCE")
  8. spark.sql("SELECT customerSatisfaction, ASSESS_PERFORMANCE(customerSatisfaction) AS result FROM stores") A. 3, 4 B. 1, 4 C. 3, 2 D. 2 E. 1, 2 Question 42

D. spark.createDataFrame(years) E. spark.createDataFrame(years, IntegerType) Question 45 Which of the following operations can be used to cache a DataFrame only in Spark’s memory assuming the default arguments can be updated? A. DataFrame.clearCache() B. DataFrame.storageLevel C. StorageLevel D. DataFrame.persist() E. DataFrame.cache() Question 46 The code block shown below contains an error. The code block is intended to return a new 4 - partition DataFrame from the 8 - partition DataFrame storesDF without inducing a shu e. Identify the error. Code block: storesDF.repartition(4) A. The repartition operation will only work if the DataFrame has been cached to memory. B. The repartition operation requires a column on which to partition rather than a number of partitions. C. The number of resulting partitions, 4, is not achievable for an 8 - partition DataFrame. D. The repartition operation induced a full shu e. The coalesce operation should be used instead. E. The repartition operation cannot guarantee the number of result partitions. Question 47 Which of the following code blocks will always return a new 12 - partition DataFrame from the 8 - partition DataFrame storesDF? A. storesDF.coalesce(12) B. storesDF.repartition() C. storesDF.repartition(12) D. storesDF.coalesce() E. storesDF.coalesce(12, "storeId")

Question 48 Which of the following Spark config properties represents the number of partitions used in wide transformations like join()? A. spark.sql.shuffle.partitions B. spark.shuffle.partitions C. spark.shuffle.io.maxRetries D. spark.shuffle.file.buffer E. spark.default.parallelism Question 49 In what order should the below lines of code be run in order to return a DataFrame containing a column openDateString , a string representation of Java’s SimpleDateFormat? 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: Lines of code:

  1. storesDF.withColumn("openDateString", from_unixtime(col("openDate"), simpleDateFormat))
  2. simpleDateFormat = "EEEE, MMM d, yyyy h:mm a"
  3. storesDF.withColumn("openDateString", from_unixtime(col("openDate"), SimpleDateFormat()))
  4. storesDF.withColumn("openDateString", date_format(col("openDate"), simpleDateFormat))