1 /*@bgen(jjtree) Generated By:JJTree: Do not edit this line. /Users/trevor/Documents/School/othercode/pig-src/src/com/yahoo/pig/impl/logicalLayer/parser/QueryParser.jj */
3 * Copyright (c) 2007 Yahoo! Inc. All rights reserved.
4 * See accompanying LICENSE file.
8 * This file lists the grammar for PIG Latin.
9 * QueryParser program ouputs a ParseTree given a Valid Pig Latin Query
12 // Generate non-static functions
14 // Case is ignored in keywords
18 PARSER_BEGIN(QueryParser)
19 package com.yahoo.pig.impl.logicalLayer.parser;
22 import java.lang.reflect.*;
23 import com.yahoo.pig.impl.logicalLayer.*;
24 import com.yahoo.pig.impl.eval.*;
25 import com.yahoo.pig.impl.eval.func.*;
26 import com.yahoo.pig.impl.eval.groupby.*;
27 import com.yahoo.pig.impl.eval.filter.*;
28 import com.yahoo.pig.impl.eval.window.*;
29 import com.yahoo.pig.impl.eval.sad.*;
30 import com.yahoo.pig.impl.logicalLayer.schema.*;
31 import com.yahoo.pig.*;
32 import com.yahoo.pig.impl.PigContext;
33 import com.yahoo.pig.PigServer.ExecType;
34 import com.yahoo.pig.impl.physicalLayer.IntermedResult;
35 import com.yahoo.pig.impl.io.FileLocalizer;
36 import com.yahoo.pig.builtin.*;
37 public class QueryParser/*@bgen(jjtree)*/implements QueryParserTreeConstants/*@egen*/ {/*@bgen(jjtree)*/
38 protected JJTQueryParserState jjtree = new JJTQueryParserState();
41 private PigContext pigContext;
42 private Map<String, IntermedResult> aliases;
44 public QueryParser(InputStream in, PigContext pigContext, Map aliases) {
46 this.pigContext = pigContext;
47 this.aliases = aliases;
50 public class EvalSpecPipeAndSchema{
52 SchemaItemList schema;
55 public class CogroupInput {
56 public LogicalOperator op;
57 public GroupBySpec spec;
60 static String unquote(String s) {
61 return s.substring(1, s.length()-1);
64 static int undollar(String s) {
65 return Integer.parseInt(s.substring(1, s.length()));
68 NestableEvalItem newFuncEvalItem(EvalFunc func, EvalItemList args) throws ParseException {
69 if (func instanceof AtomEvalFunc) return new AtomFuncEvalItem(pigContext, (AtomEvalFunc) func, args);
70 else if (func instanceof TupleEvalFunc) return new TupleFuncEvalItem(pigContext, (TupleEvalFunc) func, args);
71 else if (func instanceof BagEvalFunc) return new BagFuncEvalItem(pigContext, (BagEvalFunc) func, args);
72 else throw new ParseException("Error: unknown Eval Function type: " + func.getClass().getName());
76 LogicalOperator makeLORead(String alias) throws ParseException {
77 if (!aliases.containsKey(alias)) throw new ParseException("Unrecognized alias: " + alias);
79 LORead readOp = new LORead(pigContext, aliases.get(alias));
86 String massageFilename(String filename) throws IOException {
87 if (pigContext.getExecType() != ExecType.LOCAL) {
88 if (filename.startsWith(FileLocalizer.LOCAL_PREFIX)) {
89 filename = FileLocalizer.hadoopify(filename);
91 if (filename.startsWith(FileLocalizer.HADOOP_PREFIX)) {
92 filename = filename.substring(FileLocalizer.HADOOP_PREFIX.length());
100 LogicalOperator parseCogroup(ArrayList<CogroupInput> gis) throws ParseException{
103 LogicalOperator[] los = new LogicalOperator[n];
104 GroupBySpec[] specs = new GroupBySpec[n];
106 for (int i = 0; i < n ; i++){
108 CogroupInput gi = gis.get(i);
113 return new LOCogroup(pigContext, los, specs);
117 LogicalOperator rewriteCross(ArrayList<LogicalOperator> inputs) throws IOException, ParseException{
118 ArrayList<CogroupInput> gis = new ArrayList<CogroupInput>();
119 Iterator<LogicalOperator> iter = inputs.iterator();
120 int n = inputs.size();
122 EvalSpecPipe pipe = new EvalSpecPipe(pigContext);
123 EvalItemList list = new EvalItemList(pigContext);
125 for (int i=0; i< n; i++){
127 CogroupInput gi = new CogroupInput();
130 gi.op = inputs.get(i);
131 EvalItemList itemList = new EvalItemList(pigContext);
132 itemList.add(new ConstEvalItem(pigContext, n+""));
133 itemList.add(new ConstEvalItem(pigContext, i+""));
134 gi.spec = new GroupBySpec(pigContext, (GroupFunc) pigContext.getUDF(GFCross.class.getName()), itemList, false);
136 ColEvalItem item = new ColEvalItem(pigContext, i+1);
137 EvalItemList subSpec = new EvalItemList(pigContext);
138 subSpec.add(new StarEvalItem(pigContext));
139 item.subColSpec = subSpec;
144 return new LOEval(pigContext, parseCogroup(gis),pipe);
147 LOLoad getDefaultLoadOperator(boolean continuous, String filename) throws IOException{
149 String[] args = null;
152 args = new String[2];
157 StorageFunc loadFunc = (StorageFunc) pigContext.getUDF(PigStorage.class.getName());
158 return new LOLoad(pigContext, massageFilename(filename), loadFunc, args);
161 void assertAtomic(EvalItem item, boolean desiredAtomic) throws ParseException{
162 Boolean isAtomic = null;
163 if (item instanceof ConstEvalItem || item instanceof AtomFuncEvalItem)
165 else if (item instanceof FuncEvalItem)
168 if (isAtomic != null && isAtomic != desiredAtomic){
170 throw new ParseException("Atomic field expected but found non-atomic field");
172 throw new ParseException("Non-atomic field expected but found atomic field");
176 EvalItem copyItemAndAddSpec(EvalItem item, EvalSpec spec) throws ParseException{
177 assertAtomic(item,false);
179 if (!(item instanceof NestableEvalItem))
180 throw new ParseException("Internal Error: Cannot add spec to non-nestable field.");
181 NestableEvalItem nestableItem = (NestableEvalItem)item;
182 EvalSpecPipe specPipe = nestableItem.nestedEval;
183 nestableItem.addNestedEvalSpec(spec);
190 PARSER_END(QueryParser)
192 // Skip all the new lines, tabs and spaces
193 SKIP : { " " | "\r" | "\t" | "\n" }
195 // Skip comments(single line and multiline)
197 <"--"(~["\r","\n"])*>
198 | <"/*" (~["*"])* "*" ("*" | (~["*","/"] (~["*"])* "*"))* "/">
200 // Comparison operators that can be used in a filter:
201 TOKEN : { <#STRFILTEROP : "eq" | "gt" | "lt" | "gte" | "lte" | "neq" > }
202 TOKEN : { <#NUMFILTEROP : "==" | "<" | "<=" | ">" | ">=" | "!=" > }
203 TOKEN : { <FILTEROP : <STRFILTEROP> | <NUMFILTEROP> > }
205 // List all the keywords in the language
206 TOKEN : { <LOAD : "load"> }
207 TOKEN : { <FILTER : "filter"> }
208 TOKEN : { <FOREACH : "foreach"> }
209 TOKEN : { <MATCHES : "matches"> }
210 TOKEN : { <ORDER : "order"> }
211 TOKEN : { <ARRANGE : "arrange"> }
212 TOKEN : { <DISTINCT : "distinct"> }
213 TOKEN : { <COGROUP : "cogroup"> }
214 TOKEN : { <CROSS : "cross"> }
215 TOKEN : { <UNION : "union"> }
216 TOKEN : { <ALL : "all"> }
217 TOKEN : { <ANY : "any"> }
218 TOKEN : { <AS : "as"> }
219 TOKEN : { <BY : "by"> }
220 TOKEN : { <USING : "using"> }
221 TOKEN : { <INNER : "inner"> }
222 TOKEN : { <OUTER : "outer"> }
223 TOKEN : { <STAR : "*"> }
224 TOKEN : { <PARALLEL : "parallel"> }
225 TOKEN : { <GROUP : "group"> }
226 TOKEN : { <AND : "and"> }
227 TOKEN : { <OR : "or"> }
228 TOKEN : { <NOT : "not"> }
229 TOKEN : { <CONTINUOUSLY : "continuously"> }
230 TOKEN : { <WINDOW : "window"> }
231 TOKEN : { <SECONDS : "seconds"> }
232 TOKEN : { <MINUTES : "minutes"> }
233 TOKEN : { <HOURS : "hours"> }
234 TOKEN : { <TUPLES : "tuples"> }
235 TOKEN : { <GENERATE : "generate"> }
236 TOKEN : { <FLATTEN : "flatten"> }
237 TOKEN : { <EVAL : "eval"> }
241 <#LETTER : ["a"-"z", "A"-"Z"] >
242 | <#DIGIT : ["0"-"9"] >
243 | <#SPECIALCHAR : ["_"] >
244 | <#FSSPECIALCHAR: ["-", ":", "/"]>
245 | <IDENTIFIER: ( <LETTER> )+ ( <DIGIT> | <LETTER> | <SPECIALCHAR> | "::")* >
247 // Define Numeric Constants
250 < NUMBER: <INTEGER> | <FLOAT> | <FLOAT> ( ["e","E"] ([ "-","+"])? <FLOAT> )?>
251 | < #FLOAT: <INTEGER> ( "." <INTEGER> )? | "." <INTEGER> >
252 | < INTEGER: ( <DIGIT> )+ >
255 TOKEN : { <QUOTEDSTRING : "'" (~["'"])* "'"> }
256 // Pig has special variables starting with $
257 TOKEN : { <DOLLARVAR : "$" <INTEGER> > }
259 // Parse is the Starting function.
260 LogicalPlan Parse() : {/*@bgen(jjtree) Parse */
261 SimpleNode jjtn000 = new SimpleNode(JJTPARSE);
262 boolean jjtc000 = true;
263 jjtree.openNodeScope(jjtn000);
264 /*@egen*/LogicalOperator root; Token t1;}
265 {/*@bgen(jjtree) Parse */
270 (t1 = <IDENTIFIER> "=" root = Expr() ";"{root.alias = t1.image;})
271 | (root = Expr() ";")
274 jjtree.closeNodeScope(jjtn000, true);
278 { return new LogicalPlan(root, pigContext); }/*@bgen(jjtree)*/
279 } catch (Throwable jjte000) {
281 jjtree.clearNodeScope(jjtn000);
286 if (jjte000 instanceof RuntimeException) {
287 throw (RuntimeException)jjte000;
289 if (jjte000 instanceof ParseException) {
290 throw (ParseException)jjte000;
292 throw (Error)jjte000;
295 jjtree.closeNodeScope(jjtn000, true);
301 LogicalOperator Expr() : {/*@bgen(jjtree) Expr */
302 SimpleNode jjtn000 = new SimpleNode(JJTEXPR);
303 boolean jjtc000 = true;
304 jjtree.openNodeScope(jjtn000);
305 /*@egen*/LogicalOperator op; SchemaItemList schema;}
306 {/*@bgen(jjtree) Expr */
310 ( op = NestedExpr() [ <AS> schema = AsClause() {op.schema=schema;} ] )
314 jjtree.closeNodeScope(jjtn000, true);
318 {return op;}/*@bgen(jjtree)*/
319 } catch (Throwable jjte000) {
321 jjtree.clearNodeScope(jjtn000);
326 if (jjte000 instanceof RuntimeException) {
327 throw (RuntimeException)jjte000;
329 if (jjte000 instanceof ParseException) {
330 throw (ParseException)jjte000;
332 throw (Error)jjte000;
335 jjtree.closeNodeScope(jjtn000, true);
341 LogicalOperator NestedExpr() : {/*@bgen(jjtree) NestedExpr */
342 SimpleNode jjtn000 = new SimpleNode(JJTNESTEDEXPR);
343 boolean jjtc000 = true;
344 jjtree.openNodeScope(jjtn000);
345 /*@egen*/LogicalOperator op;}
346 {/*@bgen(jjtree) NestedExpr */
351 | LOOKAHEAD(2) ( "(" op = NestedExpr() ")" )
352 | ( "(" op = BaseExpr() ")" )
355 jjtree.closeNodeScope(jjtn000, true);
359 {return op;}/*@bgen(jjtree)*/
360 } catch (Throwable jjte000) {
362 jjtree.clearNodeScope(jjtn000);
367 if (jjte000 instanceof RuntimeException) {
368 throw (RuntimeException)jjte000;
370 if (jjte000 instanceof ParseException) {
371 throw (ParseException)jjte000;
373 throw (Error)jjte000;
376 jjtree.closeNodeScope(jjtn000, true);
382 // A reference to an alias
383 LogicalOperator Alias() : {/*@bgen(jjtree) Alias */
384 SimpleNode jjtn000 = new SimpleNode(JJTALIAS);
385 boolean jjtc000 = true;
386 jjtree.openNodeScope(jjtn000);
387 /*@egen*/Token t1; LogicalOperator op;}
388 {/*@bgen(jjtree) Alias */
391 t1 = <IDENTIFIER>/*@bgen(jjtree)*/
393 jjtree.closeNodeScope(jjtn000, true);
398 op = makeLORead(t1.image);
403 jjtree.closeNodeScope(jjtn000, true);
413 LogicalOperator BaseExpr() : {/*@bgen(jjtree) BaseExpr */
414 SimpleNode jjtn000 = new SimpleNode(JJTBASEEXPR);
415 boolean jjtc000 = true;
416 jjtree.openNodeScope(jjtn000);
417 /*@egen*/LogicalOperator op; SchemaItemList schema; Token t1, t2;}
418 {/*@bgen(jjtree) BaseExpr */
423 (<LOAD> op = LoadClause() [<AS> schema = AsClause() {op.schema=schema;} ])
424 | ((<GROUP> | <COGROUP>) op = CogroupClause())
425 | (<FILTER> op = FilterClause())
426 | (<CROSS> op = CrossClause())
427 | (<UNION> op = UnionClause())
428 | (<FOREACH> op = ForEachClause())
430 [<PARALLEL> t2=<NUMBER> { op.requestedParallelism = Integer.parseInt(t2.image);} ]
433 jjtree.closeNodeScope(jjtn000, true);
437 {return op;}/*@bgen(jjtree)*/
438 } catch (Throwable jjte000) {
440 jjtree.clearNodeScope(jjtn000);
445 if (jjte000 instanceof RuntimeException) {
446 throw (RuntimeException)jjte000;
448 if (jjte000 instanceof ParseException) {
449 throw (ParseException)jjte000;
451 throw (Error)jjte000;
454 jjtree.closeNodeScope(jjtn000, true);
460 LogicalOperator LoadClause() : {/*@bgen(jjtree) LoadClause */
461 SimpleNode jjtn000 = new SimpleNode(JJTLOADCLAUSE);
462 boolean jjtc000 = true;
463 jjtree.openNodeScope(jjtn000);
464 /*@egen*/Token t1, t2; String filename; StorageFunc loadFunc = null;
465 ArrayList<String> loadParams = new ArrayList<String>(); LOLoad lo=null; boolean continuous=false;}
466 {/*@bgen(jjtree) LoadClause */
469 ( t1 = <QUOTEDSTRING> {filename = unquote(t1.image);}
470 (<USING> loadFunc = LoadFunction() "(" (t2 = <QUOTEDSTRING> {loadParams.add(t2.image);})?
471 ( "," t2 = <QUOTEDSTRING> {loadParams.add(t2.image);})*
473 {lo = new LOLoad(pigContext, massageFilename(filename), loadFunc, loadParams);}
476 [ <CONTINUOUSLY> {continuous=true;} ]/*@bgen(jjtree)*/
478 jjtree.closeNodeScope(jjtn000, true);
484 lo = getDefaultLoadOperator(continuous,filename);
487 lo.setOutputType(LogicalOperator.MONOTONE);
490 } catch (Throwable jjte000) {
492 jjtree.clearNodeScope(jjtn000);
497 if (jjte000 instanceof RuntimeException) {
498 throw (RuntimeException)jjte000;
500 if (jjte000 instanceof ParseException) {
501 throw (ParseException)jjte000;
503 throw (Error)jjte000;
506 jjtree.closeNodeScope(jjtn000, true);
512 LogicalOperator FilterClause():
513 {/*@bgen(jjtree) FilterClause */
514 SimpleNode jjtn000 = new SimpleNode(JJTFILTERCLAUSE);
515 boolean jjtc000 = true;
516 jjtree.openNodeScope(jjtn000);
517 /*@egen*/Cond cond; LogicalOperator input;}
518 {/*@bgen(jjtree) FilterClause */
522 <BY> cond = PCond(input.outputSchema(),null)/*@bgen(jjtree)*/
524 jjtree.closeNodeScope(jjtn000, true);
529 EvalSpecPipe specPipe = new EvalSpecPipe(pigContext);
530 specPipe.add(new FilterSpec(cond));
531 return new LOEval(pigContext, input, specPipe);
533 } catch (Throwable jjte000) {
535 jjtree.clearNodeScope(jjtn000);
540 if (jjte000 instanceof RuntimeException) {
541 throw (RuntimeException)jjte000;
543 if (jjte000 instanceof ParseException) {
544 throw (ParseException)jjte000;
546 throw (Error)jjte000;
549 jjtree.closeNodeScope(jjtn000, true);
557 Cond PCond(SchemaItem over, Map<String, EvalItem> pipes) : {/*@bgen(jjtree) PCond */
558 SimpleNode jjtn000 = new SimpleNode(JJTPCOND);
559 boolean jjtc000 = true;
560 jjtree.openNodeScope(jjtn000);
561 /*@egen*/Cond cond = null;}
562 {/*@bgen(jjtree) PCond */
565 cond = POrCond(over,pipes)/*@bgen(jjtree)*/
567 jjtree.closeNodeScope(jjtn000, true);
571 {return cond;}/*@bgen(jjtree)*/
572 } catch (Throwable jjte000) {
574 jjtree.clearNodeScope(jjtn000);
579 if (jjte000 instanceof RuntimeException) {
580 throw (RuntimeException)jjte000;
582 if (jjte000 instanceof ParseException) {
583 throw (ParseException)jjte000;
585 throw (Error)jjte000;
588 jjtree.closeNodeScope(jjtn000, true);
594 Cond POrCond(SchemaItem over, Map<String, EvalItem> pipes) : {/*@bgen(jjtree) POrCond */
595 SimpleNode jjtn000 = new SimpleNode(JJTPORCOND);
596 boolean jjtc000 = true;
597 jjtree.openNodeScope(jjtn000);
598 /*@egen*/Cond cond; List<Cond> cList = new ArrayList<Cond>();}
599 {/*@bgen(jjtree) POrCond */
603 cond = PAndCond(over,pipes) {cList.add(cond);}
604 ( <OR> cond = PAndCond(over,pipes) {cList.add(cond);})*
607 jjtree.closeNodeScope(jjtn000, true);
615 return new OrCond(cList);
617 } catch (Throwable jjte000) {
619 jjtree.clearNodeScope(jjtn000);
624 if (jjte000 instanceof RuntimeException) {
625 throw (RuntimeException)jjte000;
627 if (jjte000 instanceof ParseException) {
628 throw (ParseException)jjte000;
630 throw (Error)jjte000;
633 jjtree.closeNodeScope(jjtn000, true);
639 Cond PAndCond(SchemaItem over, Map<String, EvalItem> pipes) : {/*@bgen(jjtree) PAndCond */
640 SimpleNode jjtn000 = new SimpleNode(JJTPANDCOND);
641 boolean jjtc000 = true;
642 jjtree.openNodeScope(jjtn000);
643 /*@egen*/Cond cond = null; List<Cond> cList = new ArrayList<Cond>();}
644 {/*@bgen(jjtree) PAndCond */
648 cond = PUnaryCond(over,pipes) {cList.add(cond);}
649 ( <AND> cond = PUnaryCond(over,pipes) {cList.add(cond);} )*
652 jjtree.closeNodeScope(jjtn000, true);
660 return new AndCond(cList);
662 } catch (Throwable jjte000) {
664 jjtree.clearNodeScope(jjtn000);
669 if (jjte000 instanceof RuntimeException) {
670 throw (RuntimeException)jjte000;
672 if (jjte000 instanceof ParseException) {
673 throw (ParseException)jjte000;
675 throw (Error)jjte000;
678 jjtree.closeNodeScope(jjtn000, true);
684 Cond PUnaryCond(SchemaItem over, Map<String, EvalItem> pipes) : {/*@bgen(jjtree) PUnaryCond */
685 SimpleNode jjtn000 = new SimpleNode(JJTPUNARYCOND);
686 boolean jjtc000 = true;
687 jjtree.openNodeScope(jjtn000);
688 /*@egen*/Cond cond = null; EvalItem c1, c2; Token t1; FilterFunc func; EvalItemList args;}
689 {/*@bgen(jjtree) PUnaryCond */
693 LOOKAHEAD("(" PCond(over,pipes) ")")
694 ("(" cond = PCond(over,pipes) ")")
695 | LOOKAHEAD(FilterFunction() "(") (func=FilterFunction() "(" args=EvalArgs(over,pipes) ")" {cond = new FuncCond(func, args);})
696 | cond = PNotCond(over,pipes)
697 | LOOKAHEAD(InfixExpr(over,pipes) <FILTEROP>)
698 (c1=InfixExpr(over,pipes) t1=<FILTEROP> c2=InfixExpr(over,pipes) {cond = new CompCond(c1, t1.image, c2);})
700 (c1=InfixExpr(over,pipes) <MATCHES> t1=<QUOTEDSTRING> {cond = new RegexpCond(c1, unquote(t1.image));})
703 jjtree.closeNodeScope(jjtn000, true);
707 {return cond;}/*@bgen(jjtree)*/
708 } catch (Throwable jjte000) {
710 jjtree.clearNodeScope(jjtn000);
715 if (jjte000 instanceof RuntimeException) {
716 throw (RuntimeException)jjte000;
718 if (jjte000 instanceof ParseException) {
719 throw (ParseException)jjte000;
721 throw (Error)jjte000;
724 jjtree.closeNodeScope(jjtn000, true);
730 Cond PNotCond(SchemaItem over, Map<String, EvalItem> pipes) : {/*@bgen(jjtree) PNotCond */
731 SimpleNode jjtn000 = new SimpleNode(JJTPNOTCOND);
732 boolean jjtc000 = true;
733 jjtree.openNodeScope(jjtn000);
735 {/*@bgen(jjtree) PNotCond */
738 <NOT> c1=PUnaryCond(over,pipes)/*@bgen(jjtree)*/
740 jjtree.closeNodeScope(jjtn000, true);
744 {return new NotCond(c1);}/*@bgen(jjtree)*/
745 } catch (Throwable jjte000) {
747 jjtree.clearNodeScope(jjtn000);
752 if (jjte000 instanceof RuntimeException) {
753 throw (RuntimeException)jjte000;
755 if (jjte000 instanceof ParseException) {
756 throw (ParseException)jjte000;
758 throw (Error)jjte000;
761 jjtree.closeNodeScope(jjtn000, true);
769 LogicalOperator CogroupClause() : {/*@bgen(jjtree) CogroupClause */
770 SimpleNode jjtn000 = new SimpleNode(JJTCOGROUPCLAUSE);
771 boolean jjtc000 = true;
772 jjtree.openNodeScope(jjtn000);
773 /*@egen*/CogroupInput gi; ArrayList<CogroupInput> gis = new ArrayList<CogroupInput>();}
774 {/*@bgen(jjtree) CogroupClause */
777 (gi = GroupItem() { gis.add(gi); }
778 ("," gi = GroupItem() { gis.add(gi); })*)/*@bgen(jjtree)*/
780 jjtree.closeNodeScope(jjtn000, true);
784 {return parseCogroup(gis);}/*@bgen(jjtree)*/
785 } catch (Throwable jjte000) {
787 jjtree.clearNodeScope(jjtn000);
792 if (jjte000 instanceof RuntimeException) {
793 throw (RuntimeException)jjte000;
795 if (jjte000 instanceof ParseException) {
796 throw (ParseException)jjte000;
798 throw (Error)jjte000;
801 jjtree.closeNodeScope(jjtn000, true);
808 CogroupInput GroupItem() : {/*@bgen(jjtree) GroupItem */
809 SimpleNode jjtn000 = new SimpleNode(JJTGROUPITEM);
810 boolean jjtc000 = true;
811 jjtree.openNodeScope(jjtn000);
812 /*@egen*/LogicalOperator op; GroupFunc groupFunc; CogroupInput cogroupInput = new CogroupInput();}
813 {/*@bgen(jjtree) GroupItem */
817 cogroupInput.op = NestedExpr()
820 ( <BY> cogroupInput.spec = GroupByExpr(cogroupInput.op.outputSchema()) )
821 | <ALL> {cogroupInput.spec = new GroupBySpec(pigContext, (GroupFunc) pigContext.getUDF(GFAll.class.getName()), new EvalItemList(pigContext), false);}
822 | <ANY> {cogroupInput.spec = new GroupBySpec(pigContext, (GroupFunc) pigContext.getUDF(GFAny.class.getName()), new EvalItemList(pigContext), false);}
824 [<INNER> {cogroupInput.spec.isInner = true;} | <OUTER>]
828 jjtree.closeNodeScope(jjtn000, true);
832 {return cogroupInput;}/*@bgen(jjtree)*/
833 } catch (Throwable jjte000) {
835 jjtree.clearNodeScope(jjtn000);
840 if (jjte000 instanceof RuntimeException) {
841 throw (RuntimeException)jjte000;
843 if (jjte000 instanceof ParseException) {
844 throw (ParseException)jjte000;
846 throw (Error)jjte000;
849 jjtree.closeNodeScope(jjtn000, true);
855 GroupBySpec GroupByExpr(SchemaItem over) : {/*@bgen(jjtree) GroupByExpr */
856 SimpleNode jjtn000 = new SimpleNode(JJTGROUPBYEXPR);
857 boolean jjtc000 = true;
858 jjtree.openNodeScope(jjtn000);
859 /*@egen*/Token t1; GroupBySpec spec = null; EvalItem projItem = null; EvalItemList proj = null; String s; GroupFunc func = null;}
860 {/*@bgen(jjtree) GroupByExpr */
864 LOOKAHEAD(2) (func = GroupFunction() "(" proj = SimpleProjOrEmpty(over) ")" {spec = new GroupBySpec(pigContext, func, proj, false);})
865 | (proj = BracketedSimpleProj(over)) {spec = new GroupBySpec(pigContext, (GroupFunc) pigContext.getUDF(GFTupleNoop.class.getName()), proj, false);}
868 jjtree.closeNodeScope(jjtn000, true);
872 {return spec;}/*@bgen(jjtree)*/
873 } catch (Throwable jjte000) {
875 jjtree.clearNodeScope(jjtn000);
880 if (jjte000 instanceof RuntimeException) {
881 throw (RuntimeException)jjte000;
883 if (jjte000 instanceof ParseException) {
884 throw (ParseException)jjte000;
886 throw (Error)jjte000;
889 jjtree.closeNodeScope(jjtn000, true);
895 //Used in serialization and deserialization
896 GroupBySpec GroupBySpec() : {/*@bgen(jjtree) GroupBySpec */
897 SimpleNode jjtn000 = new SimpleNode(JJTGROUPBYSPEC);
898 boolean jjtc000 = true;
899 jjtree.openNodeScope(jjtn000);
900 /*@egen*/GroupBySpec spec = null;}
901 {/*@bgen(jjtree) GroupBySpec */
904 (spec = GroupByExpr(null)
905 [<INNER> {spec.isInner = true;} | <OUTER>])/*@bgen(jjtree)*/
907 jjtree.closeNodeScope(jjtn000, true);
911 {return spec;}/*@bgen(jjtree)*/
912 } catch (Throwable jjte000) {
914 jjtree.clearNodeScope(jjtn000);
919 if (jjte000 instanceof RuntimeException) {
920 throw (RuntimeException)jjte000;
922 if (jjte000 instanceof ParseException) {
923 throw (ParseException)jjte000;
925 throw (Error)jjte000;
928 jjtree.closeNodeScope(jjtn000, true);
934 LogicalOperator CrossClause() : {/*@bgen(jjtree) CrossClause */
935 SimpleNode jjtn000 = new SimpleNode(JJTCROSSCLAUSE);
936 boolean jjtc000 = true;
937 jjtree.openNodeScope(jjtn000);
938 /*@egen*/LogicalOperator op; ArrayList<LogicalOperator> inputs = new ArrayList<LogicalOperator>();}
939 {/*@bgen(jjtree) CrossClause */
943 op = NestedExpr() { inputs.add(op); }
944 ("," op = NestedExpr() { inputs.add(op); })*
947 jjtree.closeNodeScope(jjtn000, true);
951 {return rewriteCross(inputs);}/*@bgen(jjtree)*/
952 } catch (Throwable jjte000) {
954 jjtree.clearNodeScope(jjtn000);
959 if (jjte000 instanceof RuntimeException) {
960 throw (RuntimeException)jjte000;
962 if (jjte000 instanceof ParseException) {
963 throw (ParseException)jjte000;
965 throw (Error)jjte000;
968 jjtree.closeNodeScope(jjtn000, true);
974 LogicalOperator UnionClause() : {/*@bgen(jjtree) UnionClause */
975 SimpleNode jjtn000 = new SimpleNode(JJTUNIONCLAUSE);
976 boolean jjtc000 = true;
977 jjtree.openNodeScope(jjtn000);
978 /*@egen*/LogicalOperator op; ArrayList<LogicalOperator> inputs = new ArrayList<LogicalOperator>();}
979 {/*@bgen(jjtree) UnionClause */
982 (op = NestedExpr() { inputs.add(op); }
983 ("," op = NestedExpr() { inputs.add(op); })*)/*@bgen(jjtree)*/
985 jjtree.closeNodeScope(jjtn000, true);
989 {return new LOUnion(pigContext, inputs);}/*@bgen(jjtree)*/
990 } catch (Throwable jjte000) {
992 jjtree.clearNodeScope(jjtn000);
997 if (jjte000 instanceof RuntimeException) {
998 throw (RuntimeException)jjte000;
1000 if (jjte000 instanceof ParseException) {
1001 throw (ParseException)jjte000;
1003 throw (Error)jjte000;
1006 jjtree.closeNodeScope(jjtn000, true);
1013 LogicalOperator ForEachClause() : {/*@bgen(jjtree) ForEachClause */
1014 SimpleNode jjtn000 = new SimpleNode(JJTFOREACHCLAUSE);
1015 boolean jjtc000 = true;
1016 jjtree.openNodeScope(jjtn000);
1017 /*@egen*/EvalSpecPipeAndSchema specPipeAndSchema = null; LogicalOperator input, op; }
1018 {/*@bgen(jjtree) ForEachClause */
1022 input = NestedExpr()
1023 specPipeAndSchema = NestedBlock(input.outputSchema())
1026 jjtree.closeNodeScope(jjtn000, true);
1031 op = new LOEval(pigContext, input, specPipeAndSchema.pipe);
1032 op.schema = specPipeAndSchema.schema;
1035 } catch (Throwable jjte000) {
1037 jjtree.clearNodeScope(jjtn000);
1042 if (jjte000 instanceof RuntimeException) {
1043 throw (RuntimeException)jjte000;
1045 if (jjte000 instanceof ParseException) {
1046 throw (ParseException)jjte000;
1048 throw (Error)jjte000;
1051 jjtree.closeNodeScope(jjtn000, true);
1057 EvalSpecPipeAndSchema NestedBlock(SchemaItem over):
1058 {/*@bgen(jjtree) NestedBlock */
1059 SimpleNode jjtn000 = new SimpleNode(JJTNESTEDBLOCK);
1060 boolean jjtc000 = true;
1061 jjtree.openNodeScope(jjtn000);
1062 /*@egen*/EvalSpecPipeAndSchema pipeAndSchema; Map<String, EvalItem> pipes = new HashMap<String, EvalItem>();}
1063 {/*@bgen(jjtree) NestedBlock */
1067 pipeAndSchema = GenerateStatement(over,pipes)
1068 | ("{" (NestedCommand(over,pipes) ";")* pipeAndSchema = GenerateStatement(over,pipes) ";" "}")
1071 jjtree.closeNodeScope(jjtn000, true);
1075 {return pipeAndSchema;}/*@bgen(jjtree)*/
1076 } catch (Throwable jjte000) {
1078 jjtree.clearNodeScope(jjtn000);
1083 if (jjte000 instanceof RuntimeException) {
1084 throw (RuntimeException)jjte000;
1086 if (jjte000 instanceof ParseException) {
1087 throw (ParseException)jjte000;
1089 throw (Error)jjte000;
1092 jjtree.closeNodeScope(jjtn000, true);
1098 void NestedCommand(SchemaItem over, Map<String, EvalItem> pipes):
1099 {/*@bgen(jjtree) NestedCommand */
1100 SimpleNode jjtn000 = new SimpleNode(JJTNESTEDCOMMAND);
1101 boolean jjtc000 = true;
1102 jjtree.openNodeScope(jjtn000);
1103 /*@egen*/Token t; EvalItem item;}
1104 {/*@bgen(jjtree) NestedCommand */
1108 t = <IDENTIFIER> "="
1110 item = InfixExpr(over,pipes)
1111 | item = NestedFilter(over,pipes)
1112 | item = NestedSortOrArrange(over,pipes)
1113 | item = NestedDistinct(over,pipes)
1117 jjtree.closeNodeScope(jjtn000, true);
1121 {pipes.put(t.image,item);}/*@bgen(jjtree)*/
1122 } catch (Throwable jjte000) {
1124 jjtree.clearNodeScope(jjtn000);
1129 if (jjte000 instanceof RuntimeException) {
1130 throw (RuntimeException)jjte000;
1132 if (jjte000 instanceof ParseException) {
1133 throw (ParseException)jjte000;
1135 throw (Error)jjte000;
1138 jjtree.closeNodeScope(jjtn000, true);
1144 EvalItem NestedFilter(SchemaItem over, Map<String, EvalItem> pipes):
1145 {/*@bgen(jjtree) NestedFilter */
1146 SimpleNode jjtn000 = new SimpleNode(JJTNESTEDFILTER);
1147 boolean jjtc000 = true;
1148 jjtree.openNodeScope(jjtn000);
1149 /*@egen*/Cond cond; EvalItem item; SchemaItem subSchema = null;}
1150 {/*@bgen(jjtree) NestedFilter */
1153 <FILTER> item = BaseEvalItem(over,pipes) { subSchema = item.mapInputSchema(over); }
1154 <BY> cond = PCond(subSchema,null)/*@bgen(jjtree)*/
1156 jjtree.closeNodeScope(jjtn000, true);
1160 { return copyItemAndAddSpec(item,new FilterSpec(cond)); }/*@bgen(jjtree)*/
1161 } catch (Throwable jjte000) {
1163 jjtree.clearNodeScope(jjtn000);
1168 if (jjte000 instanceof RuntimeException) {
1169 throw (RuntimeException)jjte000;
1171 if (jjte000 instanceof ParseException) {
1172 throw (ParseException)jjte000;
1174 throw (Error)jjte000;
1177 jjtree.closeNodeScope(jjtn000, true);
1183 EvalItem NestedSortOrArrange(SchemaItem over, Map<String, EvalItem> pipes):
1184 {/*@bgen(jjtree) NestedSortOrArrange */
1185 SimpleNode jjtn000 = new SimpleNode(JJTNESTEDSORTORARRANGE);
1186 boolean jjtc000 = true;
1187 jjtree.openNodeScope(jjtn000);
1188 /*@egen*/EvalItemList list; EvalItem item; SchemaItem subSchema = null; Token t;}
1189 {/*@bgen(jjtree) NestedSortOrArrange */
1193 ( t = <ORDER> | t = <ARRANGE> )
1194 item = BaseEvalItem(over,pipes) { subSchema = item.mapInputSchema(over); }
1195 <BY> list = SimpleProj(subSchema)
1198 jjtree.closeNodeScope(jjtn000, true);
1202 { return copyItemAndAddSpec(item,new SortArrangeSpec(list,t.image.equalsIgnoreCase("arrange"))); }/*@bgen(jjtree)*/
1203 } catch (Throwable jjte000) {
1205 jjtree.clearNodeScope(jjtn000);
1210 if (jjte000 instanceof RuntimeException) {
1211 throw (RuntimeException)jjte000;
1213 if (jjte000 instanceof ParseException) {
1214 throw (ParseException)jjte000;
1216 throw (Error)jjte000;
1219 jjtree.closeNodeScope(jjtn000, true);
1225 EvalItem NestedDistinct(SchemaItem over, Map<String, EvalItem> pipes):
1226 {/*@bgen(jjtree) NestedDistinct */
1227 SimpleNode jjtn000 = new SimpleNode(JJTNESTEDDISTINCT);
1228 boolean jjtc000 = true;
1229 jjtree.openNodeScope(jjtn000);
1230 /*@egen*/EvalItemList list; EvalItem item; LogicalOperator subOp = null; Token t;}
1231 {/*@bgen(jjtree) NestedDistinct */
1236 item = BaseEvalItem(over,pipes)
1239 jjtree.closeNodeScope(jjtn000, true);
1244 list = new EvalItemList(pigContext); list.add(new StarEvalItem(pigContext));
1245 return copyItemAndAddSpec(item,new DistinctSpec(list));
1247 } catch (Throwable jjte000) {
1249 jjtree.clearNodeScope(jjtn000);
1254 if (jjte000 instanceof RuntimeException) {
1255 throw (RuntimeException)jjte000;
1257 if (jjte000 instanceof ParseException) {
1258 throw (ParseException)jjte000;
1260 throw (Error)jjte000;
1263 jjtree.closeNodeScope(jjtn000, true);
1270 EvalSpecPipeAndSchema GenerateStatement(SchemaItem over, Map<String, EvalItem> pipes):
1271 {/*@bgen(jjtree) GenerateStatement */
1272 SimpleNode jjtn000 = new SimpleNode(JJTGENERATESTATEMENT);
1273 boolean jjtc000 = true;
1274 jjtree.openNodeScope(jjtn000);
1275 /*@egen*/EvalSpecPipeAndSchema pipeAndSchema = new EvalSpecPipeAndSchema(); EvalSpecPipe pipe = null; SchemaItemList schema;}
1276 {/*@bgen(jjtree) GenerateStatement */
1281 pipe = FlattenedGenerateItemList(over,pipes)
1284 jjtree.closeNodeScope(jjtn000, true);
1289 pipeAndSchema.pipe = pipe;
1290 return pipeAndSchema;
1292 } catch (Throwable jjte000) {
1294 jjtree.clearNodeScope(jjtn000);
1299 if (jjte000 instanceof RuntimeException) {
1300 throw (RuntimeException)jjte000;
1302 if (jjte000 instanceof ParseException) {
1303 throw (ParseException)jjte000;
1305 throw (Error)jjte000;
1308 jjtree.closeNodeScope(jjtn000, true);
1314 EvalSpecPipe FlattenedGenerateItemList(SchemaItem over, Map<String, EvalItem> pipes):
1315 {/*@bgen(jjtree) FlattenedGenerateItemList */
1316 SimpleNode jjtn000 = new SimpleNode(JJTFLATTENEDGENERATEITEMLIST);
1317 boolean jjtc000 = true;
1318 jjtree.openNodeScope(jjtn000);
1319 /*@egen*/EvalSpecPipe pipe = new EvalSpecPipe(pigContext); EvalItemList list = new EvalItemList(pigContext); EvalItem item;}
1320 {/*@bgen(jjtree) FlattenedGenerateItemList */
1324 item = FlattenedGenerateItem(over,pipes) {list.add(item);}
1325 ("," item = FlattenedGenerateItem(over,pipes) {list.add(item);})*
1328 jjtree.closeNodeScope(jjtn000, true);
1332 {pipe.add(list); return pipe;}/*@bgen(jjtree)*/
1333 } catch (Throwable jjte000) {
1335 jjtree.clearNodeScope(jjtn000);
1340 if (jjte000 instanceof RuntimeException) {
1341 throw (RuntimeException)jjte000;
1343 if (jjte000 instanceof ParseException) {
1344 throw (ParseException)jjte000;
1346 throw (Error)jjte000;
1349 jjtree.closeNodeScope(jjtn000, true);
1356 EvalItem FlattenedGenerateItem(SchemaItem over, Map<String, EvalItem> pipes):
1357 {/*@bgen(jjtree) FlattenedGenerateItem */
1358 SimpleNode jjtn000 = new SimpleNode(JJTFLATTENEDGENERATEITEM);
1359 boolean jjtc000 = true;
1360 jjtree.openNodeScope(jjtn000);
1361 /*@egen*/EvalItem item; SchemaItem schema = null;}
1362 {/*@bgen(jjtree) FlattenedGenerateItem */
1367 ( <FLATTEN> "(" item = GenerateItem(over,pipes) ")"
1369 if (!(item instanceof NestableEvalItem) ||
1370 (item instanceof AtomFuncEvalItem) ){
1371 throw new ParseException("Cannot flatten atom field");
1374 EvalItemList list = new EvalItemList(pigContext);
1375 list.add(new StarEvalItem(pigContext));
1376 ((NestableEvalItem)item).subColSpec = list;
1379 | (item = GenerateItem(over,pipes))
1381 [ <AS> schema = SchemaElement() ]
1384 jjtree.closeNodeScope(jjtn000, true);
1389 item.schema = schema;
1392 } catch (Throwable jjte000) {
1394 jjtree.clearNodeScope(jjtn000);
1399 if (jjte000 instanceof RuntimeException) {
1400 throw (RuntimeException)jjte000;
1402 if (jjte000 instanceof ParseException) {
1403 throw (ParseException)jjte000;
1405 throw (Error)jjte000;
1408 jjtree.closeNodeScope(jjtn000, true);
1414 EvalItem GenerateItem(SchemaItem over, Map<String, EvalItem> pipes):
1415 {/*@bgen(jjtree) GenerateItem */
1416 SimpleNode jjtn000 = new SimpleNode(JJTGENERATEITEM);
1417 boolean jjtc000 = true;
1418 jjtree.openNodeScope(jjtn000);
1419 /*@egen*/EvalItem item;}
1420 {/*@bgen(jjtree) GenerateItem */
1424 item = InfixExpr(over,pipes)
1428 jjtree.closeNodeScope(jjtn000, true);
1432 {return item;}/*@bgen(jjtree)*/
1433 } catch (Throwable jjte000) {
1435 jjtree.clearNodeScope(jjtn000);
1440 if (jjte000 instanceof RuntimeException) {
1441 throw (RuntimeException)jjte000;
1443 if (jjte000 instanceof ParseException) {
1444 throw (ParseException)jjte000;
1446 throw (Error)jjte000;
1449 jjtree.closeNodeScope(jjtn000, true);
1456 EvalItem InfixExpr(SchemaItem over, Map<String, EvalItem> pipes) : {/*@bgen(jjtree) InfixExpr */
1457 SimpleNode jjtn000 = new SimpleNode(JJTINFIXEXPR);
1458 boolean jjtc000 = true;
1459 jjtree.openNodeScope(jjtn000);
1460 /*@egen*/ EvalItem expr; }
1461 {/*@bgen(jjtree) InfixExpr */
1464 expr = AdditiveExpr(over,pipes)/*@bgen(jjtree)*/
1466 jjtree.closeNodeScope(jjtn000, true);
1470 {return expr;}/*@bgen(jjtree)*/
1471 } catch (Throwable jjte000) {
1473 jjtree.clearNodeScope(jjtn000);
1478 if (jjte000 instanceof RuntimeException) {
1479 throw (RuntimeException)jjte000;
1481 if (jjte000 instanceof ParseException) {
1482 throw (ParseException)jjte000;
1484 throw (Error)jjte000;
1487 jjtree.closeNodeScope(jjtn000, true);
1493 EvalItem AdditiveExpr(SchemaItem over, Map<String, EvalItem> pipes) : {/*@bgen(jjtree) AdditiveExpr */
1494 SimpleNode jjtn000 = new SimpleNode(JJTADDITIVEEXPR);
1495 boolean jjtc000 = true;
1496 jjtree.openNodeScope(jjtn000);
1497 /*@egen*/ Token t; EvalItem lhs, rhs; EvalItemList args; }
1498 {/*@bgen(jjtree) AdditiveExpr */
1502 lhs = MultiplicativeExpr(over,pipes)
1504 ( t = "+" | t = "-" ) rhs = MultiplicativeExpr(over,pipes)
1507 assertAtomic(lhs,true);
1508 assertAtomic(rhs,true);
1509 args = new EvalItemList(pigContext);
1512 if (t.image.equals("+")){
1513 lhs = newFuncEvalItem((EvalFunc)pigContext.getUDF("ADD"), args);
1515 lhs = newFuncEvalItem((EvalFunc)pigContext.getUDF("SUBTRACT"), args);
1521 jjtree.closeNodeScope(jjtn000, true);
1525 {return lhs;}/*@bgen(jjtree)*/
1526 } catch (Throwable jjte000) {
1528 jjtree.clearNodeScope(jjtn000);
1533 if (jjte000 instanceof RuntimeException) {
1534 throw (RuntimeException)jjte000;
1536 if (jjte000 instanceof ParseException) {
1537 throw (ParseException)jjte000;
1539 throw (Error)jjte000;
1542 jjtree.closeNodeScope(jjtn000, true);
1548 EvalItem MultiplicativeExpr(SchemaItem over, Map<String, EvalItem> pipes) : {/*@bgen(jjtree) MultiplicativeExpr */
1549 SimpleNode jjtn000 = new SimpleNode(JJTMULTIPLICATIVEEXPR);
1550 boolean jjtc000 = true;
1551 jjtree.openNodeScope(jjtn000);
1552 /*@egen*/ Token t; EvalItem lhs, rhs; EvalItemList args; }
1553 {/*@bgen(jjtree) MultiplicativeExpr */
1557 lhs = UnaryExpr(over,pipes)
1559 ( t = <STAR> | t = "/" ) rhs = UnaryExpr(over,pipes)
1561 assertAtomic(lhs,true);
1562 assertAtomic(rhs,true);
1563 args = new EvalItemList(pigContext);
1566 if (t.image.equals("*")){
1567 lhs = newFuncEvalItem((EvalFunc)pigContext.getUDF("MULTIPLY"), args);
1569 lhs = newFuncEvalItem((EvalFunc)pigContext.getUDF("DIVIDE"), args);
1575 jjtree.closeNodeScope(jjtn000, true);
1579 {return lhs;}/*@bgen(jjtree)*/
1580 } catch (Throwable jjte000) {
1582 jjtree.clearNodeScope(jjtn000);
1587 if (jjte000 instanceof RuntimeException) {
1588 throw (RuntimeException)jjte000;
1590 if (jjte000 instanceof ParseException) {
1591 throw (ParseException)jjte000;
1593 throw (Error)jjte000;
1596 jjtree.closeNodeScope(jjtn000, true);
1602 EvalItem UnaryExpr(SchemaItem over, Map<String, EvalItem> pipes) : {/*@bgen(jjtree) UnaryExpr */
1603 SimpleNode jjtn000 = new SimpleNode(JJTUNARYEXPR);
1604 boolean jjtc000 = true;
1605 jjtree.openNodeScope(jjtn000);
1606 /*@egen*/ EvalItem expr; }
1607 {/*@bgen(jjtree) UnaryExpr */
1611 LOOKAHEAD(BaseEvalItem(over,pipes)) expr = BaseEvalItem(over,pipes)
1612 | ( "(" expr = InfixExpr(over,pipes) ")" )
1615 jjtree.closeNodeScope(jjtn000, true);
1619 {return expr;}/*@bgen(jjtree)*/
1620 } catch (Throwable jjte000) {
1622 jjtree.clearNodeScope(jjtn000);
1627 if (jjte000 instanceof RuntimeException) {
1628 throw (RuntimeException)jjte000;
1630 if (jjte000 instanceof ParseException) {
1631 throw (ParseException)jjte000;
1633 throw (Error)jjte000;
1636 jjtree.closeNodeScope(jjtn000, true);
1643 EvalItem BaseEvalItem(SchemaItem over, Map<String, EvalItem> pipes) :
1644 {/*@bgen(jjtree) BaseEvalItem */
1645 SimpleNode jjtn000 = new SimpleNode(JJTBASEEVALITEM);
1646 boolean jjtc000 = true;
1647 jjtree.openNodeScope(jjtn000);
1648 /*@egen*/EvalItem item;EvalItemList projection; SchemaItem subSchema = null;}
1649 {/*@bgen(jjtree) BaseEvalItem */
1656 LOOKAHEAD(FuncEvalItem(over,pipes))
1657 item = FuncEvalItem(over,pipes)
1658 | item = PColEvalItem(over,pipes)
1659 | item = BinCond(over,pipes)
1661 { subSchema = item.mapInputSchema(over); }
1663 "." projection = BracketedSimpleProj(subSchema)
1665 assertAtomic(item,false);
1666 ((NestableEvalItem)item).addNestedEvalSpec(projection);
1672 jjtree.closeNodeScope(jjtn000, true);
1676 {return item;}/*@bgen(jjtree)*/
1677 } catch (Throwable jjte000) {
1679 jjtree.clearNodeScope(jjtn000);
1684 if (jjte000 instanceof RuntimeException) {
1685 throw (RuntimeException)jjte000;
1687 if (jjte000 instanceof ParseException) {
1688 throw (ParseException)jjte000;
1690 throw (Error)jjte000;
1693 jjtree.closeNodeScope(jjtn000, true);
1701 NestableEvalItem BinCond(SchemaItem over, Map<String, EvalItem> pipes):
1702 {/*@bgen(jjtree) BinCond */
1703 SimpleNode jjtn000 = new SimpleNode(JJTBINCOND);
1704 boolean jjtc000 = true;
1705 jjtree.openNodeScope(jjtn000);
1706 /*@egen*/Cond cond; EvalItem ifTrue, ifFalse; NestableEvalItem ret = null;}
1707 {/*@bgen(jjtree) BinCond */
1711 "(" cond = PCond(over,pipes) "?" ifTrue = BaseEvalItem(over,pipes)
1712 ":" ifFalse = BaseEvalItem(over,pipes) ")"
1715 jjtree.closeNodeScope(jjtn000, true);
1719 { return new BinCond(pigContext, cond,ifTrue,ifFalse);}/*@bgen(jjtree)*/
1720 } catch (Throwable jjte000) {
1722 jjtree.clearNodeScope(jjtn000);
1727 if (jjte000 instanceof RuntimeException) {
1728 throw (RuntimeException)jjte000;
1730 if (jjte000 instanceof ParseException) {
1731 throw (ParseException)jjte000;
1733 throw (Error)jjte000;
1736 jjtree.closeNodeScope(jjtn000, true);
1743 NestableEvalItem FuncEvalItem(SchemaItem over, Map<String, EvalItem> pipes) : {/*@bgen(jjtree) FuncEvalItem */
1744 SimpleNode jjtn000 = new SimpleNode(JJTFUNCEVALITEM);
1745 boolean jjtc000 = true;
1746 jjtree.openNodeScope(jjtn000);
1747 /*@egen*/EvalFunc func; EvalItemList args; NestableEvalItem i;}
1748 {/*@bgen(jjtree) FuncEvalItem */
1751 func=EvalFunction() "(" args=EvalArgs(over,pipes) ")" {i = newFuncEvalItem(func, args);}/*@bgen(jjtree)*/
1753 jjtree.closeNodeScope(jjtn000, true);
1757 {return i;}/*@bgen(jjtree)*/
1758 } catch (Throwable jjte000) {
1760 jjtree.clearNodeScope(jjtn000);
1765 if (jjte000 instanceof RuntimeException) {
1766 throw (RuntimeException)jjte000;
1768 if (jjte000 instanceof ParseException) {
1769 throw (ParseException)jjte000;
1771 throw (Error)jjte000;
1774 jjtree.closeNodeScope(jjtn000, true);
1780 EvalItemList EvalArgs(SchemaItem over, Map<String, EvalItem> pipes) : {/*@bgen(jjtree) EvalArgs */
1781 SimpleNode jjtn000 = new SimpleNode(JJTEVALARGS);
1782 boolean jjtc000 = true;
1783 jjtree.openNodeScope(jjtn000);
1784 /*@egen*/EvalItemList list = new EvalItemList(pigContext); EvalItem item;}
1785 {/*@bgen(jjtree) EvalArgs */
1789 (item=EvalArgsItem(over,pipes) {list.add(item);}
1790 ("," item=EvalArgsItem(over,pipes) {list.add(item);})*)
1791 | {list = new EvalItemList(pigContext);}
1794 jjtree.closeNodeScope(jjtn000, true);
1799 if (!list.isSimple()){
1800 throw new ParseException("Cannot have non-jave function as an argument");
1804 } catch (Throwable jjte000) {
1806 jjtree.clearNodeScope(jjtn000);
1811 if (jjte000 instanceof RuntimeException) {
1812 throw (RuntimeException)jjte000;
1814 if (jjte000 instanceof ParseException) {
1815 throw (ParseException)jjte000;
1817 throw (Error)jjte000;
1820 jjtree.closeNodeScope(jjtn000, true);
1826 EvalItem EvalArgsItem(SchemaItem over, Map<String, EvalItem> pipes):
1827 {/*@bgen(jjtree) EvalArgsItem */
1828 SimpleNode jjtn000 = new SimpleNode(JJTEVALARGSITEM);
1829 boolean jjtc000 = true;
1830 jjtree.openNodeScope(jjtn000);
1831 /*@egen*/EvalItem item;}
1832 {/*@bgen(jjtree) EvalArgsItem */
1836 item = InfixExpr(over,pipes)
1840 jjtree.closeNodeScope(jjtn000, true);
1844 {return item;}/*@bgen(jjtree)*/
1845 } catch (Throwable jjte000) {
1847 jjtree.clearNodeScope(jjtn000);
1852 if (jjte000 instanceof RuntimeException) {
1853 throw (RuntimeException)jjte000;
1855 if (jjte000 instanceof ParseException) {
1856 throw (ParseException)jjte000;
1858 throw (Error)jjte000;
1861 jjtree.closeNodeScope(jjtn000, true);
1870 // Map a user schema onto a LogicalOperator
1871 SchemaItemList AsClause() : {/*@bgen(jjtree) AsClause */
1872 SimpleNode jjtn000 = new SimpleNode(JJTASCLAUSE);
1873 boolean jjtc000 = true;
1874 jjtree.openNodeScope(jjtn000);
1875 /*@egen*/Token t1; SchemaItem item = null; SchemaItemList list = new SchemaItemList(); Token t = null;}
1876 {/*@bgen(jjtree) AsClause */
1880 [ ( t = <IDENTIFIER> | t = <GROUP> ) ":" ] "("
1883 item=SchemaElement() { list.add(item); }
1884 ( "," item=SchemaElement() { list.add(item); } )*
1887 | {list = new SchemaItemList();}
1892 jjtree.closeNodeScope(jjtn000, true);
1898 list.alias = t.image;
1901 } catch (Throwable jjte000) {
1903 jjtree.clearNodeScope(jjtn000);
1908 if (jjte000 instanceof RuntimeException) {
1909 throw (RuntimeException)jjte000;
1911 if (jjte000 instanceof ParseException) {
1912 throw (ParseException)jjte000;
1914 throw (Error)jjte000;
1917 jjtree.closeNodeScope(jjtn000, true);
1923 SchemaItem SchemaElement() : {/*@bgen(jjtree) SchemaElement */
1924 SimpleNode jjtn000 = new SimpleNode(JJTSCHEMAELEMENT);
1925 boolean jjtc000 = true;
1926 jjtree.openNodeScope(jjtn000);
1927 /*@egen*/ Token t1; SchemaItem item = null;}
1928 {/*@bgen(jjtree) SchemaElement */
1931 (LOOKAHEAD(SchemaBag()) item = SchemaBag()
1932 | LOOKAHEAD(SchemaTuple()) item = SchemaTuple()
1933 | LOOKAHEAD(SchemaField()) item = SchemaField() )/*@bgen(jjtree)*/
1935 jjtree.closeNodeScope(jjtn000, true);
1939 {return item;}/*@bgen(jjtree)*/
1940 } catch (Throwable jjte000) {
1942 jjtree.clearNodeScope(jjtn000);
1947 if (jjte000 instanceof RuntimeException) {
1948 throw (RuntimeException)jjte000;
1950 if (jjte000 instanceof ParseException) {
1951 throw (ParseException)jjte000;
1953 throw (Error)jjte000;
1956 jjtree.closeNodeScope(jjtn000, true);
1962 SchemaItem SchemaField() : {/*@bgen(jjtree) SchemaField */
1963 SimpleNode jjtn000 = new SimpleNode(JJTSCHEMAFIELD);
1964 boolean jjtc000 = true;
1965 jjtree.openNodeScope(jjtn000);
1967 {/*@bgen(jjtree) SchemaField */
1970 ( ( t1 = <IDENTIFIER> | t1 = <GROUP> )/*@bgen(jjtree)*/
1972 jjtree.closeNodeScope(jjtn000, true);
1975 /*@egen*/ { return new SchemaField(t1.image); } )/*@bgen(jjtree)*/
1978 jjtree.closeNodeScope(jjtn000, true);
1984 SchemaItem SchemaTuple() : {/*@bgen(jjtree) SchemaTuple */
1985 SimpleNode jjtn000 = new SimpleNode(JJTSCHEMATUPLE);
1986 boolean jjtc000 = true;
1987 jjtree.openNodeScope(jjtn000);
1988 /*@egen*/Token t1 = null; SchemaItem item = null; SchemaItemList list = new SchemaItemList(); }
1989 {/*@bgen(jjtree) SchemaTuple */
1993 [( t1 = <IDENTIFIER> | t1 = <GROUP> ) ":"] "("
1995 ( item=SchemaElement() { list.add(item); }
1996 ( "," item=SchemaElement() {list.add(item);} )*
2003 jjtree.closeNodeScope(jjtn000, true);
2009 list.alias = t1.image;
2010 list.setIsBag(false);
2013 } catch (Throwable jjte000) {
2015 jjtree.clearNodeScope(jjtn000);
2020 if (jjte000 instanceof RuntimeException) {
2021 throw (RuntimeException)jjte000;
2023 if (jjte000 instanceof ParseException) {
2024 throw (ParseException)jjte000;
2026 throw (Error)jjte000;
2029 jjtree.closeNodeScope(jjtn000, true);
2035 SchemaItem SchemaBag() : {/*@bgen(jjtree) SchemaBag */
2036 SimpleNode jjtn000 = new SimpleNode(JJTSCHEMABAG);
2037 boolean jjtc000 = true;
2038 jjtree.openNodeScope(jjtn000);
2039 /*@egen*/Token t1=null; SchemaItem item = null; SchemaItemList list = new SchemaItemList(); }
2040 {/*@bgen(jjtree) SchemaBag */
2044 [ t1 = <IDENTIFIER> ":" ] "["
2046 ( item=SchemaElement() { list.add(item); }
2047 ( "," item=SchemaElement() {list.add(item);} )*
2054 jjtree.closeNodeScope(jjtn000, true);
2060 list.alias = t1.image;
2061 list.setIsBag(true);
2064 } catch (Throwable jjte000) {
2066 jjtree.clearNodeScope(jjtn000);
2071 if (jjte000 instanceof RuntimeException) {
2072 throw (RuntimeException)jjte000;
2074 if (jjte000 instanceof ParseException) {
2075 throw (ParseException)jjte000;
2077 throw (Error)jjte000;
2080 jjtree.closeNodeScope(jjtn000, true);
2091 // Used in serialization and deserialization
2093 EvalSpecPipe PEvalSpecPipe() : {/*@bgen(jjtree) PEvalSpecPipe */
2094 SimpleNode jjtn000 = new SimpleNode(JJTPEVALSPECPIPE);
2095 boolean jjtc000 = true;
2096 jjtree.openNodeScope(jjtn000);
2097 /*@egen*/EvalSpecPipe pipe = new EvalSpecPipe(pigContext); EvalSpec spec;}
2098 {/*@bgen(jjtree) PEvalSpecPipe */
2101 (("["spec=PEvalSpec()"]" {pipe.add(spec);})*)/*@bgen(jjtree)*/
2103 jjtree.closeNodeScope(jjtn000, true);
2107 {return pipe;}/*@bgen(jjtree)*/
2108 } catch (Throwable jjte000) {
2110 jjtree.clearNodeScope(jjtn000);
2115 if (jjte000 instanceof RuntimeException) {
2116 throw (RuntimeException)jjte000;
2118 if (jjte000 instanceof ParseException) {
2119 throw (ParseException)jjte000;
2121 throw (Error)jjte000;
2124 jjtree.closeNodeScope(jjtn000, true);
2130 EvalSpec PEvalSpec() : {/*@bgen(jjtree) PEvalSpec */
2131 SimpleNode jjtn000 = new SimpleNode(JJTPEVALSPEC);
2132 boolean jjtc000 = true;
2133 jjtree.openNodeScope(jjtn000);
2134 /*@egen*/EvalSpec spec;}
2135 {/*@bgen(jjtree) PEvalSpec */
2138 (<FILTER> spec=PFilter() | <EVAL> spec=PEvalItemList() | spec=PSAD())/*@bgen(jjtree)*/
2140 jjtree.closeNodeScope(jjtn000, true);
2144 {return spec;}/*@bgen(jjtree)*/
2145 } catch (Throwable jjte000) {
2147 jjtree.clearNodeScope(jjtn000);
2152 if (jjte000 instanceof RuntimeException) {
2153 throw (RuntimeException)jjte000;
2155 if (jjte000 instanceof ParseException) {
2156 throw (ParseException)jjte000;
2158 throw (Error)jjte000;
2161 jjtree.closeNodeScope(jjtn000, true);
2167 EvalSpec PFilter() :
2168 {/*@bgen(jjtree) PFilter */
2169 SimpleNode jjtn000 = new SimpleNode(JJTPFILTER);
2170 boolean jjtc000 = true;
2171 jjtree.openNodeScope(jjtn000);
2172 /*@egen*/Cond cond;}
2173 {/*@bgen(jjtree) PFilter */
2176 cond = PCond(null,null)/*@bgen(jjtree)*/
2178 jjtree.closeNodeScope(jjtn000, true);
2182 {return new FilterSpec(cond);}/*@bgen(jjtree)*/
2183 } catch (Throwable jjte000) {
2185 jjtree.clearNodeScope(jjtn000);
2190 if (jjte000 instanceof RuntimeException) {
2191 throw (RuntimeException)jjte000;
2193 if (jjte000 instanceof ParseException) {
2194 throw (ParseException)jjte000;
2196 throw (Error)jjte000;
2199 jjtree.closeNodeScope(jjtn000, true);
2205 EvalSpec PSAD() : {/*@bgen(jjtree) PSAD */
2206 SimpleNode jjtn000 = new SimpleNode(JJTPSAD);
2207 boolean jjtc000 = true;
2208 jjtree.openNodeScope(jjtn000);
2209 /*@egen*/EvalSpec sad; EvalItemList proj;}
2210 {/*@bgen(jjtree) PSAD */
2213 ((<ORDER> <BY> proj=SimpleProj(null) {sad = new SortArrangeSpec(proj, false);})
2214 | (<ARRANGE> <BY> proj=SimpleProj(null) {sad = new SortArrangeSpec(proj, true);})
2215 | (<DISTINCT> proj=SimpleProj(null) {sad = new DistinctSpec(proj);}))/*@bgen(jjtree)*/
2217 jjtree.closeNodeScope(jjtn000, true);
2221 {return sad;}/*@bgen(jjtree)*/
2222 } catch (Throwable jjte000) {
2224 jjtree.clearNodeScope(jjtn000);
2229 if (jjte000 instanceof RuntimeException) {
2230 throw (RuntimeException)jjte000;
2232 if (jjte000 instanceof ParseException) {
2233 throw (ParseException)jjte000;
2235 throw (Error)jjte000;
2238 jjtree.closeNodeScope(jjtn000, true);
2244 EvalItemList PEvalItemList() : {/*@bgen(jjtree) PEvalItemList */
2245 SimpleNode jjtn000 = new SimpleNode(JJTPEVALITEMLIST);
2246 boolean jjtc000 = true;
2247 jjtree.openNodeScope(jjtn000);
2248 /*@egen*/EvalItemList list = new EvalItemList(pigContext); EvalItem item;}
2249 {/*@bgen(jjtree) PEvalItemList */
2252 (item=PEvalItem() {list.add(item);}
2253 ("," item=PEvalItem() {list.add(item);})*)/*@bgen(jjtree)*/
2255 jjtree.closeNodeScope(jjtn000, true);
2259 {return list;}/*@bgen(jjtree)*/
2260 } catch (Throwable jjte000) {
2262 jjtree.clearNodeScope(jjtn000);
2267 if (jjte000 instanceof RuntimeException) {
2268 throw (RuntimeException)jjte000;
2270 if (jjte000 instanceof ParseException) {
2271 throw (ParseException)jjte000;
2273 throw (Error)jjte000;
2276 jjtree.closeNodeScope(jjtn000, true);
2282 EvalItem PEvalItem() : {/*@bgen(jjtree) PEvalItem */
2283 SimpleNode jjtn000 = new SimpleNode(JJTPEVALITEM);
2284 boolean jjtc000 = true;
2285 jjtree.openNodeScope(jjtn000);
2286 /*@egen*/EvalItem item; EvalSpec subSpec; EvalItemList subProj; LogicalOperator subOp = null;}
2287 {/*@bgen(jjtree) PEvalItem */
2294 item=PNestableEvalItem()
2295 ( "["subSpec=PEvalSpec()"]" {((NestableEvalItem) item).addNestedEvalSpec(subSpec);})*
2299 EvalItemList list = new EvalItemList(pigContext);
2300 list.add(new StarEvalItem(pigContext));
2301 ((NestableEvalItem) item).subColSpec = list;
2307 jjtree.closeNodeScope(jjtn000, true);
2311 {return item;}/*@bgen(jjtree)*/
2312 } catch (Throwable jjte000) {
2314 jjtree.clearNodeScope(jjtn000);
2319 if (jjte000 instanceof RuntimeException) {
2320 throw (RuntimeException)jjte000;
2322 if (jjte000 instanceof ParseException) {
2323 throw (ParseException)jjte000;
2325 throw (Error)jjte000;
2328 jjtree.closeNodeScope(jjtn000, true);
2335 NestableEvalItem PNestableEvalItem() : {/*@bgen(jjtree) PNestableEvalItem */
2336 SimpleNode jjtn000 = new SimpleNode(JJTPNESTABLEEVALITEM);
2337 boolean jjtc000 = true;
2338 jjtree.openNodeScope(jjtn000);
2339 /*@egen*/NestableEvalItem item;}
2340 {/*@bgen(jjtree) PNestableEvalItem */
2344 (LOOKAHEAD(EvalFunctionItem()) item=EvalFunctionItem()
2345 | LOOKAHEAD(DollarVar()) item=DollarVar()
2346 | LOOKAHEAD(SerializedBinCond()) item = SerializedBinCond())/*@bgen(jjtree)*/
2348 jjtree.closeNodeScope(jjtn000, true);
2352 {return item;}/*@bgen(jjtree)*/
2353 } catch (Throwable jjte000) {
2355 jjtree.clearNodeScope(jjtn000);
2360 if (jjte000 instanceof RuntimeException) {
2361 throw (RuntimeException)jjte000;
2363 if (jjte000 instanceof ParseException) {
2364 throw (ParseException)jjte000;
2366 throw (Error)jjte000;
2369 jjtree.closeNodeScope(jjtn000, true);
2375 NestableEvalItem EvalFunctionItem() : {/*@bgen(jjtree) EvalFunctionItem */
2376 SimpleNode jjtn000 = new SimpleNode(JJTEVALFUNCTIONITEM);
2377 boolean jjtc000 = true;
2378 jjtree.openNodeScope(jjtn000);
2379 /*@egen*/EvalFunc func; EvalItemList args; NestableEvalItem i;}
2380 {/*@bgen(jjtree) EvalFunctionItem */
2383 func=EvalFunction() "(" args=PEvalItemList() ")" {i = newFuncEvalItem(func, args);}/*@bgen(jjtree)*/
2385 jjtree.closeNodeScope(jjtn000, true);
2389 {return i;}/*@bgen(jjtree)*/
2390 } catch (Throwable jjte000) {
2392 jjtree.clearNodeScope(jjtn000);
2397 if (jjte000 instanceof RuntimeException) {
2398 throw (RuntimeException)jjte000;
2400 if (jjte000 instanceof ParseException) {
2401 throw (ParseException)jjte000;
2403 throw (Error)jjte000;
2406 jjtree.closeNodeScope(jjtn000, true);
2413 NestableEvalItem SerializedBinCond():
2414 {/*@bgen(jjtree) SerializedBinCond */
2415 SimpleNode jjtn000 = new SimpleNode(JJTSERIALIZEDBINCOND);
2416 boolean jjtc000 = true;
2417 jjtree.openNodeScope(jjtn000);
2418 /*@egen*/Cond cond; EvalItem ifTrue, ifFalse; NestableEvalItem ret = null;}
2419 {/*@bgen(jjtree) SerializedBinCond */
2423 "(" cond = PSerializedCond() "?" ifTrue = PEvalItem()
2424 ":" ifFalse = PEvalItem() ")"
2427 jjtree.closeNodeScope(jjtn000, true);
2432 return new BinCond(pigContext, cond,ifTrue,ifFalse);
2434 } catch (Throwable jjte000) {
2436 jjtree.clearNodeScope(jjtn000);
2441 if (jjte000 instanceof RuntimeException) {
2442 throw (RuntimeException)jjte000;
2444 if (jjte000 instanceof ParseException) {
2445 throw (ParseException)jjte000;
2447 throw (Error)jjte000;
2450 jjtree.closeNodeScope(jjtn000, true);
2457 Cond PSerializedCond() : {/*@bgen(jjtree) PSerializedCond */
2458 SimpleNode jjtn000 = new SimpleNode(JJTPSERIALIZEDCOND);
2459 boolean jjtc000 = true;
2460 jjtree.openNodeScope(jjtn000);
2461 /*@egen*/Cond cond = null;}
2462 {/*@bgen(jjtree) PSerializedCond */
2465 cond = PSerializedOrCond()/*@bgen(jjtree)*/
2467 jjtree.closeNodeScope(jjtn000, true);
2471 {return cond;}/*@bgen(jjtree)*/
2472 } catch (Throwable jjte000) {
2474 jjtree.clearNodeScope(jjtn000);
2479 if (jjte000 instanceof RuntimeException) {
2480 throw (RuntimeException)jjte000;
2482 if (jjte000 instanceof ParseException) {
2483 throw (ParseException)jjte000;
2485 throw (Error)jjte000;
2488 jjtree.closeNodeScope(jjtn000, true);
2494 Cond PSerializedOrCond() : {/*@bgen(jjtree) PSerializedOrCond */
2495 SimpleNode jjtn000 = new SimpleNode(JJTPSERIALIZEDORCOND);
2496 boolean jjtc000 = true;
2497 jjtree.openNodeScope(jjtn000);
2498 /*@egen*/Cond cond; List<Cond> cList = new ArrayList<Cond>();}
2499 {/*@bgen(jjtree) PSerializedOrCond */
2503 cond = PSerializedAndCond() {cList.add(cond);}
2504 ( <OR> cond = PSerializedAndCond() {cList.add(cond);})*
2507 jjtree.closeNodeScope(jjtn000, true);
2512 if (cList.size()==1)
2515 return new OrCond(cList);
2517 } catch (Throwable jjte000) {
2519 jjtree.clearNodeScope(jjtn000);
2524 if (jjte000 instanceof RuntimeException) {
2525 throw (RuntimeException)jjte000;
2527 if (jjte000 instanceof ParseException) {
2528 throw (ParseException)jjte000;
2530 throw (Error)jjte000;
2533 jjtree.closeNodeScope(jjtn000, true);
2539 Cond PSerializedAndCond() : {/*@bgen(jjtree) PSerializedAndCond */
2540 SimpleNode jjtn000 = new SimpleNode(JJTPSERIALIZEDANDCOND);
2541 boolean jjtc000 = true;
2542 jjtree.openNodeScope(jjtn000);
2543 /*@egen*/Cond cond = null; List<Cond> cList = new ArrayList<Cond>();}
2544 {/*@bgen(jjtree) PSerializedAndCond */
2548 cond = PSerializedUnaryCond() {cList.add(cond);}
2549 ( <AND> cond = PSerializedUnaryCond() {cList.add(cond);} )*
2552 jjtree.closeNodeScope(jjtn000, true);
2557 if (cList.size()==1)
2560 return new AndCond(cList);
2562 } catch (Throwable jjte000) {
2564 jjtree.clearNodeScope(jjtn000);
2569 if (jjte000 instanceof RuntimeException) {
2570 throw (RuntimeException)jjte000;
2572 if (jjte000 instanceof ParseException) {
2573 throw (ParseException)jjte000;
2575 throw (Error)jjte000;
2578 jjtree.closeNodeScope(jjtn000, true);
2584 Cond PSerializedUnaryCond() : {/*@bgen(jjtree) PSerializedUnaryCond */
2585 SimpleNode jjtn000 = new SimpleNode(JJTPSERIALIZEDUNARYCOND);
2586 boolean jjtc000 = true;
2587 jjtree.openNodeScope(jjtn000);
2588 /*@egen*/Cond cond = null; EvalItem c1, c2; Token t1; FilterFunc func; EvalItemList args;}
2589 {/*@bgen(jjtree) PSerializedUnaryCond */
2593 LOOKAHEAD("(" PSerializedCond() ")")
2594 ("(" cond = PSerializedCond() ")")
2595 | cond = PSerializedNotCond()
2596 | LOOKAHEAD(PEvalItem() <FILTEROP>)
2597 (c1=PEvalItem() t1=<FILTEROP> c2=PEvalItem() {cond = new CompCond(c1, t1.image, c2);})
2598 | LOOKAHEAD(PEvalItem() <MATCHES>)
2599 (c1=PEvalItem() <MATCHES> t1=<QUOTEDSTRING> {cond = new RegexpCond(c1, unquote(t1.image));})
2600 | (func=FilterFunction() "(" args=PEvalItemList() ")" {cond = new FuncCond(func, args);})
2603 jjtree.closeNodeScope(jjtn000, true);
2607 {return cond;}/*@bgen(jjtree)*/
2608 } catch (Throwable jjte000) {
2610 jjtree.clearNodeScope(jjtn000);
2615 if (jjte000 instanceof RuntimeException) {
2616 throw (RuntimeException)jjte000;
2618 if (jjte000 instanceof ParseException) {
2619 throw (ParseException)jjte000;
2621 throw (Error)jjte000;
2624 jjtree.closeNodeScope(jjtn000, true);
2630 Cond PSerializedNotCond() : {/*@bgen(jjtree) PSerializedNotCond */
2631 SimpleNode jjtn000 = new SimpleNode(JJTPSERIALIZEDNOTCOND);
2632 boolean jjtc000 = true;
2633 jjtree.openNodeScope(jjtn000);
2635 {/*@bgen(jjtree) PSerializedNotCond */
2638 <NOT> c1=PSerializedUnaryCond()/*@bgen(jjtree)*/
2640 jjtree.closeNodeScope(jjtn000, true);
2644 {return new NotCond(c1);}/*@bgen(jjtree)*/
2645 } catch (Throwable jjte000) {
2647 jjtree.clearNodeScope(jjtn000);
2652 if (jjte000 instanceof RuntimeException) {
2653 throw (RuntimeException)jjte000;
2655 if (jjte000 instanceof ParseException) {
2656 throw (ParseException)jjte000;
2658 throw (Error)jjte000;
2661 jjtree.closeNodeScope(jjtn000, true);
2675 EvalSpec PWindow() : {/*@bgen(jjtree) PWindow */
2676 SimpleNode jjtn000 = new SimpleNode(JJTPWINDOW);
2677 boolean jjtc000 = true;
2678 jjtree.openNodeScope(jjtn000);
2679 /*@egen*/EvalSpec spec; int numTuples; double time;}
2680 {/*@bgen(jjtree) PWindow */
2685 time = PTimeWindow() { spec = new TimeWindowSpec(WindowSpec.windowType.SLIDING, time); } |
2686 numTuples = PTupleWindow() { spec = new TupleWindowSpec(WindowSpec.windowType.SLIDING, numTuples);}
2690 jjtree.closeNodeScope(jjtn000, true);
2694 {return spec;}/*@bgen(jjtree)*/
2695 } catch (Throwable jjte000) {
2697 jjtree.clearNodeScope(jjtn000);
2702 if (jjte000 instanceof RuntimeException) {
2703 throw (RuntimeException)jjte000;
2705 if (jjte000 instanceof ParseException) {
2706 throw (ParseException)jjte000;
2708 throw (Error)jjte000;
2711 jjtree.closeNodeScope(jjtn000, true);
2717 double PTimeWindow() : {/*@bgen(jjtree) PTimeWindow */
2718 SimpleNode jjtn000 = new SimpleNode(JJTPTIMEWINDOW);
2719 boolean jjtc000 = true;
2720 jjtree.openNodeScope(jjtn000);
2721 /*@egen*/double n; Token t;}
2722 {/*@bgen(jjtree) PTimeWindow */
2725 ( t = <NUMBER> { n = Double.parseDouble(t.image); }
2727 <MINUTES> { n = n*60; } |
2728 <HOURS> { n = n * 3600; }
2732 jjtree.closeNodeScope(jjtn000, true);
2736 {return n;}/*@bgen(jjtree)*/
2739 jjtree.closeNodeScope(jjtn000, true);
2745 int PTupleWindow() : {/*@bgen(jjtree) PTupleWindow */
2746 SimpleNode jjtn000 = new SimpleNode(JJTPTUPLEWINDOW);
2747 boolean jjtc000 = true;
2748 jjtree.openNodeScope(jjtn000);
2749 /*@egen*/int n; Token t;}
2750 {/*@bgen(jjtree) PTupleWindow */
2753 ( t = <NUMBER> { try{
2754 n = Integer.parseInt(t.image);
2755 }catch(NumberFormatException e){
2756 throw new ParseException("Only whole number tuple windows allowed.");
2762 jjtree.closeNodeScope(jjtn000, true);
2766 {return n;}/*@bgen(jjtree)*/
2769 jjtree.closeNodeScope(jjtn000, true);
2781 // These the simple non-terminals that are shared across many
2783 EvalFunc EvalFunction() : {/*@bgen(jjtree) EvalFunction */
2784 SimpleNode jjtn000 = new SimpleNode(JJTEVALFUNCTION);
2785 boolean jjtc000 = true;
2786 jjtree.openNodeScope(jjtn000);
2787 /*@egen*/String funcName;}
2788 {/*@bgen(jjtree) EvalFunction */
2791 funcName = QualifiedFunction()/*@bgen(jjtree)*/
2793 jjtree.closeNodeScope(jjtn000, true);
2797 {return (EvalFunc) pigContext.getUDF(funcName);}/*@bgen(jjtree)*/
2798 } catch (Throwable jjte000) {
2800 jjtree.clearNodeScope(jjtn000);
2805 if (jjte000 instanceof RuntimeException) {
2806 throw (RuntimeException)jjte000;
2808 if (jjte000 instanceof ParseException) {
2809 throw (ParseException)jjte000;
2811 throw (Error)jjte000;
2814 jjtree.closeNodeScope(jjtn000, true);
2820 GroupFunc GroupFunction() : {/*@bgen(jjtree) GroupFunction */
2821 SimpleNode jjtn000 = new SimpleNode(JJTGROUPFUNCTION);
2822 boolean jjtc000 = true;
2823 jjtree.openNodeScope(jjtn000);
2824 /*@egen*/String funcName;}
2825 {/*@bgen(jjtree) GroupFunction */
2828 funcName = QualifiedFunction()/*@bgen(jjtree)*/
2830 jjtree.closeNodeScope(jjtn000, true);
2834 {return (GroupFunc) pigContext.getUDF(funcName);}/*@bgen(jjtree)*/
2835 } catch (Throwable jjte000) {
2837 jjtree.clearNodeScope(jjtn000);
2842 if (jjte000 instanceof RuntimeException) {
2843 throw (RuntimeException)jjte000;
2845 if (jjte000 instanceof ParseException) {
2846 throw (ParseException)jjte000;
2848 throw (Error)jjte000;
2851 jjtree.closeNodeScope(jjtn000, true);
2857 StorageFunc LoadFunction() : {/*@bgen(jjtree) LoadFunction */
2858 SimpleNode jjtn000 = new SimpleNode(JJTLOADFUNCTION);
2859 boolean jjtc000 = true;
2860 jjtree.openNodeScope(jjtn000);
2861 /*@egen*/String funcName;}
2862 {/*@bgen(jjtree) LoadFunction */
2865 funcName = QualifiedFunction()/*@bgen(jjtree)*/
2867 jjtree.closeNodeScope(jjtn000, true);
2871 {return (StorageFunc) pigContext.getUDF(funcName);}/*@bgen(jjtree)*/
2872 } catch (Throwable jjte000) {
2874 jjtree.clearNodeScope(jjtn000);
2879 if (jjte000 instanceof RuntimeException) {
2880 throw (RuntimeException)jjte000;
2882 if (jjte000 instanceof ParseException) {
2883 throw (ParseException)jjte000;
2885 throw (Error)jjte000;
2888 jjtree.closeNodeScope(jjtn000, true);
2894 FilterFunc FilterFunction() : {/*@bgen(jjtree) FilterFunction */
2895 SimpleNode jjtn000 = new SimpleNode(JJTFILTERFUNCTION);
2896 boolean jjtc000 = true;
2897 jjtree.openNodeScope(jjtn000);
2898 /*@egen*/String funcName;}
2899 {/*@bgen(jjtree) FilterFunction */
2902 funcName = QualifiedFunction()/*@bgen(jjtree)*/
2904 jjtree.closeNodeScope(jjtn000, true);
2908 {return (FilterFunc) pigContext.getUDF(funcName);}/*@bgen(jjtree)*/
2909 } catch (Throwable jjte000) {
2911 jjtree.clearNodeScope(jjtn000);
2916 if (jjte000 instanceof RuntimeException) {
2917 throw (RuntimeException)jjte000;
2919 if (jjte000 instanceof ParseException) {
2920 throw (ParseException)jjte000;
2922 throw (Error)jjte000;
2925 jjtree.closeNodeScope(jjtn000, true);
2932 * Bug 831620 - '$' support
2934 void ClassName() : {} { <IDENTIFIER> (("." <IDENTIFIER>)|("$" <IDENTIFIER>))* }
2937 * Bug 831620 - '$' support
2939 String QualifiedFunction() : {Token t1;StringBuffer s=new StringBuffer();}
2941 ((t1=<IDENTIFIER> { s.append(t1.image);}
2942 (("." t1=<IDENTIFIER> {s.append("." + t1.image);})|
2943 ("$" t1=<IDENTIFIER> {s.append("$" + t1.image);}))*))
2944 {return s.toString();}
2948 // If there is one time it may not be bracketed, but if multiple, they must be bracketed
2949 EvalItemList BracketedSimpleProj(SchemaItem over) : {/*@bgen(jjtree) BracketedSimpleProj */
2950 SimpleNode jjtn000 = new SimpleNode(JJTBRACKETEDSIMPLEPROJ);
2951 boolean jjtc000 = true;
2952 jjtree.openNodeScope(jjtn000);
2953 /*@egen*/EvalItem i = null; EvalItemList proj = new EvalItemList(pigContext);}
2954 {/*@bgen(jjtree) BracketedSimpleProj */
2958 i = PSimpleProjItem(over) {proj.add(i);}
2959 | ("(" i = PSimpleProjItem(over) {proj.add(i);}
2960 ("," i = PSimpleProjItem(over) {proj.add(i);})*
2964 jjtree.closeNodeScope(jjtn000, true);
2968 {return proj;}/*@bgen(jjtree)*/
2969 } catch (Throwable jjte000) {
2971 jjtree.clearNodeScope(jjtn000);
2976 if (jjte000 instanceof RuntimeException) {
2977 throw (RuntimeException)jjte000;
2979 if (jjte000 instanceof ParseException) {
2980 throw (ParseException)jjte000;
2982 throw (Error)jjte000;
2985 jjtree.closeNodeScope(jjtn000, true);
2991 EvalItemList SimpleProjOrEmpty(SchemaItem over) : {/*@bgen(jjtree) SimpleProjOrEmpty */
2992 SimpleNode jjtn000 = new SimpleNode(JJTSIMPLEPROJOREMPTY);
2993 boolean jjtc000 = true;
2994 jjtree.openNodeScope(jjtn000);
2995 /*@egen*/EvalItemList list;}
2996 {/*@bgen(jjtree) SimpleProjOrEmpty */
3000 list = SimpleProj(over)
3001 | {list = new EvalItemList(pigContext);}
3004 jjtree.closeNodeScope(jjtn000, true);
3008 {return list;}/*@bgen(jjtree)*/
3009 } catch (Throwable jjte000) {
3011 jjtree.clearNodeScope(jjtn000);
3016 if (jjte000 instanceof RuntimeException) {
3017 throw (RuntimeException)jjte000;
3019 if (jjte000 instanceof ParseException) {
3020 throw (ParseException)jjte000;
3022 throw (Error)jjte000;
3025 jjtree.closeNodeScope(jjtn000, true);
3031 //Just a simple list of projection items
3032 EvalItemList SimpleProj(SchemaItem over) : {/*@bgen(jjtree) SimpleProj */
3033 SimpleNode jjtn000 = new SimpleNode(JJTSIMPLEPROJ);
3034 boolean jjtc000 = true;
3035 jjtree.openNodeScope(jjtn000);
3036 /*@egen*/EvalItem i = null; EvalItemList proj = new EvalItemList(pigContext);}
3037 {/*@bgen(jjtree) SimpleProj */
3041 i = PSimpleProjItem(over) {proj.add(i);}
3042 ("," i = PSimpleProjItem(over) {proj.add(i);})*
3045 jjtree.closeNodeScope(jjtn000, true);
3049 {return proj;}/*@bgen(jjtree)*/
3050 } catch (Throwable jjte000) {
3052 jjtree.clearNodeScope(jjtn000);
3057 if (jjte000 instanceof RuntimeException) {
3058 throw (RuntimeException)jjte000;
3060 if (jjte000 instanceof ParseException) {
3061 throw (ParseException)jjte000;
3063 throw (Error)jjte000;
3066 jjtree.closeNodeScope(jjtn000, true);
3072 EvalItem PSimpleProjItem(SchemaItem over):
3073 {/*@bgen(jjtree) PSimpleProjItem */
3074 SimpleNode jjtn000 = new SimpleNode(JJTPSIMPLEPROJITEM);
3075 boolean jjtc000 = true;
3076 jjtree.openNodeScope(jjtn000);
3077 /*@egen*/EvalItem item;}
3078 {/*@bgen(jjtree) PSimpleProjItem */
3083 | item = PColEvalItem(over,null)
3087 jjtree.closeNodeScope(jjtn000, true);
3091 {return item;}/*@bgen(jjtree)*/
3092 } catch (Throwable jjte000) {
3094 jjtree.clearNodeScope(jjtn000);
3099 if (jjte000 instanceof RuntimeException) {
3100 throw (RuntimeException)jjte000;
3102 if (jjte000 instanceof ParseException) {
3103 throw (ParseException)jjte000;
3105 throw (Error)jjte000;
3108 jjtree.closeNodeScope(jjtn000, true);
3115 EvalItem Star() : {/*@bgen(jjtree) Star */
3116 SimpleNode jjtn000 = new SimpleNode(JJTSTAR);
3117 boolean jjtc000 = true;
3118 jjtree.openNodeScope(jjtn000);
3120 {/*@bgen(jjtree) Star */
3123 t1=<STAR>/*@bgen(jjtree)*/
3125 jjtree.closeNodeScope(jjtn000, true);
3129 {return new StarEvalItem(pigContext);}/*@bgen(jjtree)*/
3132 jjtree.closeNodeScope(jjtn000, true);
3138 EvalItem Const() : {/*@bgen(jjtree) Const */
3139 SimpleNode jjtn000 = new SimpleNode(JJTCONST);
3140 boolean jjtc000 = true;
3141 jjtree.openNodeScope(jjtn000);
3143 {/*@bgen(jjtree) Const */
3146 t1=<QUOTEDSTRING>/*@bgen(jjtree)*/
3148 jjtree.closeNodeScope(jjtn000, true);
3152 {return new ConstEvalItem(pigContext, unquote(t1.image));}/*@bgen(jjtree)*/
3155 jjtree.closeNodeScope(jjtn000, true);
3161 EvalItem PColEvalItem(SchemaItem over, Map<String, EvalItem> pipes):
3162 {/*@bgen(jjtree) PColEvalItem */
3163 SimpleNode jjtn000 = new SimpleNode(JJTPCOLEVALITEM);
3164 boolean jjtc000 = true;
3165 jjtree.openNodeScope(jjtn000);
3166 /*@egen*/EvalItem item;}
3167 {/*@bgen(jjtree) PColEvalItem */
3172 | item = AliasField(over, pipes)
3175 jjtree.closeNodeScope(jjtn000, true);
3182 } catch (Throwable jjte000) {
3184 jjtree.clearNodeScope(jjtn000);
3189 if (jjte000 instanceof RuntimeException) {
3190 throw (RuntimeException)jjte000;
3192 if (jjte000 instanceof ParseException) {
3193 throw (ParseException)jjte000;
3195 throw (Error)jjte000;
3198 jjtree.closeNodeScope(jjtn000, true);
3204 ColEvalItem DollarVar() : {/*@bgen(jjtree) DollarVar */
3205 SimpleNode jjtn000 = new SimpleNode(JJTDOLLARVAR);
3206 boolean jjtc000 = true;
3207 jjtree.openNodeScope(jjtn000);
3209 {/*@bgen(jjtree) DollarVar */
3212 t1=<DOLLARVAR>/*@bgen(jjtree)*/
3214 jjtree.closeNodeScope(jjtn000, true);
3218 {return new ColEvalItem(pigContext, undollar(t1.image));}/*@bgen(jjtree)*/
3221 jjtree.closeNodeScope(jjtn000, true);
3227 EvalItem AliasField(SchemaItem over, Map<String, EvalItem> pipes) : {/*@bgen(jjtree) AliasField */
3228 SimpleNode jjtn000 = new SimpleNode(JJTALIASFIELD);
3229 boolean jjtc000 = true;
3230 jjtree.openNodeScope(jjtn000);
3232 {/*@bgen(jjtree) AliasField */
3235 (t1=<GROUP> | t1=<IDENTIFIER>)/*@bgen(jjtree)*/
3237 jjtree.closeNodeScope(jjtn000, true);
3241 { int i; EvalItem item = null;
3243 item = pipes.get(t1.image);
3246 if ( over == null || (i = over.colFor(t1.image)) == -1)
3247 throw new ParseException("Invalid alias: " + t1.image + " in " + over.alias + "--> " + over);
3248 item = new ColEvalItem(pigContext, i);
3254 jjtree.closeNodeScope(jjtn000, true);