|
|
-
Parse Error with '-' in Hive
Alex Barrera 2012-05-31, 15:35
Hi there,
I'm looking for help with the following error: I keep receiving an error 'Parse Error: line 40:4 cannot recognize input near '-' 'Platform' STRING column type. '
It looks to be a problem with my JSON deserializer OR Hive not recognizing the - in the field names. So far I've tried commenting it out with / and //, and tried wrapping single and double quotes around the field name. Nothing has worked so far.
My code looks like this: add jar s3://sa/hive-json-serde-0.3.jar; DROP TABLE IF EXISTS viewstream; CREATE EXTERNAL TABLE IF NOT EXISTS viewstream( cl STRING, pid STRING, vp STRING, ar STRING, UArm STRING, dc STRING, host STRING, Blocked STRING, UA-Platform STRING, UA-Browser STRING, UA-Version STRING, UA-Language STRING )
ROW FORMAT SERDE 'org.apache.hadoop.hive.contrib.serde2.JsonSerde' LOCATION 'hdfs:///repo/viewstream/';
Anybody run into similar errors? I can't find anything on this problem online, strangely enough.
Thanks all, Alex
-
Re: Parse Error with '-' in Hive
alo alt 2012-05-31, 15:40
Hi, try to use _ instead - UA_Platform STRING, and so on. - Alex -- Alexander Alten-Lorenz http://mapredit.blogspot.comGerman Hadoop LinkedIn Group: http://goo.gl/N8pCFOn May 31, 2012, at 5:35 PM, Alex Barrera wrote: > Hi there, > > I'm looking for help with the following error: I keep receiving an error > 'Parse Error: line 40:4 cannot recognize input near '-' 'Platform' STRING > column type. ' > > It looks to be a problem with my JSON deserializer OR Hive not recognizing > the - in the field names. So far I've tried commenting it out with / and > //, and tried wrapping single and double quotes around the field name. > Nothing has worked so far. > > My code looks like this: > add jar s3://sa/hive-json-serde-0.3.jar; > DROP TABLE IF EXISTS viewstream; > CREATE EXTERNAL TABLE IF NOT EXISTS viewstream( > cl STRING, > pid STRING, > vp STRING, > ar STRING, > UArm STRING, > dc STRING, > host STRING, > Blocked STRING, > UA-Platform STRING, > UA-Browser STRING, > UA-Version STRING, > UA-Language STRING > ) > > ROW FORMAT SERDE 'org.apache.hadoop.hive.contrib.serde2.JsonSerde' > LOCATION 'hdfs:///repo/viewstream/'; > > Anybody run into similar errors? I can't find anything on this problem > online, strangely enough. > > Thanks all, > Alex
-
Re: Parse Error with '-' in Hive
Edward Capriolo 2012-05-31, 16:00
I never use - for variable names or object names. Makes trouble for ORM tools package names etc etc. _ is your friend. I believe the correct escape here is backtick `. But you might be out of luck.
On 5/31/12, Alex Barrera <[EMAIL PROTECTED]> wrote: > Hi there, > > I'm looking for help with the following error: I keep receiving an error > 'Parse Error: line 40:4 cannot recognize input near '-' 'Platform' STRING > column type. ' > > It looks to be a problem with my JSON deserializer OR Hive not recognizing > the - in the field names. So far I've tried commenting it out with / and > //, and tried wrapping single and double quotes around the field name. > Nothing has worked so far. > > My code looks like this: > add jar s3://sa/hive-json-serde-0.3.jar; > DROP TABLE IF EXISTS viewstream; > CREATE EXTERNAL TABLE IF NOT EXISTS viewstream( > cl STRING, > pid STRING, > vp STRING, > ar STRING, > UArm STRING, > dc STRING, > host STRING, > Blocked STRING, > UA-Platform STRING, > UA-Browser STRING, > UA-Version STRING, > UA-Language STRING > ) > > ROW FORMAT SERDE 'org.apache.hadoop.hive.contrib.serde2.JsonSerde' > LOCATION 'hdfs:///repo/viewstream/'; > > Anybody run into similar errors? I can't find anything on this problem > online, strangely enough. > > Thanks all, > Alex >
-
Re: Parse Error with '-' in Hive
shrikanth shankar 2012-05-31, 16:03
I believe Hive column names cant have '-' in them . From what I know this JSON serde uses column names as JSON expressions. This means that if you renamed the column name you would end up with a null value for the column. You might want to try a different json serde (for e.g. the one Amazon uses in EMR examples allows the JSON expression for a column to be passed in as a SERDE parameter)
thanks, Shrikanth On May 31, 2012, at 8:35 AM, Alex Barrera wrote:
> Hi there, > > I'm looking for help with the following error: I keep receiving an error 'Parse Error: line 40:4 cannot recognize input near '-' 'Platform' STRING column type. ' > > It looks to be a problem with my JSON deserializer OR Hive not recognizing the - in the field names. So far I've tried commenting it out with / and //, and tried wrapping single and double quotes around the field name. Nothing has worked so far. > > My code looks like this: > add jar s3://sa/hive-json-serde-0.3.jar; > DROP TABLE IF EXISTS viewstream; > CREATE EXTERNAL TABLE IF NOT EXISTS viewstream( > cl STRING, > pid STRING, > vp STRING, > ar STRING, > UArm STRING, > dc STRING, > host STRING, > Blocked STRING, > UA-Platform STRING, > UA-Browser STRING, > UA-Version STRING, > UA-Language STRING > ) > > ROW FORMAT SERDE 'org.apache.hadoop.hive.contrib.serde2.JsonSerde' > LOCATION 'hdfs:///repo/viewstream/'; > > Anybody run into similar errors? I can't find anything on this problem online, strangely enough. > > Thanks all, > Alex
-
Re: Parse Error with '-' in Hive
Alex Barrera 2012-06-01, 19:39
Thank you all for the responses - turns out ` didn't work as an escape key either and we had to rewrite the data with _ . Much appreciated! Alex
On Thu, May 31, 2012 at 11:03 AM, shrikanth shankar <[EMAIL PROTECTED]>wrote:
> I believe Hive column names cant have '-' in them . From what I know this > JSON serde uses column names as JSON expressions. This means that if you > renamed the column name you would end up with a null value for the column. > You might want to try a different json serde (for e.g. the one Amazon uses > in EMR examples allows the JSON expression for a column to be passed in as > a SERDE parameter) > > thanks, > Shrikanth > On May 31, 2012, at 8:35 AM, Alex Barrera wrote: > > > Hi there, > > > > I'm looking for help with the following error: I keep receiving an error > 'Parse Error: line 40:4 cannot recognize input near '-' 'Platform' STRING > column type. ' > > > > It looks to be a problem with my JSON deserializer OR Hive not > recognizing the - in the field names. So far I've tried commenting it out > with / and //, and tried wrapping single and double quotes around the field > name. Nothing has worked so far. > > > > My code looks like this: > > add jar s3://sa/hive-json-serde-0.3.jar; > > DROP TABLE IF EXISTS viewstream; > > CREATE EXTERNAL TABLE IF NOT EXISTS viewstream( > > cl STRING, > > pid STRING, > > vp STRING, > > ar STRING, > > UArm STRING, > > dc STRING, > > host STRING, > > Blocked STRING, > > UA-Platform STRING, > > UA-Browser STRING, > > UA-Version STRING, > > UA-Language STRING > > ) > > > > ROW FORMAT SERDE 'org.apache.hadoop.hive.contrib.serde2.JsonSerde' > > LOCATION 'hdfs:///repo/viewstream/'; > > > > Anybody run into similar errors? I can't find anything on this problem > online, strangely enough. > > > > Thanks all, > > Alex > >
|
|