Skip to content

Commit

Permalink
fix groupby bug
Browse files Browse the repository at this point in the history
  • Loading branch information
继盛 committed Feb 2, 2016
1 parent 728953c commit 1d67d5e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion odps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import sys

__version__ = '0.3.0'
__version__ = '0.3.1'
__all__ = ['ODPS',]

version = sys.version_info
Expand Down
5 changes: 5 additions & 0 deletions odps/df/backends/odpssql/tests/test_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ def testBaseCompilation(self):
"GROUP BY REGEXP_EXTRACT(t1.`name`, '/projects/(.*?)/', 1)"
self.assertEqual(to_str(expected), to_str(self.engine.compile(expr, prettify=False)))

expr = self.expr.groupby(
self.expr.name.extract('/projects/(.*?)/', group=1).rename('project')).count()
self.assertEqual(len(expr.dtypes), 2)
self.assertEqual(to_str(expected), to_str(self.engine.compile(expr, prettify=False)))

expr = self.expr.describe()
expected = 'SELECT SUM(IF(t1.`id` IS NOT NULL, 1, 0)) AS id_count, ' \
'MIN(t1.`id`) AS id_min, MAX(t1.`id`) AS id_max, ' \
Expand Down
4 changes: 2 additions & 2 deletions odps/df/expr/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,9 @@ def aggregate(self, *aggregations, **kw):
if not all(self._is_reduction(agg) for agg in aggregations):
raise TypeError('Only aggregate functions can be provided')

names = [by.name for by in self._by if isinstance(by, Column)] + \
names = [by.name for by in self._by if isinstance(by, SequenceExpr)] + \
[agg.name for agg in aggregations]
types = [by._data_type for by in self._by if isinstance(by, Column)] + \
types = [by._data_type for by in self._by if isinstance(by, SequenceExpr)] + \
[agg._data_type for agg in aggregations]

return GroupByCollectionExpr(_input=self, _aggregations=aggregations,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
long_description = f.read()

setup(name='pyodps',
version='0.3.0',
version='0.3.1',
description='ODPS Python SDK',
long_description=long_description,
author='Wu Wei',
Expand Down

0 comments on commit 1d67d5e

Please sign in to comment.