Pass the Databricks Databricks Certification Databricks-Certified-Associate-Developer-for-Apache-Spark-3.0 Questions and answers with CertsForce

Viewing page 4 out of 6 pages
Viewing questions 31-40 out of questions
Questions # 31:

Which of the following describes slots?

Options:

A.

Slots are dynamically created and destroyed in accordance with an executor's workload.


B.

To optimize I/O performance, Spark stores data on disk in multiple slots.


C.

A Java Virtual Machine (JVM) working as an executor can be considered as a pool of slots for task execution.


D.

A slot is always limited to a single core.

Slots are the communication interface for executors and are used for receiving commands and sending results to the driver.


Expert Solution
Questions # 32:

Which of the following statements about reducing out-of-memory errors is incorrect?

Options:

A.

Concatenating multiple string columns into a single column may guard against out-of-memory errors.


B.

Reducing partition size can help against out-of-memory errors.


C.

Limiting the amount of data being automatically broadcast in joins can help against out-of-memory errors.


D.

Setting a limit on the maximum size of serialized data returned to the driver may help prevent out-of-memory errors.


E.

Decreasing the number of cores available to each executor can help against out-of-memory errors.


Expert Solution
Questions # 33:

The code block displayed below contains an error. The code block should return a copy of DataFrame transactionsDf where the name of column transactionId has been changed to

transactionNumber. Find the error.

Code block:

transactionsDf.withColumn("transactionNumber", "transactionId")

Options:

A.

The arguments to the withColumn method need to be reordered.


B.

The arguments to the withColumn method need to be reordered and the copy() operator should be appended to the code block to ensure a copy is returned.


C.

The copy() operator should be appended to the code block to ensure a copy is returned.


D.

Each column name needs to be wrapped in the col() method and method withColumn should be replaced by method withColumnRenamed.


E.

The method withColumn should be replaced by method withColumnRenamed and the arguments to the method need to be reordered.


Expert Solution
Questions # 34:

Which of the following code blocks shuffles DataFrame transactionsDf, which has 8 partitions, so that it has 10 partitions?

Options:

A.

transactionsDf.repartition(transactionsDf.getNumPartitions()+2)


B.

transactionsDf.repartition(transactionsDf.rdd.getNumPartitions()+2)


C.

transactionsDf.coalesce(10)


D.

transactionsDf.coalesce(transactionsDf.getNumPartitions()+2)


E.

transactionsDf.repartition(transactionsDf._partitions+2)


Expert Solution
Questions # 35:

Which of the following describes the difference between client and cluster execution modes?

Options:

A.

In cluster mode, the driver runs on the worker nodes, while the client mode runs the driver on the client machine.


B.

In cluster mode, the driver runs on the edge node, while the client mode runs the driver in a worker node.


C.

In cluster mode, each node will launch its own executor, while in client mode, executors will exclusively run on the client machine.


D.

In client mode, the cluster manager runs on the same host as the driver, while in cluster mode, the cluster manager runs on a separate node.


E.

In cluster mode, the driver runs on the master node, while in client mode, the driver runs on a virtual machine in the cloud.


Expert Solution
Questions # 36:

Which of the following statements about the differences between actions and transformations is correct?

Options:

A.

Actions are evaluated lazily, while transformations are not evaluated lazily.


B.

Actions generate RDDs, while transformations do not.


C.

Actions do not send results to the driver, while transformations do.


D.

Actions can be queued for delayed execution, while transformations can only be processed immediately.


E.

Actions can trigger Adaptive Query Execution, while transformation cannot.


Expert Solution
Questions # 37:

Which of the following code blocks returns a DataFrame with a single column in which all items in column attributes of DataFrame itemsDf are listed that contain the letter i?

Sample of DataFrame itemsDf:

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

2.|itemId|itemName |attributes |supplier |

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

4.|1 |Thick Coat for Walking in the Snow|[blue, winter, cozy] |Sports Company Inc.|

5.|2 |Elegant Outdoors Summer Dress |[red, summer, fresh, cooling]|YetiX |

6.|3 |Outdoors Backpack |[green, summer, travel] |Sports Company Inc.|

7.+------+----------------------------------+-----------------------------+-------------------+

Options:

A.

itemsDf.select(explode("attributes").alias("attributes_exploded")).filter(attributes_exploded.contains("i"))


B.

itemsDf.explode(attributes).alias("attributes_exploded").filter(col("attributes_exploded").contains("i"))


C.

itemsDf.select(explode("attributes")).filter("attributes_exploded".contains("i"))


D.

itemsDf.select(explode("attributes").alias("attributes_exploded")).filter(col("attributes_exploded").contains("i"))


E.

itemsDf.select(col("attributes").explode().alias("attributes_exploded")).filter(col("attributes_exploded").contains("i"))


Expert Solution
Questions # 38:

The code block displayed below contains an error. The code block should return the average of rows in column value grouped by unique storeId. Find the error.

Code block:

transactionsDf.agg("storeId").avg("value")

Options:

A.

Instead of avg("value"), avg(col("value")) should be used.


B.

The avg("value") should be specified as a second argument to agg() instead of being appended to it.


C.

All column names should be wrapped in col() operators.


D.

agg should be replaced by groupBy.


E.

"storeId" and "value" should be swapped.


Expert Solution
Questions # 39:

Which of the following code blocks reads in the parquet file stored at location filePath, given that all columns in the parquet file contain only whole numbers and are stored in the most appropriate

format for this kind of data?

Options:

A.

1.spark.read.schema(

2. StructType(

3. StructField("transactionId", IntegerType(), True),

4. StructField("predError", IntegerType(), True)

5. )).load(filePath)


B.

1.spark.read.schema([

2. StructField("transactionId", NumberType(), True),

3. StructField("predError", IntegerType(), True)

4. ]).load(filePath)


C.

1.spark.read.schema(

2. StructType([

3. StructField("transactionId", StringType(), True),

4. StructField("predError", IntegerType(), True)]

5. )).parquet(filePath)


D.

1.spark.read.schema(

2. StructType([

3. StructField("transactionId", IntegerType(), True),

4. StructField("predError", IntegerType(), True)]

5. )).format("parquet").load(filePath)


E.

1.spark.read.schema([

2. StructField("transactionId", IntegerType(), True),

3. StructField("predError", IntegerType(), True)

4. ]).load(filePath, format="parquet")


Expert Solution
Questions # 40:

Which of the following code blocks can be used to save DataFrame transactionsDf to memory only, recalculating partitions that do not fit in memory when they are needed?

Options:

A.

from pyspark import StorageLevel

transactionsDf.cache(StorageLevel.MEMORY_ONLY)


B.

transactionsDf.cache()


C.

transactionsDf.storage_level('MEMORY_ONLY')


D.

transactionsDf.persist()


E.

transactionsDf.clear_persist()


F.

from pyspark import StorageLevel

transactionsDf.persist(StorageLevel.MEMORY_ONLY)


Expert Solution
Viewing page 4 out of 6 pages
Viewing questions 31-40 out of questions