Sqooping from/to MYSQL and HDFS

Sqooping from/to MYSQL and HDFS

Sqoop Import
From MYSQL table to HDFS

sqoop import --connect jdbc:mysql://127.0.0.1/export --username root --driver com.mysql.jdbc.Driver --table exported --target-dir '/user/horton/exported' -m 1

From MYSQL table to Hive

sqoop import --hive-import --connect jdbc:mysql://127.0.0.1/export --username root --driver com.mysql.jdbc.Driver --table exported --hive-table test.exported3 -m 1

From MYSQL table to Hive schema defined.

sqoop import --hive-import --connect jdbc:mysql://127.0.0.1/export --username root --driver com.mysql.jdbc.Driver --table exported --hive-table test.exported3 -m 1 --map-column-hive 'row_key=int,value=string,ts=timestamp';

From MYSQL table to Hive with delimiters

sqoop import --hive-import --connect jdbc:mysql://127.0.0.1/export --username root --driver com.mysql.jdbc.Driver --table exported --hive-table test.exported2 -m 1 --fields-terminated-by ','

Free form query import

sqoop import --connect jdbc:mysql://127.0.0.1/export --username root --driver com.mysql.jdbc.Driver --query 'select * from exported where $CONDITIONS' --target-dir '/user/horton/test_query' -m 1

Incremental import into HDFS

sqoop import --connect jdbc:mysql://127.0.0.1/export --username root --driver com.mysql.jdbc.Driver --table exported --target-dir '/user/horton/test_incremental' -m 1 --check-column ts --incremental lastmodified --last-value '2017-01-24 23:11:16.0' -merge-key row_key

Incremental import into Hive

sqoop import --hive-import --connect jdbc:mysql://127.0.0.1/export --username hive --password hive --driver com.mysql.jdbc.Driver --table exported --hive-table test.exported1 -m 1 --check-column ts --incremental lastmodified --last-value '2017-01-24 23:11:10.0' -merge-key row_key

Incremental import into HDFS from Query

sqoop import --connect jdbc:mysql://127.0.0.1/export --username root --driver com.mysql.jdbc.Driver --query 'select * from exported where $CONDITIONS' --target-dir '/user/horton/test_incremental/t2' -m 1 --check-column ts --incremental lastmodified --last-value '2017-01-24 23:11:16.0' -merge-key row_key

Incremental import into Hive from Query is not supported.
Sqoop Export
Insert/export from HDFS

sqoop export --connect jdbc:mysql://127.0.0.1/export --username root --driver com.mysql.jdbc.Driver --table exported --export-dir /apps/hive/warehouse/test.db/exported1  -m 1 --input-fields-terminated-by '\001'

Insert/export from Hive

sqoop export --connect jdbc:mysql://127.0.0.1/export --username root --driver com.mysql.jdbc.Driver --table exported --hcatalog-database test --hcatalog-table exported3 --input-fields-terminated-by '\001' -m 1

Update from HDFS

sqoop export --connect jdbc:mysql://127.0.0.1/export --username root --driver com.mysql.jdbc.Driver --table exported --export-dir /apps/hive/warehouse/test.db/exported1  -m 1 --update-key row_key --input-fields-terminated-by '\001'

Using Hcatalog

sqoop export --connect jdbc:mysql://127.0.0.1/export --username root --driver com.mysql.jdbc.Driver --table exported --hcatalog-database test --hcatalog-table exported -m 1

Update from Hive using Hcatalog is not supported yet. Getting Java exception and there are open tickets on it.

5 comments:

  1. We provide Google Professional-Data-Engineer Exam Questions in two formats PDF & Practice Software. Try free demo of Professional-Data-EngineerExam products. Money Back Guarantee

    ReplyDelete
  2. It is pleasure to share my experience with Professional-Data-Engineer Dumps and to inform you about the usefulness of this study material during my preparation. I did not go anywhere else for studies and focused on the stuff provided in Professional-Data-Engineer Dumps PDF and aced my IT exam with reasonable marks.

    ReplyDelete
  3. I am thankful to Exam4Lead for assisting me during my preparation and I cannot forget the king disposition of experts. The wording of questions and answers was so simple and captivating in Google Professional-Data-Engineer dumps. There was nothing confusing in this handy study stuff. I will strongly suggest to all IT candidates of this certification to use Google Professional-Data-Engineer dumps.

    ReplyDelete
  4. Thank you for the good post. I Successfully cleared my Google Professional Data Engineer exam. I found a site with more than 500 real exam questions for Google Professional Data Engineer helped me to clear the exam with 95%. Skillcertpro ! Good dumps for anyone who is looking to clear the exam.

    ReplyDelete
  5. Many thanks for sharing such kind of info. It is actually not easy to meet the difficulties to Pass your Google Professional-Data-Engineer Exam Dumps, but if you have valid study material like Real Google Exam Questions. No doubt will pending to be successful.
    Hence its only need to get an authentic study material to prepare any of your exam, than nobody can stop you to be successful in your field. Only Valid Google Exam Dumps can be the cause of your success.
    For More Details:-
    https://dumpstoday.com/

    ReplyDelete