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

Viewing page 3 out of 6 pages
Viewing questions 21-30 out of questions
Questions # 21:

The code block shown below should return an exact copy of DataFrame transactionsDf that does not include rows in which values in column storeId have the value 25. Choose the answer that

correctly fills the blanks in the code block to accomplish this.

Options:

A.

transactionsDf.remove(transactionsDf.storeId==25)


B.

transactionsDf.where(transactionsDf.storeId!=25)


C.

transactionsDf.filter(transactionsDf.storeId==25)


D.

transactionsDf.drop(transactionsDf.storeId==25)


E.

transactionsDf.select(transactionsDf.storeId!=25)


Expert Solution
Questions # 22:

The code block displayed below contains an error. When the code block below has executed, it should have divided DataFrame transactionsDf into 14 parts, based on columns storeId and

transactionDate (in this order). Find the error.

Code block:

transactionsDf.coalesce(14, ("storeId", "transactionDate"))

Options:

A.

The parentheses around the column names need to be removed and .select() needs to be appended to the code block.


B.

Operator coalesce needs to be replaced by repartition, the parentheses around the column names need to be removed, and .count() needs to be appended to the code block.

(Correct)


C.

Operator coalesce needs to be replaced by repartition, the parentheses around the column names need to be removed, and .select() needs to be appended to the code block.


D.

Operator coalesce needs to be replaced by repartition and the parentheses around the column names need to be replaced by square brackets.


E.

Operator coalesce needs to be replaced by repartition.


Expert Solution
Questions # 23:

The code block shown below should return a two-column DataFrame with columns transactionId and supplier, with combined information from DataFrames itemsDf and transactionsDf. The code

block should merge rows in which column productId of DataFrame transactionsDf matches the value of column itemId in DataFrame itemsDf, but only where column storeId of DataFrame

transactionsDf does not match column itemId of DataFrame itemsDf. Choose the answer that correctly fills the blanks in the code block to accomplish this.

Code block:

transactionsDf.__1__(itemsDf, __2__).__3__(__4__)

Options:

A.

1. join

2. transactionsDf.productId==itemsDf.itemId, how="inner"

3. select

4. "transactionId", "supplier"


B.

1. select

2. "transactionId", "supplier"

3. join

4. [transactionsDf.storeId!=itemsDf.itemId, transactionsDf.productId==itemsDf.itemId]


C.

1. join

2. [transactionsDf.productId==itemsDf.itemId, transactionsDf.storeId!=itemsDf.itemId]

3. select

4. "transactionId", "supplier"


D.

1. filter

2. "transactionId", "supplier"

3. join

4. "transactionsDf.storeId!=itemsDf.itemId, transactionsDf.productId==itemsDf.itemId"


E.

1. join

2. transactionsDf.productId==itemsDf.itemId, transactionsDf.storeId!=itemsDf.itemId

3. filter

4. "transactionId", "supplier"


Expert Solution
Questions # 24:

Which of the following code blocks reads the parquet file stored at filePath into DataFrame itemsDf, using a valid schema for the sample of itemsDf shown below?

Sample of itemsDf:

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

2.|itemId|attributes |supplier |

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

4.|1 |[blue, winter, cozy] |Sports Company Inc.|

5.|2 |[red, summer, fresh, cooling]|YetiX |

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

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

Options:

A.

1.itemsDfSchema = StructType([

2. StructField("itemId", IntegerType()),

3. StructField("attributes", StringType()),

4. StructField("supplier", StringType())])

5.

6.itemsDf = spark.read.schema(itemsDfSchema).parquet(filePath)


B.

1.itemsDfSchema = StructType([

2. StructField("itemId", IntegerType),

3. StructField("attributes", ArrayType(StringType)),

4. StructField("supplier", StringType)])

5.

6.itemsDf = spark.read.schema(itemsDfSchema).parquet(filePath)


C.

1.itemsDf = spark.read.schema('itemId integer, attributes , supplier string').parquet(filePath)


D.

1.itemsDfSchema = StructType([

2. StructField("itemId", IntegerType()),

3. StructField("attributes", ArrayType(StringType())),

4. StructField("supplier", StringType())])

5.

6.itemsDf = spark.read.schema(itemsDfSchema).parquet(filePath)


E.

