Saket Mankar
Saket Mankar

Reputation: 25

Date type column is getting decremented on sqoop import by 2 days from SQL server to Hive

I have one table in the database where insertdate is of 'Date' type. However, when I import the table into hive using sqoop values in hive tables are getting decremented.

Example

RDBMS --> insertdate='2013-04-01'

Hive --> insertdate='2013-03-30'

I have used below command to import data:

sqoop import --connect 'jdbc:sqlserver://localhost;username=XXXXX;password=XXXXXXX;database=XXXXXXXXXX'--table tbl_name \
 --warehouse-dir /user/hive/warehouse --m 1 \
 --hive-import --hive-database db_name --hive-overwrite --null-string '\\N' --null-non-string '\\N' --hive-drop-import-delims

Upvotes: 2

Views: 757

Answers (3)

Tutu Kumari
Tutu Kumari

Reputation: 503

Solved in mysql by using parameter : -D mapreduce.map.java.opts=" -Duser.timezone=GMT"

sqoop import -D mapreduce.map.java.opts=" -Duser.timezone=GMT" \

--connect jdbc:mysql://hostname/location \

--username name -P \

--table VW_Location_History_For_Hadoop \

--target-dir /apps/hive/warehouse/test.db/location_h \

--hive-table test.location_hierarchy \

--fields-terminated-by "," \

--hive-import \

--delete-target-dir \

--m 1

Upvotes: 0

Priya.A
Priya.A

Reputation: 1

Its working after adding sqljdbc41.jar.

Upvotes: 0

Dev
Dev

Reputation: 13753

The problem is not with Sqoop, it is with the JDBC driver of SQL Server.

Check related question - dates consistently two days off

I think you are putting sqljdbc4.jar in /sqoop/lib.

Use sqljdbc41.jar or newer to fix this.

(sqljdbc41.jar is compiled with Java 7)

Upvotes: 1

Related Questions