Search code examples
mysqlhadoophadoop2bigdata

Import a mysql table (sqoop) directly in hive using --create-hive-table


I'm training myself for the HDPCD exam, so I'm testing all possible import and exports using MySQL to Hive. In this example, I would like to import a table from MySQL and create from scratch the same table in hive using the parameter --create-hive-table. Although in the [documentation][1] it's included I have found a right example to do it. I have tried this but it doesn't work

sqoop import --connect jdbc:mysql://master/poc --username root --table dept --where 'id_dept > 2' --hive-import --hive-database poc --hive-table deptv2 --create-hive-table true -m 1 --split-by id_dept

Please, guys if someone of you knows how to use it let me know it. I appreciate thanks so much


Solution

  • I'm back cause I have just to try again just putting the parameter without any input and it worked that's it. Anyways I'll leave an example. Probably it's going to help someone.

    sqoop import --connect jdbc:mysql://master/poc --username root \
      --table dept --where 'id_dept > 2' --hive-import \
      --hive-database poc --hive-table deptv2 --create-hive-table -m 1 --split-by id_dept
    

    Thanks.