Support Questions
Find answers, ask questions, and share your expertise

mismatched input 'AS' expecting RIGHT_PAREN in Pig



I want to fetch url ,methods and class from the below line using Pig Script:

Mapped "{[/aLog/transaction],methods=[POST],produces=[application/ || application/json]}" onto public org.springframework.http.ResponseEntity<java.lang.Object>,javax.servlet.http.HttpServletRequest) throws com.fhlb.commons.CustomException,

Here is my Pig Script :

extract = FOREACH logs_entry GENERATE FLATTEN(REGEX_EXTRACT_ALL(logmessage,'^(Mapped)\\"(\\{+(\\[+([^/].*)+\\]),methods=(\\[+([A-Z].*)+\\]),produces=(\\[+([^ ].*)+\\])+\\}\\)"\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(throws)\\s+(.*)
AS (t1:chararray,url:chararray,type:chararray,produces:chararray,t2:chararray,t3:chararray,classes:chararray,throw:chararray,exception:chararray);

But I got below error :

ERROR 1200: <line 9, column 229> mismatched input 'AS' expecting RIGHT_PAREN

I am not good at regex so please help me to find out the solution.



@priyal patel

Your statement has a syntax issue and that is why you are getting the current error. So if you retype your pig script as follows, you won't have the syntax error.

extract = FOREACH a GENERATE FLATTEN(REGEX_EXTRACT_ALL(rec,'^(Mapped)\\"(\\{+(\\[+([^/].*)+\\]),methods=(\\[+([A-Z].*)+\\]),produces=(\\[+([^ ].*)+\\])+\\}\\)"\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(throws)\\s+(.*)')) AS (t1:chararray,url:chararray,type:chararray,produces:chararray,t2:chararray,t3:chararray,classes:chararray,throw:chararray,exception:chararray);

Now, your regex is as is as you mentioned in the question. I need some more info regarding what you want to fetch out of this error message. And then we can work on the desired regex.


@Rahul Soni,


Actually its a type mistake.I edited my question and i found that i forgot to close ' ')) '.

I want to fetch following values ,

[/aLog/transaction],POST,[application/ || application/json]

I tried below script,

extract = FOREACH matched GENERATE FLATTEN(REGEX_EXTRACT_ALL(logmessage,'^(\\S+)\\s+"(\\{(\\S+),.*=(.*),.*=(.*)\\})"+\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+).*

Output :

(Mapped,{[/auditConfirmation/businessDates],methods=[GET],produces=[application/ || application/json]},[/auditConfirmation/businessDates],[GET],[application/ || application/json],on

I fetched the output which i want But i am getting one extra schema.Could you help me with regex which extract only expected output.I want to remove "{[/auditConfirmation/businessDates],methods=[GET],produces=[application/ || application/json]}" from the output.

I got the Expected output using below script :

output = FOREACH extract GENERATE $4 as url,$5 as requesttype,$6 as produces;

Sorry but can you please put the pattern a bit more clearly? A bit hard to understand in the format you mentioned.


@Rahul Soni,


I edited the comment.Please check it.

Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.