This topic provides answers to some frequently asked questions about Sqoop.
What do I do if the time specified by a timestamp field is eight hours earlier than the original time when I import data from ApsaraDB RDS into E-MapReduce (EMR)?
Description
The test_table table in ApsaraDB RDS contains a timestamp field.
The following command is used to import data from the test_table table to EMR HDFS:
sqoop import \ --connect jdbc:mysql://rm-2ze****341.mysql.rds.aliyuncs.com:3306/s***o_sqoop_db \ --username s***o \ --password ****** \ --table test_table \ --target-dir /user/hadoop/output \ --delete-target-dir \ --direct \ --split-by id \ --fields-terminated-by '|' \ -m 1
The import result is queried.
In the query result, the time specified by the timestamp field is eight hours earlier than the original time.
Solution: When you import the data, delete the --direct parameter from the import command.
sqoop import \ --connect jdbc:mysql://rm-2ze****341.mysql.rds.aliyuncs.com:3306/s***o_sqoop_db \ --username s***o \ --password ****** \ --table test_table \ --target-dir /user/hadoop/output \ --delete-target-dir \ --split-by id \ --fields-terminated-by '|' \ -m 1
The query result is normal.