From: <ibr...@us...> - 2011-01-19 11:57:26
|
Revision: 3871 http://tora.svn.sourceforge.net/tora/?rev=3871&view=rev Author: ibre5041 Date: 2011-01-19 11:57:19 +0000 (Wed, 19 Jan 2011) Log Message: ----------- - Aggregate functions added (fixes count(distinct(floor(x))) ...) - Fix for missing group by in query rewrite Modified Paths: -------------- branches/tora-trotl/sandbox/OracleSQL.g Modified: branches/tora-trotl/sandbox/OracleSQL.g =================================================================== --- branches/tora-trotl/sandbox/OracleSQL.g 2011-01-19 10:16:29 UTC (rev 3870) +++ branches/tora-trotl/sandbox/OracleSQL.g 2011-01-19 11:57:19 UTC (rev 3871) @@ -268,6 +268,7 @@ ^('t_from' r_from table_reference_list/*? join_clause?*/) where_clause? hierarchical_query_clause? + group_by_clause? model_clause? union_clause? order_by_clause? @@ -350,8 +351,9 @@ | ( expr_paren ) => expr_paren | ( k_cursor LPAREN ) => cursor_expression | ( k_cast LPAREN) => cast_expression - | ( k_cluster_set LPAREN ) => special_expression + | ( k_cluster_set LPAREN ) => special_expression | ( analytic_function ) => analytic_function + | ( aggregate_function ) => aggregate_function | ( function_expression ) => function_expression // | ( compound_expression ) => compound_expression | ( case_expression ) => case_expression @@ -385,6 +387,7 @@ parameter_name : identifier[T_UNKNOWN] ; + case_expression : r_case ( simple_case_expression | searched_case_expression ) ( else_case_expression )? k_end ; @@ -1041,7 +1044,11 @@ analytic_function : analytic_function_call ( ( k_respect | k_ignore) k_nulls )? k_over LPAREN analytic_clause RPAREN ; - + +count_function + : k_count LPAREN ( ASTERISK | (r_distinct | r_all)? sql_expression) RPAREN + ( k_over LPAREN analytic_clause RPAREN)? + ; analytic_clause : query_partition_clause? (order_by_clause windowing_clause?)? ; @@ -1058,6 +1065,17 @@ ; /* ================================================================================ + Aggregate functions + ================================================================================ */ +aggregate_function_name + : (k_count | function_name) // TODO use real list of aggregate function names here + ; +aggregate_function + : aggregate_function_name + LPAREN ( ASTERISK | (r_distinct | r_all)? sql_expression) RPAREN ( k_over LPAREN analytic_clause RPAREN)? + ; + +/* ================================================================================ FOR UPDATE CLAUSE ================================================================================ */ for_update_clause @@ -1075,7 +1093,7 @@ PIVOT CLAUSE ================================================================================ */ pivot_clause - : k_pivot k_xml? LPAREN function_expression c_alias? (COMMA function_expression c_alias?)* + : k_pivot k_xml? LPAREN aggregate_function c_alias? (COMMA aggregate_function c_alias?)* pivot_for_clause pivot_in_clause RPAREN ; pivot_for_clause @@ -1613,7 +1631,7 @@ k_connect_by_root : r='CONNECT_BY_ROOT' { $r->setType($r, T_RESERVED); } ; k_constraint : r='CONSTRAINT' { $r->setType($r, T_RESERVED); } ; k_corr : r='CORR' { $r->setType($r, T_RESERVED); } ; -k_count : r='COUNT' { $r->setType($r, T_RESERVED); } ; +k_count : r='COUNT' { $r->setType($r, T_RESERVED); } ; k_covar_pop : r='COVAR_POP' { $r->setType($r, T_RESERVED); } ; k_covar_samp : r='COVAR_SAMP' { $r->setType($r, T_RESERVED); } ; k_cross : r='CROSS' { $r->setType($r, T_RESERVED); } ; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |