The code block shown below should store DataFrame transactionsDf on two different executors, utilizing the executors' memory as much as possible, but not writing anything to disk. Choose the answer that correctly fills the blanks in the code block to accomplish this.
1.from pyspark import StorageLevel 2.transactionsDf.__1__(StorageLevel.__2__).__3__
A. 1. cache
2.
MEMORY_ONLY_2
3.
count()
B. 1. persist
2.
DISK_ONLY_2
3.
count()
C. 1. persist
2.
MEMORY_ONLY_2
3.
select()
D. 1. cache
2.
DISK_ONLY_2
3.
count()
E. 1. persist
2.
MEMORY_ONLY_2
3.
count()
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")
4.
importedDf = spark.read.option("format", "json").path(jsonPath)
5.
importedDf = spark.read.json(jsonPath)
A. 4, 1, 2
B. 5, 1, 3
C. 5, 2
D. 4, 1, 3
E. 5, 1, 2
Which of the following code blocks returns a DataFrame with an added column to DataFrame transactionsDf that shows the unix epoch timestamps in column transactionDate as strings in the format month/day/year in column transactionDateFormatted?
Excerpt of DataFrame transactionsDf:
A. transactionsDf.withColumn("transactionDateFormatted", from_unixtime("transactionDate", format="dd/ MM/yyyy"))
B. transactionsDf.withColumnRenamed("transactionDate", "transactionDateFormatted", from_unixtime ("transactionDateFormatted", format="MM/dd/yyyy"))
C. transactionsDf.apply(from_unixtime(format="MM/dd/yyyy")).asColumn("transactionDateFor matted")
D. transactionsDf.withColumn("transactionDateFormatted", from_unixtime("transactionDate", format="MM/ dd/yyyy"))
E. transactionsDf.withColumn("transactionDateFormatted", from_unixtime("transactionDate"))
Which of the following describes a valid concern about partitioning?
A. A shuffle operation returns 200 partitions if not explicitly set.
B. Decreasing the number of partitions reduces the overall runtime of narrow transformations if there are more executors available than partitions.
C. No data is exchanged between executors when coalesce() is run.
D. Short partition processing times are indicative of low skew.
E. The coalesce() method should be used to increase the number of partitions.
Which of the following describes a way for resizing a DataFrame from 16 to 8 partitions in the most efficient way?
A. Use operation DataFrame.repartition(8) to shuffle the DataFrame and reduce the number of partitions.
B. Use operation DataFrame.coalesce(8) to fully shuffle the DataFrame and reduce the number of partitions.
C. Use a narrow transformation to reduce the number of partitions.
D. Use a wide transformation to reduce the number of partitions.
E. Use operation DataFrame.coalesce(0.5) to halve the number of partitions in the DataFrame.
Which of the following code blocks reduces a DataFrame from 12 to 6 partitions and performs a full shuffle?
A. DataFrame.repartition(12)
B. DataFrame.coalesce(6).shuffle()
C. DataFrame.coalesce(6)
D. DataFrame.coalesce(6, shuffle=True)
E. DataFrame.repartition(6)
Which of the following code blocks returns a DataFrame where columns predError and productId are removed from DataFrame transactionsDf?
Sample of DataFrame transactionsDf:
1.+-------------+---------+-----+-------+---------+----+
2.|transactionId|predError|value|storeId|productId|f |
3.+-------------+---------+-----+-------+---------+----+
4.|1 |3 |4 |25 |1 |null|
5.|2 |6 |7 |2 |2 |null|
6.|3 |3 |null |25 |3 |null|
7.+-------------+---------+-----+-------+---------+----+
A. transactionsDf.withColumnRemoved("predError", "productId")
B. transactionsDf.drop(["predError", "productId", "associateId"])
C. transactionsDf.drop("predError", "productId", "associateId")
D. transactionsDf.dropColumns("predError", "productId", "associateId")
E. transactionsDf.drop(col("predError", "productId"))
Which of the following statements about data skew is incorrect?
A. Spark will not automatically optimize skew joins by default.
B. Broadcast joins are a viable way to increase join performance for skewed data over sort- merge joins.
C. In skewed DataFrames, the largest and the smallest partition consume very different amounts of memory.
D. To mitigate skew, Spark automatically disregards null values in keys when joining.
E. Salting can resolve data skew.
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"))
Which of the following describes characteristics of the Spark UI?
A. Via the Spark UI, workloads can be manually distributed across executors.
B. Via the Spark UI, stage execution speed can be modified.
C. The Scheduler tab shows how jobs that are run in parallel by multiple users are distributed across the cluster.
D. There is a place in the Spark UI that shows the property spark.executor.memory.
E. Some of the tabs in the Spark UI are named Jobs, Stages, Storage, DAGs, Executors, and SQL.