Which of the following describes how Spark achieves fault tolerance?
A. Spark helps fast recovery of data in case of a worker fault by providing the MEMORY_AND_DISK storage level option. B. If an executor on a worker node fails while calculating an RDD, that RDD can be recomputed by another executor using the lineage. C. Spark builds a fault-tolerant layer on top of the legacy RDD data system, which by itself is not fault tolerant. D. Due to the mutability of DataFrames after transformations, Spark reproduces them using observed lineage in case of worker node failure. E. Spark is only fault-tolerant if this feature is specifically enabled via the spark.fault_recovery.enabled property.
B. If an executor on a worker node fails while calculating an RDD, that RDD can be recomputed by another executor using the lineage.
Question 52:
The code block displayed below contains an error. The code block is intended to write DataFrame transactionsDf to disk as a parquet file in location /FileStore/transactions_split, using column storeId as key for partitioning. Find the error.
A. The format("parquet") expression is inappropriate to use here, "parquet" should be passed as first argument to the save() operator and "/FileStore/transactions_split" as the second argument. B. Partitioning data by storeId is possible with the partitionBy expression, so partitionOn should be replaced by partitionBy. C. Partitioning data by storeId is possible with the bucketBy expression, so partitionOn should be replaced by bucketBy. D. partitionOn("storeId") should be called before the write operation. E. The format("parquet") expression should be removed and instead, the information should be added to the write expression like so: write("parquet").
B. Partitioning data by storeId is possible with the partitionBy expression, so partitionOn should be replaced by partitionBy.
Question 53:
In which order should the code blocks shown below be run in order to read a JSON file from location jsonPath into a DataFrame and return only the rows that do not have value 3 in column productId?
1.
importedDf.createOrReplaceTempView("importedDf")
2.
spark.sql("SELECT * FROM importedDf WHERE productId != 3")
3.
spark.sql("FILTER * FROM importedDf WHERE productId != 3")
A. 4, 1, 2 B. 5, 1, 3 C. 5, 2 D. 4, 1, 3 E. 5, 1, 2
E. 5, 1, 2
Question 54:
Which of the following code blocks returns a 2-column DataFrame that shows the distinct values in column productId and the number of rows with that productId in DataFrame transactionsDf?
A. transactionsDf.count("productId").distinct() B. transactionsDf.groupBy("productId").agg(col("value").count()) C. transactionsDf.count("productId") D. transactionsDf.groupBy("productId").count() E. transactionsDf.groupBy("productId").select(count("value"))
D. transactionsDf.groupBy("productId").count()
transactionsDf.groupBy("productId").count()
Correct. This code block first groups DataFrame transactionsDf by column productId and then counts the rows in each group.
transactionsDf.groupBy("productId").select(count("value")) Incorrect. You cannot call select on a GroupedData object (the output of a groupBy) statement.
transactionsDf.count("productId")
No. DataFrame.count() does not take any arguments.
transactionsDf.count("productId").distinct()
Wrong. Since DataFrame.count() does not take any arguments, this option cannot be right. transactionsDf.groupBy("productId").agg(col("value").count()) False. A Column object, as returned by col("value"), does not have a count() method.
You can see all available methods for Column object linked in the Spark documentation below. More info: pyspark.sql.DataFrame.count -- PySpark 3.1.2 documentation, pyspark.sql.Column -- PySpark 3.1.2 documentation
Static notebook | Dynamic notebook: See test 3, 41 (Databricks import instructions)
Question 55:
The code block displayed below contains an error. The code block should return all rows of DataFrame transactionsDf, but including only columns storeId and predError. Find the error.
A. Instead of select, DataFrame transactionsDf needs to be filtered using the filter operator. B. Columns storeId and predError need to be represented as a Python list, so they need to be wrapped in brackets ([]). C. The take method should be used instead of the collect method. D. Instead of collect, collectAsRows needs to be called. E. The collect method is not a method of the SparkSession object.
E. The collect method is not a method of the SparkSession object.
Correct code block:
transactionsDf.select("storeId", "predError").collect() collect() is a method of the DataFrame object.
More info: pyspark.sql.DataFrame.collect -- PySpark 3.1.2 documentation Static notebook | Dynamic notebook: See test 2, 24 (Databricks import instructions)
Question 56:
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
The schema passed into schema should be of type StructType or a string, so all entries in which a list is passed are incorrect.
In addition, since all numbers are whole numbers, the IntegerType() data type is the correct option here. NumberType() is not a valid data type and StringType() would fail, since the parquet file is
stored in the "most appropriate format for this kind of data", meaning that it is most likely an IntegerType, and Spark does not convert data types if a schema is provided. Also note that StructType accepts only a single argument (a list of
StructFields). So, passing multiple arguments is invalid.
Finally, Spark needs to know which format the file is in. However, all of the options listed are valid here, since Spark assumes parquet as a default when no file format is specifically passed.
More info: pyspark.sql.DataFrameReader.schema -- PySpark 3.1.2 documentation and StructType -- PySpark 3.1.2 documentation
Question 57:
Which of the following code blocks reorders the values inside the arrays in column attributes of DataFrame itemsDf from last to first one in the alphabet?
A. itemsDf.withColumn('attributes', sort_array(col('attributes').desc())) B. itemsDf.withColumn('attributes', sort_array(desc('attributes'))) C. itemsDf.withColumn('attributes', sort(col('attributes'), asc=False)) D. itemsDf.withColumn("attributes", sort_array("attributes", asc=False)) E. itemsDf.select(sort_array("attributes"))
D. itemsDf.withColumn("attributes", sort_array("attributes", asc=False))
Question 58:
Which of the following code blocks displays the 10 rows with the smallest values of column value in DataFrame transactionsDf in a nicely formatted way?
A. transactionsDf.sort(asc(value)).show(10) B. transactionsDf.sort(col("value")).show(10) C. transactionsDf.sort(col("value").desc()).head() D. transactionsDf.sort(col("value").asc()).print(10) E. transactionsDf.orderBy("value").asc().show(10)
B. transactionsDf.sort(col("value")).show(10)
Question 59:
The code block shown below should return all rows of DataFrame itemsDf that have at least 3 items in column itemNameElements. Choose the answer that correctly fills the blanks in the code block to accomplish this.
+------+----------------------------------+-------------------+------------------------------------------+ |1 |Thick Coat for Walking in the Snow|Sports Company Inc.|[Thick, Coat, for, Walking, in, the, Snow]|
|2 |Elegant Outdoors Summer Dress |YetiX |[Elegant, Outdoors, Summer, Dress] | +------+----------------------------------+-------------------+------------------------------------------+ The big difficulty with this is in knowing the difference between count and
size (refer to documentation below). size is the correct function to choose here since it returns the number
of elements in an array on a per-row basis.
The other consideration for solving this is the difference between select and filter. Since we want to return the rows in the original DataFrame, filter is the right choice. If we would use select, we would simply get a single-column DataFrame
The code block shown below should return a DataFrame with only columns from DataFrame transactionsDf for which there is a corresponding transactionId in DataFrame itemsDf. DataFrame itemsDf is very small and much smaller than
DataFrame transactionsDf. The query should be executed in an optimized way. Choose the answer that correctly fills the blanks in the code block to accomplish this.
Nowadays, the certification exams become more and more important and required by more and more
enterprises when applying for a job. But how to prepare for the exam effectively? How to prepare
for the exam in a short time with less efforts? How to get a ideal result and how to find the
most reliable resources? Here on Vcedump.com, you will find all the answers.
Vcedump.com provide not only Databricks exam questions,
answers and explanations but also complete assistance on your exam preparation and certification
application. If you are confused on your DATABRICKS-CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK exam preparations
and Databricks certification application, do not hesitate to visit our
Vcedump.com to find your solutions here.