Commits

Olemis Lang  committed 8e24d77

GViz QL : Group values according to group by clause. Aggregation functions avg, count, sum ... (failures=5)

  • Participants
  • Parent commits bb56cc3
  • Branches gviz_ql

Comments (0)

Files changed (1)

File trac-dev/gviz/tracgviz/gvizql.py

         else:
           raise GVizRuntimeError("Unknown column " + colnm + ".")
 
+    get_col_schema.__schema__ = schema
     return get_col_schema
 
   @staticmethod
       if not isinstance(row, self.Tuple):
         raise GVizRuntimeError("%s invoked without GROUP BY, PIVOT" % (funcnm,))
       else:
-        getvalue = GVizQLClauseHandler._column_accessor(row.__schema__)
+        get_group_value = GVizQLClauseHandler._column_accessor(row.__schema__)
         try:
-          return f(row.__group__, getvalue, col_schema[0])
+          return f(row.__group__, get_group_value, col_schema[0])
         except GVizRuntimeError:
           # Target column is not available
           raise GVizRuntimeError('%s(%s) : No such column in GROUP BY, PIVOT'% \
 
     if not return_type:
       def agg_schema(get_col_schema):
+        schema = get_col_schema.__schema__
+        if not isinstance(row, self.Sequence):
+          raise GVizRuntimeError("%s invoked without GROUP BY, PIVOT" % (funcnm,))
+        else:
+          get_group_col_schema = GVizQLClauseHandler._schema_accessor(
+              schema.__schema__)
         try:
-          return (func_label, get_col_schema(col_schema[0])[1])
+          return (func_label, get_group_col_schema(col_schema[0])[1])
         except GVizRuntimeError:
           # Target column is not available
           raise GVizRuntimeError('%s(%s) : No such column in GROUP BY, PIVOT'% \