Assume you are given data with the following columns. Index Column…
Question Answered step-by-step Assume you are given data with the following columns. Index Column… Assume you are given data with the following columns. IndexColumn NamePossible values0IDcontinuous1Hairtrue, false2Number_legsContinuous3Milktrue, false4Wingstrue, false5WeightContinuous6Typemammal, amphibian, bird, invertebrates, fish, reptiles7AgeContinuous You will answer the questions either using the Spark RDD API or Spark SQL dataframes/datasets. Please complete the question using spark RDDs for the questions marked as [Spark RDD], please complete the questions using dataframes/datasets for questions marked as [Spark SQL]. When you program Spark SQL you must use the dataset/dataframe operations instead of SQL syntax. Example using dataset/dataframe operations syntax: df.filter($”age” > 21).show() df.select($”ID”, $”age” + 1).show() Do not use SQL syntax like this: val sqlDF = spark.sql(“SELECT * FROM animals”) sqlDF.show() For Spark RDD questions assume you have been given the code below. val lines = sc.textFile(“animals.txt”) // assume all the columns are separated by “, “val split_lines = lines.map(_.split(“, “)) For Spark SQL questions assume you have been given the code below. case class Animal(ID: Int, Hair: Boolean, Number_legs: Int, Milk: Boolean, Wings: Boolean, Weight: Float, Type: String, Age: Int)val df = spark.read.schema(Encoders.product[Animal].schema).option(“delimiter”, ” “).csv(“animals.txt”).as[Animal] You can find some useful Spark RDD functions by pressing this link:https://lms.latrobe.edu.au/mod/page/view.php?id=5358303 You can find some useful Spark SQL APIs by pressing this link:https://lms.latrobe.edu.au/mod/page/view.php?id=5358267 Write spark code to do the following. Your solution can consist of one or more lines of Spark code. You do not need to make the output format look good. Marks will be awarded for more efficient code. For example, code that results in less data shuffles. [Spark RDD] Output the percentage of animals with 4 legs that are mammals. That is, among all animals with 4 legs what percentage are mammals? Engineering & Technology Computer Science CSE 3BDC Share QuestionEmailCopy link Comments (0)


