|
CORRECT TEXT Problem Scenario 81 : You have been given MySQL DB with following details. You have been given following product.csv file product.csv productID,productCode,name,quantity,price 1001,PEN,Pen Red,5000,1.23 1002,PEN,Pen Blue,8000,1.25 1003,PEN,Pen Black,2000,1.25 1004,PEC,Pencil 2B,10000,0.48 1005,PEC,Pencil 2H,8000,0.49 1006,PEC,Pencil HB,0,9999.99 Now accomplish following activities. 1 . Create a Hive ORC table using SparkSql 2 . Load this data in Hive table. 3 . Create a Hive parquet table using SparkSQL and load data in it.
Answer: See the explanation for Step by Step Solution and configuration. Explanation: Solution : Step 1 : Create this tile in HDFS under following directory (Without header} /user/cloudera/he/exam/task1/productcsv Step 2 : Now using Spark-shell read the file as RDD // load the data into a new RDD val products = sc.textFile("/user/cloudera/he/exam/task1/product.csv") // Return the first element in this RDD prod u cts.fi rst() Step 3 : Now define the schema using a case> Problem Scenario 84 : In Continuation of previous question, please accomplish following activities. 1. Select all the products which has product code as null 2. Select all the products, whose name starts with Pen and results should be order by Price descending order.
IT Certification Guaranteed, The Easy Way!
3. Select all the products, whose name starts with Pen and results should be order by Price descending order and quantity ascending order. 4. Select top 2 products by price
Answer: See the explanation for Step by Step Solution and configuration. Explanation: Solution : Step 1 : Select all the products which has product code as null val results = sqlContext.sql(......SELECT' FROM products WHERE code IS NULL......) results. showQ val results = sqlContext.sql(......SELECT * FROM products WHERE code = NULL ",,M ) results.showQ Step 2 : Select all the products , whose name starts with Pen and results should be order by Price descending order. val results = sqlContext.sql(......SELECT * FROM products WHERE name LIKE 'Pen %' ORDER BY price DESC......) results. showQ Step 3 : Select all the products , whose name starts with Pen and results should be order by Price descending order and quantity ascending order. val results = sqlContext.sql('.....SELECT * FROM products WHERE name LIKE 'Pen %' ORDER BY price DESC, quantity......) results. showQ Step 4 : Select top 2 products by price val results = sqlContext.sql(......SELECT' FROM products ORDER BY price desc LIMIT2......} results. show()
|
|