Free CCA175 Exam Braindumps (page: 7)

Page 6 of 25

Problem Scenario 85 : In Continuation of previous question, please accomplish following activities.

1. Select all the columns from product table with output header as below. productID AS ID
code AS Code name AS Description price AS 'Unit Price'
2. Select code and name both separated by ' -' and header name should be Product
Description'.
3. Select all distinct prices.
4. Select distinct price and name combination.
5. Select all price data sorted by both code and productID combination.
6. count number of products.
7. Count number of products for each code.

  1. See the explanation for Step by Step Solution and configuration.

Answer(s): A

Explanation:

Solution :
Step 1: Select all the columns from product table with output header as below. productID AS ID code AS Code name AS Description price AS "Unit Price' val results = sqlContext.sql(......SELECT productID AS ID, code AS Code, name AS Description, price AS Unit Price' FROM products ORDER BY ID""" results.show()
Step 2: Select code and name both separated by ' -' and header name should be "Product Description.
val results = sqlContext.sql(......SELECT CONCAT(code, ' -', name) AS Product Description, price FROM products""" )
results.showQ
Step 3: Select all distinct prices.
val results = sqlContext.sql(......SELECT DISTINCT price AS Distinct Price" FROM products......)
results.show()
Step 4: Select distinct price and name combination. val results = sqlContext.sql(......SELECT DISTINCT price, name FROM products""" ) results. showQ
Step 5: Select all price data sorted by both code and productID combination. val results = sqlContext.sql('.....SELECT' FROM products ORDER BY code, productID'.....) results.show()
Step 6: count number of products.
val results = sqlContext.sql(......SELECT COUNT(') AS 'Count' FROM products......) results.show()
Step 7: Count number of products for each code.
val results = sqlContext.sql(......SELECT code, COUNT('} FROM products GROUP BY code......)
results. showQ
val results = sqlContext.sql(......SELECT code, COUNT('} AS count FROM products GROUP BY code ORDER BY count DESC......)
results. showQ



Problem Scenario 18 : You have been given following mysql database details as well as other info.
user=retail_dba
password=cloudera
database=retail_db
jdbc URL = jdbc:mysql://quickstart:3306/retail_db
Now accomplish following activities.

1. Create mysql table as below.
mysql --user=retail_dba -password=cloudera
use retail_db
CREATE TABLE IF NOT EXISTS departments_hive02(id int, department_name
varchar(45), avg_salary int);
show tables;
2. Now export data from hive table departments_hive01 in departments_hive02. While
exporting, please note following. wherever there is a empty string it should be loaded as a
null value in mysql.
wherever there is -999 value for int field, it should be created as null value.

  1. See the explanation for Step by Step Solution and configuration.

Answer(s): A

Explanation:

Solution :
Step 1: Create table in mysql db as well.
mysql ~user=retail_dba -password=cloudera
use retail_db
CREATE TABLE IF NOT EXISTS departments_hive02(id int, department_name varchar(45), avg_salary int);
show tables;
Step 2: Now export data from hive table to mysql table as per the requirement. sqoop export --connect jdbc:mysql://quickstart:3306/retail_db \ -username retaildba \
-password cloudera \
--table departments_hive02 \
-export-dir /user/hive/warehouse/departments_hive01 \ -input-fields-terminated-by '\001' \
--input-Iines-terminated-by '\n' \
--num-mappers 1 \
-batch \
-Input-null-string "" \
-input-null-non-string -999
Step 3: Now validate the data, select * from departments_hive02;



CORRECT TEXT
Problem Scenario 10 : You have been given following mysql database details as well as other info.
user=retail_dba
password=cloudera
database=retail_db
jdbc URL = jdbc:mysql://quickstart:3306/retail_db
Please accomplish following.

1. Create a database named hadoopexam and then create a table named departments in
it, with following fields. department_id int,
department_name string
For e.g. location should be
hdfs://quickstart.cloudera:8020/user/hive/warehouse/hadoopexam.db/departments
2. Please import data in existing table created above from retaidb.departments into hive
table hadoopexam.departments.
3. Please import data in a non-existing table, means while importing create hive table
named hadoopexam.departments_new

  1. See the explanation for Step by Step Solution and configuration.

Answer(s): A

Explanation:

Solution:
Step 1: Go to hive interface and create database.
hive
create database hadoopexam;

Step 2: Use the database created in above step and then create table in it. use hadoopexam; show tables;
Step 3: Create table in it.
create table departments (department_id int, department_name string); show tables;
desc departments;
desc formatted departments;
Step 4: Please check following directory must not exist else it will give error, hdfs dfs -Is /user/cloudera/departments
If directory already exists, make sure it is not useful and than delete the same. This is the staging directory where Sqoop store the intermediate data before pushing in hive table.
hadoop fs -rm -R departments
Step 5: Now import data in existing table
sqoop import \
-connect jdbc:mysql://quickstart:3306/retail_db \
~username=retail_dba \
-password=cloudera \
--table departments \
-hive-home /user/hive/warehouse \
-hive-import \
-hive-overwrite \
-hive-table hadoopexam.departments
Step 6: Check whether data has been loaded or not.
hive;
use hadoopexam;
show tables;
select" from departments;
desc formatted departments;
Step 7: Import data in non-existing tables in hive and create table while importing.
sqoop import \
-connect jdbc:mysql://quickstart:3306/retail_db \
--username=retail_dba \
~password=cloudera \
-table departments \
-hive-home /user/hive/warehouse \
-hive-import \
-hive-overwrite \
-hive-table hadoopexam.departments_new \
-create-hive-table
Step 8: Check-whether data has been loaded or not.
hive;
use hadoopexam;
show tables;
select" from departments_new;
desc formatted departments_new;



Problem Scenario 64 : You have been given below code snippet.
val a = sc.parallelize(List("dog", "salmon", "salmon", "rat", "elephant"), 3)
val b = a.keyBy(_.length)
val c = sc.parallelize(Ust("dog", "cat", "gnu", "salmon", "rabbit", "turkey", "wolf", "bear", "bee"), 3)
val d = c.keyBy(_.length)
operation1
Write a correct code snippet for operationl which will produce desired output, shown below.
Array[(lnt, (Option[String], String))] = Array((6, (Some(salmon), salmon)), (6, (Some(salmon), rabbit}}, (6, (Some(salmon), turkey)), (6, (Some(salmon), salmon)), (6, (Some(salmon), rabbit)), (6, (Some(salmon), turkey)), (3, (Some(dog), dog)), (3, (Some(dog), cat)), (3, (Some(dog), gnu)), (3, (Some(dog), bee)), (3, (Some(rat), (3, (Some(rat), cat)), (3, (Some(rat), gnu)), (3, (Some(rat), bee)), (4, (None, wo!f)), (4, (None, bear)))

  1. See the explanation for Step by Step Solution and configuration.

Answer(s): A

Explanation:

Solution : b.rightOuterJqin(d).collect
rightOuterJoin [Pair] : Performs an right outer join using two key-value RDDs. Please note that the keys must be generally comparable to make this work correctly.






Post your Comments and Discuss Cloudera CCA175 exam with other Community members:

CCA175 Exam Discussions & Posts