You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pig.apache.org by Apache Wiki <wi...@apache.org> on 2010/10/09 00:21:04 UTC
[Pig Wiki] Update of "DefaultDataTypeInserter" by XuefuZhang
Dear Wiki user,
You have subscribed to a wiki page or wiki category on "Pig Wiki" for change notification.
The "DefaultDataTypeInserter" page has been changed by XuefuZhang.
http://wiki.apache.org/pig/DefaultDataTypeInserter
--------------------------------------------------
New page:
= DefaultDataTypeInserter.g =
{{{
tree grammar DefaultDataTypeInserter;
options {
tokenVocab=PigParser;
ASTLabelType=CommonTree;
output=AST;
backtrack=true;
}
@header {
package pig;
}
query :^( QUERY statement* )
;
statement : ^( STATEMENT alias? op_clause )
;
alias : IDENTIFIER
;
op_clause : load_clause | store_clause | filter_clause | distinct_clause
;
load_clause : ^( LOAD QUOTEDSTRING func_clause? as_clause? )
;
as_clause: tuple_def
;
tuple_def : ^( TUPLE_DEF field+ )
;
// Add default types for schema field.
field : ^( FIELD IDENTIFIER )
-> ^( FIELD IDENTIFIER BYTEARRAY )
| ^( FIELD IDENTIFIER type )
;
type : simple_type | tuple_type | bag_type | map_type
;
simple_type : INT | LONG | FLOAT | DOUBLE | CHARARRAY | BYTEARRAY
;
tuple_type : tuple_def
;
bag_type : tuple_def
;
map_type :
;
func_clause : ^( FUNC func_name func_args? )
;
func_name : IDENTIFIER+
;
func_args : QUOTEDSTRING+
;
store_clause : ^( STORE alias QUOTEDSTRING func_clause? )
;
filter_clause : ^( FILTER alias cond )
;
cond : ^( OR cond cond )
| ^( AND cond cond )
| ^( NOT cond )
| ^( NULL expr NOT )
| ^( FILTEROP expr expr )
| func_clause
;
expr : ^( PLUS expr expr )
| ^( MINUS expr expr )
| ^( STAR expr expr )
| ^( DIV expr expr )
| ^( PERCENT expr expr )
| ^( CAST_EXPR type expr )
| const_expr
| var_expr
| neg_expr
;
var_expr : projectable_expr^ ( dot_proj | pound_proj )*
;
projectable_expr: func_clause | col_ref | bin_expr
;
dot_proj : ^( PERIOD col_ref+ )
;
pound_proj : POUND^ ( QUOTEDSTRING | NULL )
;
bin_expr : ^( BIN_EXPR cond expr expr )
;
neg_expr : MINUS^ expr
;
distinct_clause : ^( DISTINCT alias )
;
col_ref : alias_col_ref | dollar_col_ref
;
alias_col_ref : GROUP | IDENTIFIER
;
dollar_col_ref : DOLLAR! INTEGER
;
const_expr : scalar | map | bag | tuple
;
scalar : INTEGER | LONGINEGER | FLOATNUMBER | DOUBLENUMBER | QUOTEDSTRING | NULL
;
map : ^( MAP_VAL keyvalue+ )
;
keyvalue : ^( KEY_VAL_PAIR string_val const_expr )
;
string_val : QUOTEDSTRING | NULL
;
bag :^( BAG_VAL tuple+ )
;
tuple : ^( TUPLE_VAL const_expr+ )
;
}}}