1.itemsDfSchema = StructType([

2. StructField("itemId", IntegerType()),

3. StructField("attributes", ArrayType([StringType()])),

4. StructField("supplier", StringType())])

5.

6.itemsDf = spark.read(schema=itemsDfSchema).parquet(filePath)


Expert Solution
Questions # 25:

The code block shown below should read all files with the file ending .png in directory path into Spark. Choose the answer that correctly fills the blanks in the code block to accomplish this.

spark.__1__.__2__(__3__).option(__4__, "*.png").__5__(path)

Options:

A.

1. read()

2. format

3. "binaryFile"

4. "recursiveFileLookup"

5. load


B.

1. read

2. format

3. "binaryFile"

4. "pathGlobFilter"

5. load


C.

1. read

2. format

3. binaryFile

4. pathGlobFilter

5. load


D.

1. open

2. format

3. "image"

4. "fileType"

5. open


E.

1. open

2. as

3. "binaryFile"

4. "pathGlobFilter"

5. load


Expert Solution
Questions # 26:

Which of the following describes Spark's way of managing memory?

Options:

A.

Spark uses a subset of the reserved system memory.


B.

Storage memory is used for caching partitions derived from DataFrames.


C.

As a general rule for garbage collection, Spark performs better on many small objects than few big objects.


D.

Disabling serialization potentially greatly reduces the memory footprint of a Spark application.


E.

Spark's memory usage can be divided into three categories: Execution, transaction, and storage.


Expert Solution
Questions # 27:

Which of the following describes a narrow transformation?

Options:

A.

narrow transformation is an operation in which data is exchanged across partitions.


B.

A narrow transformation is a process in which data from multiple RDDs is used.


C.

A narrow transformation is a process in which 32-bit float variables are cast to smaller float variables, like 16-bit or 8-bit float variables.


D.

A narrow transformation is an operation in which data is exchanged across the cluster.


E.

A narrow transformation is an operation in which no data is exchanged across the cluster.


Expert Solution
Questions # 28:

The code block shown below should add column transactionDateForm to DataFrame transactionsDf. The column should express the unix-format timestamps in column transactionDate as string

type like Apr 26 (Sunday). Choose the answer that correctly fills the blanks in the code block to accomplish this.

transactionsDf.__1__(__2__, from_unixtime(__3__, __4__))

Options:

A.

1. withColumn

2. "transactionDateForm"

3. "MMM d (EEEE)"

4. "transactionDate"


B.

1. select

2. "transactionDate"

3. "transactionDateForm"

4. "MMM d (EEEE)"


C.

1. withColumn

2. "transactionDateForm"

3. "transactionDate"

4. "MMM d (EEEE)"


D.

1. withColumn

2. "transactionDateForm"

3. "transactionDate"

4. "MM d (EEE)"


E.

1. withColumnRenamed

2. "transactionDate"

3. "transactionDateForm"

4. "MM d (EEE)"


Expert Solution
Questions # 29:

Which of the following code blocks uses a schema fileSchema to read a parquet file at location filePath into a DataFrame?

Options:

A.

spark.read.schema(fileSchema).format("parquet").load(filePath)


B.

spark.read.schema("fileSchema").format("parquet").load(filePath)


C.

spark.read().schema(fileSchema).parquet(filePath)


D.

spark.read().schema(fileSchema).format(parquet).load(filePath)


E.

spark.read.schema(fileSchema).open(filePath)


Expert Solution
Questions # 30:

Which of the following code blocks returns a DataFrame that is an inner join of DataFrame itemsDf and DataFrame transactionsDf, on columns itemId and productId, respectively and in which every

itemId just appears once?

Options:

A.

itemsDf.join(transactionsDf, "itemsDf.itemId==transactionsDf.productId").distinct("itemId")


B.

itemsDf.join(transactionsDf, itemsDf.itemId==transactionsDf.productId).dropDuplicates(["itemId"])


C.

itemsDf.join(transactionsDf, itemsDf.itemId==transactionsDf.productId).dropDuplicates("itemId")


D.

itemsDf.join(transactionsDf, itemsDf.itemId==transactionsDf.productId, how="inner").distinct(["itemId"])


E.

itemsDf.join(transactionsDf, "itemsDf.itemId==transactionsDf.productId", how="inner").dropDuplicates(["itemId"])


Expert Solution
Viewing page 3 out of 6 pages
Viewing questions 21-30 out of questions