



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




What is a Spark Driver? - ANSWER-The spark driver is the node in which the Spark application's main method runs to coordinate the Spark application. It contains the SparkContext object. Responsible for scheduling the execution of data by various worker nodes in cluster mode. What are worker nodes in cluster-mode Spark - ANSWER-Worker nodes are machines that host the executors responsible for the execution of tasks. What are slots? - ANSWER-Slots are resources for parallelization within a Spark application. What is a combination of a block of data and a set of transformers that runs on a single executor? - ANSWER-Task What is a group of tasks that can be executed in parallel to compute the same set of operations on potentially multiple machines? - ANSWER-Stage What is a shuffle? - ANSWER-A shuffle is the process by which data is compared across partitions. If you have a DF with more partitions than you have (single core) executors what happens? - ANSWER-Performance will be suboptimal because not all data can be processed at the same time. Shuffle commands will create a large number of connections. Increased overhead associated with managing resources for data processing for each task. Increased risk of out-of-memory errors depending on the size of executors. which of the following operations will trigger evaluation? A) df.filter() B) df.distinct() C) df.intersect() D) df.join() E) df.count() - ANSWER-E) df.count()
What is the difference between transformation and actions? - ANSWER- Transformations are business logic operations that do not induce executions while actions are execution triggers focused on returning results. Which of the following DF operations is always classified as a narrow transformation? A) df.sort() B) df.distinct() C) df.repartition() D) df.select() E) df.join() - ANSWER-D df.select() Spark has a few different execution/deployment modes: cluster, client, and local. What is a Spark execution/deployment mode? - ANSWER-Spark's execution/development mode determines where the driver and executors are physically stored when a Spark application is run. pass - ANSWER-pass What is an out-of-memory error in Spark? - ANSWER-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. Which of the following is the default storage level for persist() for a non-streaming dataframe/dataset? A) MEMORY_AND_DISK B) MEMORY_AND_DISK_SER C) DISK_ONLY D) MEMORY_ONLY_SER E) MEMORY_ONLY - ANSWER-A) MEMORY_AND_DISK What is a broadcast variable? - ANSWER-A broadcast variable is entirely cached on each worker node so it doesn't need to be shipped or shuffled between nodes within each stage. Which of the following operations is most likely to skew in size of your data's partitions? A) df.collect() B) df.cache() C) df.repartition(n) D) df.coalesce(n) E) df.persist() - ANSWER-D) df.coalesce(n) What data structures are Spark DataFrames built on top of? - ANSWER-RDDs (resilient distributed datasets)
The code block contains an error. The code block is intended to return a 15% sample of rows from DF 'storesDF' without replacement. Identify the error. storesDF.sample(True, fraction = .015) - ANSWER-The first argument True sets the sampling to be with replacement. 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) - ANSWER-B) DataFrame.take(n) The codeblock below contains an error. It is intended to return a DF containing only the rows from df "storesDF" where the value in col "sqft" is <= 25000. storesDF.filter(sqft <= 25000) - ANSWER-The column name sqft needs to be quoted and wrapped in the col() function like storesDF.filter(col("sqft") <= 25000). pass - ANSWER-pass Which operation is used to convert a DF column from one type to another? - ANSWER- col().cast() What is the code that returns a new DF with a new column 'sqft100' that is 1/100th of a column 'sqft' in a DF 'storesDF'. Note: col 'sqft1000' is not in the original DF. - ANSWER-storesDF.withColumn("sqft100", col("sqft") / 100) What is the code that returns a new DF from a DF 'storesDF' where column 'numberOfManagers' is the constant integer 1? - ANSWER- storesDF.withColumn("numberOfManagers", lit(1)) pass - ANSWER-pass 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() - ANSWER-C) explode() What code returns a new DataFrame where column "storeCategory" is an all-lowercase version of column "storeCategory" in DataFrame "storesDF". - ANSWER- storesDF.withColumn("storeCategory", lower(col("storeCategory")))
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: (storesDF.withColumnRenamed("state", "division") .withColumnRenamed("managerFullName", "managerName")) - ANSWER- The first argument to operation withColumnRenamed() should be the old column name and the second argument should be the new column name. What is the code that returns a DataFrame where rows in DataFrame "storesDF" containing missing values in every column have been dropped. - ANSWER- storesDF.na.drop("all") Which of the following operations fails to return a DataFrame where every row is unique? A) DataFrame.distinct() B) DataFrame.drop_duplicates(subset = None) C) DataFrame.drop_duplicates() D) DataFrame.dropDuplicates() E) DataFrame.drop_duplicates(subset = "all") - ANSWER-E) DataFrame.drop.duplicates(subset="all") The code block below should extract the value for column 'sqft' from the first row of DF 'storesDF'. Fill in the blanks. 1.2._3 - ANSWER-1) storesDF