Sqoop is a tool that helps transfer data between Hadoop and relational databases. It is mainly used to import data from databases into Hadoop's HDFS and export data back.
Click to reveal answer
beginner
Which command imports a full table from a database into HDFS using Sqoop?
The command is <code>sqoop import --connect <jdbc-connection-string> --table <table-name> --username <user> --password <password> --target-dir <hdfs-directory></code>. This imports the entire table into the specified HDFS directory.
Click to reveal answer
intermediate
What does the --split-by option do in Sqoop import?
The <code>--split-by</code> option tells Sqoop which column to use to split the data for parallel import. This helps speed up the import by dividing the work across multiple mappers.
Click to reveal answer
intermediate
How can you import only specific columns from a database table using Sqoop?
Use the --columns option with a comma-separated list of column names. For example, --columns "id,name,age" imports only those columns.
Click to reveal answer
intermediate
What is the role of the --where clause in Sqoop import?
The <code>--where</code> clause lets you filter rows during import by specifying a SQL condition. For example, <code>--where "age > 30"</code> imports only rows where age is greater than 30.
Click to reveal answer
What does Sqoop primarily do?
AProcesses big data inside Hadoop
BTransfers data between Hadoop and relational databases
CVisualizes data in Hadoop
DManages Hadoop cluster nodes
✗ Incorrect
Sqoop is designed to transfer data between Hadoop and relational databases.
Which option specifies the database table to import in Sqoop?
A--table
B--connect
C--target-dir
D--split-by
✗ Incorrect
The --table option tells Sqoop which database table to import.
How does Sqoop speed up data import?
ABy using multiple mappers with --split-by
BBy compressing data
CBy importing only metadata
DBy exporting data instead
✗ Incorrect
Sqoop uses multiple mappers and the --split-by option to parallelize data import.
Which option filters rows during import?
A--columns
B--username
C--where
D--target-dir
✗ Incorrect
The --where option applies a SQL condition to filter rows during import.
To import only specific columns, which option do you use?
A--table
B--split-by
C--connect
D--columns
✗ Incorrect
The --columns option lets you specify which columns to import.
Explain how Sqoop imports data from a relational database into Hadoop.
Think about the steps and options needed to move data from a database to Hadoop.
You got /5 concepts.
Describe how you can control which data Sqoop imports from a database table.
Consider options that limit or organize the data imported.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of Sqoop in Hadoop?
easy
A. To process data inside Hadoop using MapReduce
B. To export data from Hadoop to relational databases
C. To import data from relational databases into Hadoop
D. To visualize data stored in Hadoop
Solution
Step 1: Understand Sqoop's role
Sqoop is designed to transfer data between relational databases and Hadoop.
Step 2: Identify import function
Its main use is importing data from databases into Hadoop's storage.
Final Answer:
To import data from relational databases into Hadoop -> Option C
Quick Check:
Sqoop imports data = A [OK]
Hint: Remember Sqoop imports data into Hadoop from databases [OK]
Common Mistakes:
Confusing import with export
Thinking Sqoop processes data inside Hadoop
Assuming Sqoop is for visualization
2. Which of the following is the correct basic Sqoop import command syntax?
easy
A. sqoop export --connect jdbc:mysql://localhost/db --table mytable --target-dir /user/hadoop/mytable
B. sqoop import --connect jdbc:mysql://localhost/db --table mytable --target-dir /user/hadoop/mytable
C. sqoop import --table mytable --connect jdbc:mysql://localhost/db --output-dir /user/hadoop/mytable
D. sqoop import --connect jdbc:mysql://localhost/db --table mytable --output-dir /user/hadoop/mytable
Solution
Step 1: Identify correct command type
Import commands use 'sqoop import' with connection, table, and target directory.
The command uses --num-mappers 4 but does not specify --split-by column.
Step 2: Understand parallel import requirements
Sqoop requires a --split-by column to divide data for multiple mappers; missing it causes error.
Final Answer:
Missing --split-by column for parallel import -> Option A
Quick Check:
Parallel import needs --split-by column [OK]
Hint: Always specify --split-by when using multiple mappers [OK]
Common Mistakes:
Assuming --num-mappers works without --split-by
Thinking --target-dir format causes error
Ignoring table existence check
5. You want to import a large 'orders' table from MySQL into Hadoop quickly. The table has a numeric primary key 'order_id'. Which Sqoop command will best speed up the import?