Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]
Created on
02-22-2019
10:41 AM
- last edited on
04-21-2026
04:38 AM
by
GrazittiAPI
I want to store data in hdfs as parquet file and then create an external table over it as parquet.
i used sqoop command to pull data from Oracle into hdfs.Column4 is date field in Oracle table so i want to store it as timestamp in hive.When i ran select * from table in hue i got the error below.
Please help , looks like data type issue because of column 4 .If i import only first 3 fields (string) from oracle to hdfs and create hive table using first 3 columns then it is working fine. Issue came once i added column4.
Step1 :
CREATE external TABLE IF NOT EXISTS `abc`
(
column1 STRING,
column2 STRING,
column3 STRING
column4 TIMESTAMP
)
STORED AS PARQUET
LOCATION '/data/encrypt/abc';
Step 2:
sqoop import --connect *** --username *** --password ****** --query 'select column1,column2,column3,column4 from abc where $CONDITIONS' --split-by column1 --delete-target-dir --target-dir /data/encrypt/abc --compression-codec org.apache.hadoop.io.compress.SnappyCodec --as-parquetfile
Hue :
select * from abc;
Error:
Created 02-22-2019 04:37 PM
Yes, try ORACLE TO_TIMESTAMP() format if needed
Created 02-22-2019 12:15 PM
Created 02-22-2019 12:27 PM
date is stored as a DATE datatype in oracle. I tried to create column4 as String in hive external table then also i got same error. But i want to store it as TIMESTAMP.
How can i achieve this ? - you'll need to convert it during import if you want a Hive TIMESTAMP field
like i want to store other datatype number (oracle) as integer in both hdfs and hive?
Created 02-22-2019 01:41 PM
I tried to import as Timestamp but got this error for both Timestamp and java.sql.Timestamp
--map-column-java Column4=Timestamp
--map-column-java Column4=java.sql.Timestamp
ERROR tool.ImportTool: Import failed: No ResultSet method for Java type Timestamp
ERROR tool.ImportTool: Import failed: Cannot convert to AVRO type java.sql.Timestamp
Created 02-22-2019 02:10 PM
Created 02-22-2019 04:20 PM
It worked but i can see NULL values in column4 in hive table. May be format issue ?
Created 02-22-2019 04:37 PM
Yes, try ORACLE TO_TIMESTAMP() format if needed