Review Board 1.7.22


PIG-3342 Allow conditions in case statement

Review Request #11613 - Created June 4, 2013 and submitted

Cheolsoo Park
PIG-3342
Reviewers
pig
pig-git
Allows condition expression in case statement.
All unit tests pass.
src/org/apache/pig/parser/AstPrinter.g
Revision c2abede New Change
[20] 328 lines
[+20]
329
var_expr
329
var_expr
330
    : projectable_expr ( dot_proj | pound_proj )*
330
    : projectable_expr ( dot_proj | pound_proj )*
331
;
331
;
332

    
   
332

   
333
projectable_expr
333
projectable_expr
334
    : func_eval | col_ref | bin_expr | case_expr
334
    : func_eval | col_ref | bin_expr | case_expr | case_cond
335
;
335
;
336

    
   
336

   
337
dot_proj
337
dot_proj
338
    : ^( PERIOD { sb.append(".("); } col_alias_or_index ( { sb.append(", "); } col_alias_or_index)*  { sb.append(")"); } )
338
    : ^( PERIOD { sb.append(".("); } col_alias_or_index ( { sb.append(", "); } col_alias_or_index)*  { sb.append(")"); } )
339
;
339
;
[+20] [20] 22 lines
[+20]
362
bin_expr
362
bin_expr
363
    : ^( BIN_EXPR { sb.append(" ("); } cond { sb.append(" ? "); } expr { sb.append(" : "); } expr { sb.append(") "); } )
363
    : ^( BIN_EXPR { sb.append(" ("); } cond { sb.append(" ? "); } expr { sb.append(" : "); } expr { sb.append(") "); } )
364
;
364
;
365

    
   
365

   
366
case_expr
366
case_expr
367
    : ^( CASE { sb.append(" " + $CASE.text + "("); } expr ( { sb.append(", "); } expr )+ { sb.append(") "); } )
367
    : ^( CASE_EXPR { sb.append(" CASE ("); } expr ( { sb.append(", "); } expr )+ { sb.append(") "); } )

    
   
368
;

    
   
369

   

    
   
370
case_cond

    
   
371
    : ^( CASE_COND { sb.append(" CASE ("); }

    
   
372
        ^( WHEN cond ( { sb.append(", "); } cond )* { sb.append(", "); } )

    
   
373
        ^( THEN expr ( { sb.append(", "); } expr )* { sb.append(") "); } ) )
368
;
374
;
369

    
   
375

   
370
limit_clause
376
limit_clause
371
    : ^( LIMIT { sb.append($LIMIT.text).append(" "); } rel
377
    : ^( LIMIT { sb.append($LIMIT.text).append(" "); } rel
372
        ( INTEGER { sb.append(" ").append($INTEGER.text); } | LONGINTEGER { sb.append(" ").append($LONGINTEGER.text); } | expr ) )
378
        ( INTEGER { sb.append(" ").append($INTEGER.text); } | LONGINTEGER { sb.append(" ").append($LONGINTEGER.text); } | expr ) )
[+20] [20] 368 lines
src/org/apache/pig/parser/AstValidator.g
Revision 2c6d4dc New Change
 
src/org/apache/pig/parser/LogicalPlanGenerator.g
Revision 9375d60 New Change
 
src/org/apache/pig/parser/QueryParser.g
Revision 2b84c86 New Change
 
test/org/apache/pig/test/TestCase.java
Revision dbee495 New Change
 
  1. src/org/apache/pig/parser/AstPrinter.g: Loading...
  2. src/org/apache/pig/parser/AstValidator.g: Loading...
  3. src/org/apache/pig/parser/LogicalPlanGenerator.g: Loading...
  4. src/org/apache/pig/parser/QueryParser.g: Loading...
  5. test/org/apache/pig/test/TestCase.java: Loading...