182.Sqoop Import – Specifying Columns

  • To get schema details on customers table:
    • sqoop eval --connect jdbc:mysql://ms.itversity.com:3306/ retail_db --username retail_user --password itversity -e "DESCRIBE customers"
  • Command to import table with specified columns:
    • sqoop import --connect jdbc:mysql://ms.itversity.com:3306/retail_db --username retail_user --password itversity --table customers --columns customer_id,customer_fname,customer_lname,customer_street,customer_city,customer_state,customer_zipcode --warehouse-dir /user/training/sqoop_import/retail_db --delete-target-dir
  • To validate imported table:
    • hadoop fs -ls /user/training/sqoop_import/retail_db
    • hadoop fs -ls /user/training/sqoop_import/retail_db/customers
    • hadoop fs -tail /user/training/sqoop_import/retail_db/customers/part-m-00003

Share this post