Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Sqoop-Hcatalog Table Creation Error- Parsing Exception

Sqoop-Hcatalog Table Creation Error- Parsing Exception

New Contributor

I'm in a process of importing data from sybase to hive using Sqoop. When use hive import everything worked fine but I need the data in orc format so I started using Hcatalog.

In Hcatalog the table is created as follows:

create external table default.val_deriv_orc (
deriv varchar ,
deriv_descr varchar )
stored as orcfile;

Using varchar is causing the following issue:

FAILED: ParseException line 2:13 mismatched input ',' expecting ( near 'char' in primitive type specification
18/02/07 16:25:13 INFO hcat.SqoopHCatUtilities: 18/02/07 16:25:13 ERROR ql.Driver: FAILED: ParseException line 2:13 mismatched input ',' expecting ( near 'char' in primitive type specification

Whereas, hive import used string type and everything worked fine!

I couldn't find any solution or possible clue so any help to resolve the issue would be appreciated. Thank you.

Rohith

2 REPLIES 2

Re: Sqoop-Hcatalog Table Creation Error- Parsing Exception

Expert Contributor

varchar requires length of the column to be mentioned in hive.

Can you try below query

create external table default.val_deriv_orc (deriv varchar(10), deriv_descr varchar(15))stored as orcfile;

if you are not sure about the max length of the column data, its better to use string datatype. varchar will automatically remove the column data more than specified length.

0: jdbc:hive2://localhost:10000> create external table default.val_deriv_orc (deriv varchar(4) ,deriv_descr varchar(5))stored as orcfile;

0: jdbc:hive2://localhost:10000> insert into default.val_deriv_orc values('abcdef','abcde');

0: jdbc:hive2://localhost:10000> select * from default.val_deriv_orc;
+----------------------+----------------------------+--+
| val_deriv_orc.deriv  | val_deriv_orc.deriv_descr  |
+----------------------+----------------------------+--+
| abcd                 | abcde                      |
+----------------------+----------------------------+--+

Re: Sqoop-Hcatalog Table Creation Error- Parsing Exception

New Contributor

Thanks for the response Naresh.

Sqoop is generating those queries when I'm using hive-import/hcatalog so I can't modify it. When using the hive-import sqoop is generating the string types and no issues with that. But when using hcatalog to create tables it is using varchar with no length and is failing to execute!

I found a work around to avoid using hcatalog but that's not the ideal way to implement. Any other thoughts would help!