如何确保使用 sqoop 导入的数据在配置单元中遵循与 mysql table 中相同的行顺序

how to make sure the data imported using sqoop follows the same row order in hive as in mysql table

如何确保使用 sqoop 导入的数据在 hive 中遵循与在 mysql table 中相同的行顺序?

mysql> select * from customer; +------+--------+------+--------+ | id | name | age | salary | +------+--------+------+--------+ | 1 | John | 30 | 80000 | | 2 | Kevin | 33 | 84000 | | 3 | Mark | 28 | 90000 | | 4 | Jenna | 34 | 93000 | | 5 | Robert | 32 | 100000 | | 6 | Zoya | 40 | 60000 | | 7 | Sam | 37 | 75000 | | 8 | George | 31 | 67000 | | 9 | Peter | 23 | 70000 | | 19 | Alex | 26 | 74000 | +------+--------+------+-----

我想要 table 导入后。它在配置单元中也遵循相同的顺序。

在使用 Apache Sqoop 将 table 导入配置单元时,默认情况下它的顺序相同,但为了确保,您可以做一件事,如果您的 MySQL table 具有主键,然后使用相同的架构和主键手动创建配置单元 table 并编写不带 --create-hive-table 参数的导入语句。

这样可以确保数据的顺序与 MySQL table

相同