Forum

This topic contains 0 replies, has 1 voice, and was last updated by  Avikumar 2 years, 3 months ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #1283 Reply

    Avikumar
    Participant

    Sqoop – Job:-
    syntax
    The following is the syntax for creating a Sqoop job.
    $ sqoop job (generic-args) (job-args)
    [– [subtool-name] (subtool-args)]
    $ sqoop-job (generic-args) (job-args)
    [– [subtool-name] (subtool-args)]

    Create Job (–create):-

    Here we are creating a job with the name myjob, which can import the table data from RDBMS table to HDFS. The following command is used to create a job that is importing data from the employee table in the db database to the HDFS file.
    $ sqoop job –create myjob \
    –import \
    –connect jdbc:mysql://localhost/db \
    –username root \
    –table employee –m 1
    Verify Job (–list)
    ‘–list’ argument is used to verify the saved jobs. The following command is used to verify the list of saved Sqoop jobs.

    $ sqoop job –list
    It shows the list of saved jobs.

    Available jobs:
    myjob
    Inspect Job (–show)
    $ sqoop job –show myjob

    Execute Job (–exec):-
    ‘–exec’ option is used to execute a saved job. The following command is used to execute a saved job called myjob.
    $ sqoop job –exec myjob

    Sqoop – Codegen:-
    Syntax
    The following is the syntax for Sqoop codegen command.
    $ sqoop codegen (generic-args) (codegen-args)
    $ sqoop-codegen (generic-args) (codegen-args)

    Verification
    Let us take a look at the output. The path, which is in bold, is the location that the Java code of the emp table generates and stores. Let us verify the files in that location using the following commands.
    $ cd /tmp/sqoop-hadoop/compile/9a300a1f94899df4a9b10f9935ed9f91/
    $ ls
    emp.class
    emp.jar
    emp.java

    Sqoop – Eval:-
    Syntax
    The following syntax is used for Sqoop eval command.
    $ sqoop eval (generic-args) (eval-args)
    $ sqoop-eval (generic-args) (eval-args)

    Select Query Evaluation:-
    Using eval tool, we can evaluate any type of SQL query. Let us take an example of selecting limited rows in the employee table of db database. The following command is used to evaluate the given example using SQL query.
    $ sqoop eval \
    –connect jdbc:mysql://localhost/db \
    –username root \
    –query “SELECT * FROM employee LIMIT 3”

    Insert Query Evaluation:-
    Sqoop eval tool can be applicable for both modeling and defining the SQL statements. That means, we can use eval for insert statements too. The following command is used to insert a new row in the employee table of db database.
    $ sqoop eval \
    –connect jdbc:mysql://localhost/db \
    –username root \
    -e “INSERT INTO employee VALUES(1207,‘Raju’,‘UI dev’,15000,‘TP’)”
    mysql>
    mysql> use db;
    mysql> SELECT * FROM employee;

Viewing 1 post (of 1 total)
Reply To: Sqoop – Job
Your information:




cf22

Your Name (required)

Your Email (required)

Subject

Phone No

Your Message

Cart

  • No products in the cart.