All Products
Search
Document Center

E-MapReduce:FAQ about Sqoop

Last Updated:Jun 19, 2024

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

    1. The test_table table in ApsaraDB RDS contains a timestamp field.image

    2. 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
    3. The import result is queried.

      In the query result, the time specified by the timestamp field is eight hours earlier than the original time.image

  • 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.image