Commits

Olemis Lang committed 464aef3

GViz QL : Tests for PIVOT clause ... [ok]

gvizql.py Total tests : 62 , Failures : 10 , Errors : 13

  • Participants
  • Parent commits 0666121
  • Branches gviz_ql

Comments (0)

Files changed (2)

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

     r"""Initialize this clause with a sequence of expressions specifying
     how to group multiple rows in the base data set.
     """
+    if not isinstance(seq, Sequence):
+      seq = Sequence([seq])
     self.groups_def = seq
+    self.aggregate = [self._resolve_schema(c, lambda colnm: (colnm, None))[0] 
+        for c in self.groups_def ]
 
   def transform(self, schema, data):
     r"""Create groups.
     r"""Initialize this clause with the expressions transforming values into
     new columns.
     """
+    if not isinstance(seq, Sequence):
+      seq = Sequence([seq])
     self.pivot_def = seq
+    self.pivot = [self._resolve_schema(c, lambda colnm: (colnm, None))[0] 
+        for c in self.pivot_def ]
 
   def transform(self, schema, data):
     r"""Create new columns from data.
     except KeyError:
       raise LookupError('Unknown aggregation function %s' % (funcnm,))
     return_type = getattr(f, 'return_type', None)
-    func_label = '%s()' % (funcnm,)
+    func_label = '%s(%s)' % \
+        (funcnm, colnm['schema'](lambda colnm: (colnm, None) )[0])
     return dict(
         eval=self._unsupported, 
         schema=(func_label, return_type) if return_type else 
             lambda get_col_schema: (func_label, get_col_schema(colnm)),
         is_eval_callable=True,
-        is_schema_callable=bool(return_type)
+        is_schema_callable=not bool(return_type)
       )
 
   def handle_func(self, funcnm, _, __):
   def _handle_explicit_order(self, expr, direction):
     return (expr[1], direction[1] == 'asc')
 
-  handle_orderasc = handle_order_desc = _handle_explicit_order
+  handle_orderasc = handle_order_dsc = _handle_explicit_order
 
   def handle_orderseq(self, orderdef, _, neworder):
     orderdef = orderdef[1]

File trac-dev/gviz/tracgviz/testing/test_gvizql.py

       *****
       * Parsing
       *****
-      NotSupported  :(
+      [u'dept', u'salary', u'lunchTime']
+      [u'dept']
+      *****
+      * Result
+      *****
+      GVizUnsupportedQueryOp  :  Unable to evaluate PIVOT clause. Either the whole clause or an specific feature is not supported yet.
+
 
       >>> parse("select dept  pivot    dept   ", 'pivot', 'cols')
       *****
       *****
       * Parsing
       *****
-      NotSupported  :(
+      [u'dept']
+      [u'dept']
+      *****
+      * Result
+      *****
+      GVizUnsupportedQueryOp  :  Unable to evaluate PIVOT clause. Either the whole clause or an specific feature is not supported yet.
+
 
       >>> parse("select sum(salary) pivot dept", 'pivot', 'cols')
       *****
       *****
       * Parsing
       *****
-      NotSupported  :(
+      [u'dept']
+      [u'sum(salary)']
+      *****
+      * Result
+      *****
+      GVizUnsupportedQueryOp  :  Unable to evaluate PIVOT clause. Either the whole clause or an specific feature is not supported yet.
+
       """,
   'Parsing PIVOT (complex)' : r"""
       >>> parse("select sum(salary) pivot dept, lunchTime", 'pivot', \
       *****
       * Parsing
       *****
-      NotSupported  :(
+      [u'dept', u'lunchTime']
+      [u'sum(salary)']
+      *****
+      * Result
+      *****
+      GVizUnsupportedQueryOp  :  Unable to evaluate PIVOT clause. Either the whole clause or an specific feature is not supported yet.
+
 
       >>> parse("select sum(salary), max(lunchTime) pivot dept", \
       ...           'pivot', 'cols')
       *****
       * Parsing
       *****
-      NotSupported  :(
+      [u'dept']
+      [u'sum(salary)', u'max(lunchTime)']
+      *****
+      * Result
+      *****
+      GVizUnsupportedQueryOp  :  Unable to evaluate PIVOT clause. Either the whole clause or an specific feature is not supported yet.
+
 
       >>> parse("select dept, sum(salary) group by dept pivot lunchTime", \
       ...           'pivot', 'cols', 'aggregate')
       *****
       * Parsing
       *****
-      NotSupported  :(
+      [u'lunchTime']
+      [u'dept', u'sum(salary)']
+      [u'dept']
+      *****
+      * Result
+      *****
+      GVizUnsupportedQueryOp  :  Unable to evaluate GROUP BY clause. Either the whole clause or an specific feature is not supported yet.
+
 
       >>> parse("select lunchTime, sum(salary) group by lunchTime " \
       ...       "pivot dept", 'pivot', 'cols', 'aggregate')
       *****
       * Parsing
       *****
-      NotSupported  :(
+      [u'dept']
+      [u'lunchTime', u'sum(salary)']
+      [u'lunchTime']
+      *****
+      * Result
+      *****
+      GVizUnsupportedQueryOp  :  Unable to evaluate GROUP BY clause. Either the whole clause or an specific feature is not supported yet.
+
       """,
   'Parsing ORDER BY (simple)' : r"""
       >>> parse("order by   dept , salary desc   ", 'sort')