Skip to content
Snippets Groups Projects
Commit a57413372525 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

may now GROUPBY function call or column number. Closes #66602

parent 21e23dabd0bd
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,7 @@
* support != operator for non equality
* support for CAST function
* support for regexp-based pattern matching using a REGEXP operator
* may now GROUPBY functions / column number
2011-01-12 -- 0.28.0
* enhance rewrite_shared_optional so one can specify where the new identity
......
......@@ -173,7 +173,10 @@
rule dgroupby<<S>>: groupby<<S>> {{ if groupby: warn('GROUPBY is now before WHERE clause') }}
rule dlimit_offset<<S>>: limit_offset<<S>> {{ if limit_offset: warn('LIMIT/OFFSET are now before WHERE clause') }}
rule groupby<<S>>: GROUPBY variables<<S>> {{ S.set_groupby(variables); return True }}
rule groupby<<S>>: GROUPBY {{ nodes = [] }}
expr_add<<S>> {{ nodes.append(expr_add) }}
( ',' expr_add<<S>> {{ nodes.append(expr_add) }}
)* {{ S.set_groupby(nodes); return True }}
|
rule having<<S>>: HAVING logical_expr<<S>> {{ S.set_having([logical_expr]) }}
......
......@@ -246,8 +246,14 @@
_token = self._peek('GROUPBY', 'ORDERBY', 'WHERE', 'LIMIT', 'OFFSET', 'HAVING', 'WITH', "';'", 'r"\\)"', context=_context)
if _token == 'GROUPBY':
GROUPBY = self._scan('GROUPBY', context=_context)
variables = self.variables(S, _context)
S.set_groupby(variables); return True
nodes = []
expr_add = self.expr_add(S, _context)
nodes.append(expr_add)
while self._peek("','", 'ORDERBY', 'WHERE', 'LIMIT', 'OFFSET', 'HAVING', 'WITH', "';'", 'GROUPBY', 'r"\\)"', context=_context) == "','":
self._scan("','", context=_context)
expr_add = self.expr_add(S, _context)
nodes.append(expr_add)
S.set_groupby(nodes); return True
elif 1:
pass
else:
......@@ -533,7 +539,7 @@
vars = []
var = self.var(S, _context)
vars.append(var)
while self._peek("','", 'BEING', 'ORDERBY', 'WHERE', 'LIMIT', 'OFFSET', 'HAVING', 'WITH', "';'", 'GROUPBY', 'r"\\)"', context=_context) == "','":
while self._peek("','", 'BEING', context=_context) == "','":
self._scan("','", context=_context)
var = self.var(S, _context)
vars.append(var)
......@@ -704,4 +710,3 @@
f = stdin
print parse(argv[1], f.read())
else: print >>sys.stderr, 'Args: <rule> [<filename>]'
# End -- grammar generated by Yapps
......@@ -153,6 +153,10 @@
'Any X,Y,A ORDERBY Y '
'WHERE A done_for Y, X split_into Y, A diem D '
'HAVING MIN(D) < "2010-07-01", MAX(D) >= "2010-07-01";',
'Any YEAR(XD),COUNT(X) GROUPBY YEAR(XD) ORDERBY YEAR(XD) WHERE X date XD;',
'Any YEAR(XD),COUNT(X) GROUPBY 1 ORDERBY 1 WHERE X date XD;',
)
class ParserHercule(TestCase):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment