Valid CCA175 Dumps shared by EduDump.com for Helping Passing CCA175 Exam! EduDump.com now offer the newest CCA175 exam dumps, the EduDump.com CCA175 exam questions have been updated and answers have been corrected get the newest EduDump.com CCA175 dumps with Test Engine here:
CORRECT TEXT Problem Scenario 87 : You have been given below three files product.csv (Create this file in hdfs) productID,productCode,name,quantity,price,supplierid 1 001,PEN,Pen Red,5000,1.23,501 1 002,PEN,Pen Blue,8000,1.25,501 1003,PEN,Pen Black,2000,1.25,501 1004,PEC,Pencil 2B,10000,0.48,502 1005,PEC,Pencil 2H,8000,0.49,502 1006,PEC,Pencil HB,0,9999.99,502 2001,PEC,Pencil 3B,500,0.52,501 2002,PEC,Pencil 4B,200,0.62,501 2003,PEC,Pencil 5B,100,0.73,501 2004,PEC,Pencil 6B,500,0.47,502 supplier.csv supplierid,name,phone 501,ABC Traders,88881111 502,XYZ Company,88882222 503,QQ Corp,88883333 products_suppliers.csv productID,supplierID 2001,501 2002,501 2003,501 2004,502 2001,503 Now accomplish all the queries given in solution. Select product, its price , its supplier name where product price is less than 0.6 using SparkSQL
Correct Answer:
See the explanation for Step by Step Solution and configuration. Explanation: Solution : Step 1: hdfs dfs -mkdir sparksql2 hdfs dfs -put product.csv sparksq!2/ hdfs dfs -put supplier.csv sparksql2/ hdfs dfs -put products_suppliers.csv sparksql2/ Step 2 : Now in spark shell // this Is used to Implicitly convert an RDD to a DataFrame. import sqlContext.impIicits._ // Import Spark SQL data types and Row. import org.apache.spark.sql._ // load the data into a new RDD val products = sc.textFile("sparksql2/product.csv") val supplier = sc.textFileC'sparksq^supplier.csv") val prdsup = sc.textFile("sparksql2/products_suppliers.csv"} // Return the first element in this RDD products.fi rst() supplier.first{). prdsup.first() //define the schema using a case class case class Product(productid: Integer, code: String, name: String, quantity:lnteger, price: Float, supplierid:lnteger) case class Suplier(supplierid: Integer, name: String, phone: String) case class PRDSUP(productid: Integer.supplierid: Integer) // create an RDD of Product objects val prdRDD = products.map(_.split('\")).map(p => Product(p(0).tolnt,p(1),p(2),p(3).tolnt,p(4).toFloat,p(5).toint)) val supRDD = supplier.map(_.split(",")).map(p => Suplier(p(0).tolnt,p(1),p(2))) val prdsupRDD = prdsup.map(_.split(",")).map(p => PRDSUP(p(0).tolnt,p(1}.tolnt}} prdRDD.first() prdRDD.count() supRDD.first() supRDD.count() prdsupRDD.first() prdsupRDD.count(} // change RDD of Product objects to a DataFrame val prdDF = prdRDD.toDF() val supDF = supRDD.toDF() val prdsupDF = prdsupRDD.toDF() // register the DataFrame as a temp table prdDF.registerTempTablef'products") supDF.registerTempTablef'suppliers") prdsupDF.registerTempTablef'productssuppliers"} //Select product, its price , its supplier name where product price is less than 0.6 val results = sqlContext.sql(......SELECT products.name, price, suppliers.name as sup_name FROM products JOIN suppliers ON products.supplierlD= suppliers.supplierlD WHERE price < 0.6......] results. show()