Commits

Olemis Lang  committed 101ee06

Incorporating changes introduced during last merge ;o)

  • Participants
  • Parent commits 49a0635
  • Branches gviz_ql

Comments (0)

Files changed (4)

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

 #   Global Testing
 #------------------------------------------------------
 
-try:
-  from testing.gvizql import __test__, TEST_DATA_GVIZSCHEMA, \
-                              TEST_DATA_GVIZDATA
-except ImportError :
-  pass
-else :
-  def test_suite():
-    from doctest import ELLIPSIS, NORMALIZE_WHITESPACE, REPORT_UDIFF
-    from unittest import defaultTestLoader
-    from string import whitespace
-    import sys
-    
-    from api import GVizInvalidQuery
-    from testing.dutest import MultiTestLoader, DocTestLoader
-    
-    def parse(expr, *attrs, **kwds):
-      # Test lexical analysis
-      print "*****\n* Tokens\n*****"
-      newline = False
-      p = GVizQLParser()
-      p.noisy = False
-      for tkn, val in p.get_tokens(expr):
-        if tkn is not Whitespace:
-          if newline:
+from testing.test_gvizql import __test__, TEST_DATA_GVIZSCHEMA, \
+                            TEST_DATA_GVIZDATA
+def test_suite():
+  from doctest import ELLIPSIS, NORMALIZE_WHITESPACE, REPORT_UDIFF
+  from unittest import defaultTestLoader
+  from string import whitespace
+  import sys
+  
+  from api import GVizInvalidQuery
+  from testing.dutest import MultiTestLoader, DocTestLoader
+  
+  def parse(expr, *attrs, **kwds):
+    # Test lexical analysis
+    print "*****\n* Tokens\n*****"
+    newline = False
+    p = GVizQLParser()
+    p.noisy = False
+    for tkn, val in p.get_tokens(expr):
+      if tkn is not Whitespace:
+        if newline:
+          print
+        else:
+          newline = True
+        print tkn, val,
+    if not (tkn is Whitespace and val == '\n'):  # Check for EOL token.
+      raise AssertionError('Expected : %s , %r \n\nGot : %s , %r' % \
+                                  (Whitespace, u'\n', tkn, val))
+    if attrs :
+      # Test parsing and compilation
+      print
+      print "*****\n* Parsing\n*****",
+      from api import GVizUnsupportedQueryOp
+      try:
+        expr = p.parse(expr)
+      except GVizUnsupportedQueryOp :
+        print '\nNotSupported  :(',
+      except GVizInvalidQuery, exc :
+        print 
+        print exc.message
+      else:
+        for attrnm in attrs :
+          print
+          print getattr(expr, attrnm),
+        # Test evaluation and transformations on result sets
+        print
+        print "*****\n* Result\n*****",
+        try:
+          schema, data = expr.transform(TEST_DATA_GVIZSCHEMA, \
+                                        TEST_DATA_GVIZDATA)
+        except Exception, exc:
+          print
+          print exc.__class__.__name__, ' : ', exc.message,
+        else:
+          print
+          print "= Columns =",
+          if isinstance(schema, dict):
+            def iter_schema():
+              return ((k,) + v for k, v in schema.iteritems())
+          else:
+            iter_schema = lambda : schema
+          for col in iter_schema() :
             print
-          else:
-            newline = True
-          print tkn, val,
-      if not (tkn is Whitespace and val == '\n'):  # Check for EOL token.
-        raise AssertionError('Expected : %s , %r \n\nGot : %s , %r' % \
-                                    (Whitespace, u'\n', tkn, val))
-      if attrs :
-        # Test parsing and compilation
-        print
-        print "*****\n* Parsing\n*****",
-        from api import GVizUnsupportedQueryOp
-        try:
-          expr = p.parse(expr)
-        except GVizUnsupportedQueryOp :
-          print '\nNotSupported  :(',
-        except GVizInvalidQuery, exc :
+            print col[0], col[1],
+            try :
+              print col[2],
+            except IndexError :
+              pass
           print 
-          print exc.message
-        else:
-          for attrnm in attrs :
-            print
-            print getattr(expr, attrnm),
-          # Test evaluation and transformations on result sets
-          print
-          print "*****\n* Result\n*****",
-          try:
-            schema, data = expr.transform(TEST_DATA_GVIZSCHEMA, \
-                                          TEST_DATA_GVIZDATA)
-          except Exception, exc:
-            print
-            print exc.__class__.__name__, ' : ', exc.message,
-          else:
-            print
-            print "= Columns =",
-            if isinstance(schema, dict):
-              def iter_schema():
-                return ((k,) + v for k, v in schema.iteritems())
-            else:
-              iter_schema = lambda : schema
-            for col in iter_schema() :
-              print
-              print col[0], col[1],
-              try :
-                print col[2],
-              except IndexError :
-                pass
-            print 
-            for row in data :
-              print "= Row ="
-              for val, col in izip(row, iter_schema()):
-                print '  ', col[0], '=', val
-    
-    l = MultiTestLoader([defaultTestLoader, \
-                          DocTestLoader(
-                              extraglobs=dict(parse=parse),
-                              optionflags=ELLIPSIS \
-                                          | NORMALIZE_WHITESPACE \
-  #                                        | REPORT_UDIFF \
-                            )])
-    return l.loadTestsFromModule(sys.modules[__name__])
+          for row in data :
+            print "= Row ="
+            for val, col in izip(row, iter_schema()):
+              print '  ', col[0], '=', val
   
+  l = MultiTestLoader([defaultTestLoader, \
+                        DocTestLoader(
+                            extraglobs=dict(parse=parse),
+                            optionflags=ELLIPSIS \
+                                        | NORMALIZE_WHITESPACE \
+#                                        | REPORT_UDIFF \
+                          )])
+  return l.loadTestsFromModule(sys.modules[__name__])
+

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

-
-r"""Test cases and test data for GViz QL support.
-"""
-__author__ = 'Olemis Lang'
-
-from datetime import date, time, datetime
-
-TEST_DATA_GVIZDATA = [ \
-    ('John', 'Eng', time(12,0,0), 1000, date(2005,3,19), 35, True, datetime(2007,12,2,15,56,0)),
-    ('Dave', 'Eng', time(12,0,0), 500, date(2006,4,19), 27, False, None),
-    ('Sally', 'Eng', time(13,0,0), 600, date(2005,10,10), 30, False, None),
-    ('Ben', 'Sales', time(12,0,0), 400, date(2002,10,10), 32, True, datetime(2005,3,9,12,30,0)),
-    ('Dana', 'Sales', time(12,0,0), 350, date(2004,9,8), 25, False, None),
-    ('Mike', 'Marketing', time(13,0,0), 800, date(2005,1,10), 24, True, datetime(2007,12,30,14,40,0)),
-  ]
-
-#TEST_DATA_GVIZDATA = dict([item for row in TEST_DATA_GVIZDATA \
-#                            for item in izip( \
-#                                ('name', 'dept', 'lunchTime', \
-#                                  'salary', 'hireDate', 'age', \
-#                                  'isSenior', 'seniorityStartTime'), \
-#                                row)])
-
-TEST_DATA_GVIZSCHEMA = [
-    ('name', 'string'), ('dept', 'string'), ('lunchTime', 'timeofday'), \
-    ('salary', 'number'), ('hireDate', 'date'), ('age', 'number'), \
-    ('isSenior', 'boolean'), ('seniorityStartTime', 'datetime') \
-  ]
-
-#TEST_DATA_GVIZSCHEMA = dict([k, (v,)] for k,v in TEST_DATA_GVIZSCHEMA)
-
-__test__ = {
-  'Parser setup' : r"""
-      >>> kwds = (getattr(GVizQLParser, 'GVIZ_QL_' + a) \
-      ...           for a in ['KEYWS', 'OPS', 'FUNCS', 'CONST', 'CPREF'])
-      ...
-      >>> kwds = sum(kwds, [])
-      >>> print ' '.join(sorted(set(kwds)))
-      ...                             #doctest: +NORMALIZE_WHITESPACE 
-      ... 
-      and asc avg by count date datetime desc false 
-      format from group is label limit max min not null 
-      offset options or order pivot select sum timeofday 
-      timestamp true where
-      """,
-  'Parsing SELECT (simple)' : r"""
-      >>> parse("  select *  ", 'cols')
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved select
-      Token.Name.Other *
-      *****
-      * Parsing
-      *****
-      None
-      *****
-      * Result
-      *****
-      = Columns =
-      name string
-      dept string
-      lunchTime timeofday
-      salary number
-      hireDate date
-      age number
-      isSenior boolean
-      seniorityStartTime datetime
-      = Row =
-         name = John
-         dept = Eng
-         lunchTime = 12:00:00
-         salary = 1000
-         hireDate = 2005-03-19
-         age = 35
-         isSenior = True
-         seniorityStartTime = 2007-12-02 15:56:00
-      = Row =
-         name = Dave
-         dept = Eng
-         lunchTime = 12:00:00
-         salary = 500
-         hireDate = 2006-04-19
-         age = 27
-         isSenior = False
-         seniorityStartTime = None
-      = Row =
-         name = Sally
-         dept = Eng
-         lunchTime = 13:00:00
-         salary = 600
-         hireDate = 2005-10-10
-         age = 30
-         isSenior = False
-         seniorityStartTime = None
-      = Row =
-         name = Ben
-         dept = Sales
-         lunchTime = 12:00:00
-         salary = 400
-         hireDate = 2002-10-10
-         age = 32
-         isSenior = True
-         seniorityStartTime = 2005-03-09 12:30:00
-      = Row =
-         name = Dana
-         dept = Sales
-         lunchTime = 12:00:00
-         salary = 350
-         hireDate = 2004-09-08
-         age = 25
-         isSenior = False
-         seniorityStartTime = None
-      = Row =
-         name = Mike
-         dept = Marketing
-         lunchTime = 13:00:00
-         salary = 800
-         hireDate = 2005-01-10
-         age = 24
-         isSenior = True
-         seniorityStartTime = 2007-12-30 14:40:00
-      
-      >>> parse("  select `group`, selectme ", 'cols')
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved select
-      Token.Name.Variable `group`
-      Token.Punctuation ,
-      Token.Name.Variable selectme
-      *****
-      * Parsing
-      *****
-      [u'group', u'selectme']
-      *****
-      * Result
-      *****
-      GVizInvalidQuery  :  Unable to evaluate SELECT clause. Unknown column group.
-      
-      >>> parse("select dept, salary  ", 'cols')
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved select
-      Token.Name.Variable dept
-      Token.Punctuation ,
-      Token.Name.Variable salary
-      *****
-      * Parsing
-      *****
-      [u'dept', u'salary']
-      *****
-      * Result
-      *****
-      = Columns =
-      dept string
-      salary number
-      = Row =
-         dept = Eng
-         salary = 1000
-      = Row =
-         dept = Eng
-         salary = 500
-      = Row =
-         dept = Eng
-         salary = 600
-      = Row =
-         dept = Sales
-         salary = 400
-      = Row =
-         dept = Sales
-         salary = 350
-      = Row =
-         dept = Marketing
-         salary = 800
-      
-      >>> parse("select `email address`, name, `date`", 'cols')
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved select
-      Token.Name.Variable `email address`
-      Token.Punctuation ,
-      Token.Name.Variable name
-      Token.Punctuation ,
-      Token.Name.Variable `date`
-      *****
-      * Parsing
-      *****
-      [u'email address', u'name', u'date']
-      *****
-      * Result
-      *****
-      GVizInvalidQuery  :  Unable to evaluate SELECT clause. Unknown column email address.
-      
-      >>> parse("select lunchTime , name", 'cols')
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved select
-      Token.Name.Variable lunchTime
-      Token.Punctuation ,
-      Token.Name.Variable name
-      *****
-      * Parsing
-      *****
-      [u'lunchTime', u'name']
-      *****
-      * Result
-      *****
-      = Columns =
-      lunchTime timeofday
-      name string
-      = Row =
-         lunchTime = 12:00:00
-         name = John
-      = Row =
-         lunchTime = 12:00:00
-         name = Dave
-      = Row =
-         lunchTime = 13:00:00
-         name = Sally
-      = Row =
-         lunchTime = 12:00:00
-         name = Ben
-      = Row =
-         lunchTime = 12:00:00
-         name = Dana
-      = Row =
-         lunchTime = 13:00:00
-         name = Mike      
-      >>> parse("select    name ", 'cols')
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved select
-      Token.Name.Variable name
-      *****
-      * Parsing
-      *****
-      [u'name']
-      *****
-      * Result
-      *****
-      = Columns =
-      name string
-      = Row =
-         name = John
-      = Row =
-         name = Dave
-      = Row =
-         name = Sally
-      = Row =
-         name = Ben
-      = Row =
-         name = Dana
-      = Row =
-         name = Mike
-      """,
-  'Parsing SELECT (complex)' : r"""
-      >>> parse("select    max(salary)", 'cols')
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved select
-      Token.Name.Builtin max
-      Token.Punctuation (
-      Token.Name.Variable salary
-      Token.Punctuation )
-      *****
-      * Parsing
-      *****
-      NotSupported  :(
-      """,
-  'Parsing FROM' : r"""
-      >>> parse("  from employees", 'basetable') 
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved from
-      Token.Name.Variable employees
-      *****
-      * Parsing
-      *****
-      employees
-      *****
-      * Result
-      *****
-      GVizInvalidQuery  :  Unable to evaluate FROM clause. 
-                    Data source doesn't contain base table employees.
-     
-      >>> parse("from `employees`", 'basetable')
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved from
-      Token.Name.Variable `employees`
-      *****
-      * Parsing
-      *****
-      employees
-      *****
-      * Result
-      *****
-      GVizInvalidQuery  :  Unable to evaluate FROM clause. 
-                    Data source doesn't contain base table employees.
-      
-      >>> parse("select dept , salary from emp_data", 'basetable', 'cols')
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved select
-      Token.Name.Variable dept
-      Token.Punctuation ,
-      Token.Name.Variable salary
-      Token.Keyword.Reserved from
-      Token.Name.Variable emp_data
-      *****
-      * Parsing
-      *****
-      emp_data
-      [u'dept', u'salary']
-      *****
-      * Result
-      *****
-      GVizInvalidQuery  :  Unable to evaluate FROM clause. 
-                      Data source doesn't contain base table emp_data.
-      """,
-  'Parsing WHERE (simple)' : r"""
-      >>> parse("where salary >= 600", 'filter')
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved where
-      Token.Name.Variable salary
-      Token.Operator >=
-      Token.Literal.Number.Integer 600
-      *****
-      * Parsing
-      *****
-      NotSupported  :(
-      
-      >>> parse("where dept != 'Eng' and date '2005-01-21' < hireDate", \
-      ...       'filter')
-      ... 
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved where
-      Token.Name.Variable dept
-      Token.Operator !=
-      Token.Literal.String.Single 'Eng'
-      Token.Operator.Word and
-      Token.Literal.Date date '2005-01-21'
-      Token.Operator <
-      Token.Name.Variable hireDate
-      *****
-      * Parsing
-      *****
-      NotSupported  :(
-      
-      >>> parse("where salary > 700", 'filter')
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved where
-      Token.Name.Variable salary
-      Token.Operator >
-      Token.Literal.Number.Integer 700
-      *****
-      * Parsing
-      *****
-      NotSupported  :(
-      
-      >>> parse("where salary > 700.35", 'filter')
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved where
-      Token.Name.Variable salary
-      Token.Operator >
-      Token.Literal.Number 700.35
-      *****
-      * Parsing
-      *****
-      NotSupported  :(
-      
-      >>> parse("select name where salary > 700", 'filter', 'cols')
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved select
-      Token.Name.Variable name
-      Token.Keyword.Reserved where
-      Token.Name.Variable salary
-      Token.Operator >
-      Token.Literal.Number.Integer 700
-      *****
-      * Parsing
-      *****
-      NotSupported  :(
-      
-      """,
-  'Parsing WHERE (complex)' : r"""
-      >>> parse("where (dept<>'Eng' and isSenior=true) or " \
-      ...       "(dept='Sales') or seniorityStartTime is null", 'filter')
-      ...
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved where
-      Token.Punctuation (
-      Token.Name.Variable dept
-      Token.Operator <>
-      Token.Literal.String.Single 'Eng'
-      Token.Operator.Word and
-      Token.Name.Variable isSenior
-      Token.Operator =
-      Token.Name.Variable true
-      Token.Punctuation )
-      Token.Operator.Word or
-      Token.Punctuation (
-      Token.Name.Variable dept
-      Token.Operator =
-      Token.Literal.String.Single 'Sales'
-      Token.Punctuation )
-      Token.Operator.Word or
-      Token.Name.Variable seniorityStartTime
-      Token.Operator.Word is
-      Token.Keyword.Constant null
-      *****
-      * Parsing
-      *****
-      NotSupported  :(
-      
-      """,
-  'Parsing GROUP BY (simple)' : r"""
-      >>> parse("select dept  group by   dept", 'aggregate', 'cols')
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved select
-      Token.Name.Variable dept
-      Token.Keyword.Reserved group by
-      Token.Name.Variable dept
-      *****
-      * Parsing
-      *****
-      NotSupported  :(
-      
-      >>> parse("select dept, max(salary) group by   dept   ", \
-      ...           'aggregate', 'cols')
-      ... 
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved select
-      Token.Name.Variable dept
-      Token.Punctuation ,
-      Token.Name.Builtin max
-      Token.Punctuation (
-      Token.Name.Variable salary
-      Token.Punctuation )
-      Token.Keyword.Reserved group by
-      Token.Name.Variable dept
-      *****
-      * Parsing
-      *****
-      NotSupported  :(
-      
-      >>> parse("select lunchTime, avg(salary), count(age) " \
-      ...       "group by    isSenior,lunchTime", \
-      ...           'aggregate', 'cols')
-      ... 
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved select
-      Token.Name.Variable lunchTime
-      Token.Punctuation ,
-      Token.Name.Builtin avg
-      Token.Punctuation (
-      Token.Name.Variable salary
-      Token.Punctuation )
-      Token.Punctuation ,
-      Token.Name.Builtin count
-      Token.Punctuation (
-      Token.Name.Variable age
-      Token.Punctuation )
-      Token.Keyword.Reserved group by
-      Token.Name.Variable isSenior
-      Token.Punctuation ,
-      Token.Name.Variable lunchTime
-      *****
-      * Parsing
-      *****
-      NotSupported  :(
-      """,
-  'Parsing GROUP BY (complex)' : r"""
-      """,
-  'Parsing PIVOT (simple)' : r"""
-      >>> parse("select dept  pivot    dept, salary , lunchTime", 
-      ...           'pivot', 'cols')
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved select
-      Token.Name.Variable dept
-      Token.Keyword.Reserved pivot
-      Token.Name.Variable dept
-      Token.Punctuation ,
-      Token.Name.Variable salary
-      Token.Punctuation ,
-      Token.Name.Variable lunchTime
-      *****
-      * Parsing
-      *****
-      NotSupported  :(
-      
-      >>> parse("select dept  pivot    dept   ", 'pivot', 'cols')
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved select
-      Token.Name.Variable dept
-      Token.Keyword.Reserved pivot
-      Token.Name.Variable dept
-      *****
-      * Parsing
-      *****
-      NotSupported  :(
-      
-      >>> parse("select sum(salary) pivot dept", 'pivot', 'cols')
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved select
-      Token.Name.Builtin sum
-      Token.Punctuation (
-      Token.Name.Variable salary
-      Token.Punctuation )
-      Token.Keyword.Reserved pivot
-      Token.Name.Variable dept
-      *****
-      * Parsing
-      *****
-      NotSupported  :(
-      """,
-  'Parsing PIVOT (complex)' : r"""
-      >>> parse("select sum(salary) pivot dept, lunchTime", 'pivot', \
-      ...           'cols')
-      ...
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved select
-      Token.Name.Builtin sum
-      Token.Punctuation (
-      Token.Name.Variable salary
-      Token.Punctuation )
-      Token.Keyword.Reserved pivot
-      Token.Name.Variable dept
-      Token.Punctuation ,
-      Token.Name.Variable lunchTime
-      *****
-      * Parsing
-      *****
-      NotSupported  :(
-      
-      >>> parse("select sum(salary), max(lunchTime) pivot dept", \
-      ...           'pivot', 'cols')
-      ...
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved select
-      Token.Name.Builtin sum
-      Token.Punctuation (
-      Token.Name.Variable salary
-      Token.Punctuation )
-      Token.Punctuation ,
-      Token.Name.Builtin max
-      Token.Punctuation (
-      Token.Name.Variable lunchTime
-      Token.Punctuation )
-      Token.Keyword.Reserved pivot
-      Token.Name.Variable dept
-      *****
-      * Parsing
-      *****
-      NotSupported  :(
-      
-      >>> parse("select dept, sum(salary) group by dept pivot lunchTime", \
-      ...           'pivot', 'cols', 'aggregate')
-      ...
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved select
-      Token.Name.Variable dept
-      Token.Punctuation ,
-      Token.Name.Builtin sum
-      Token.Punctuation (
-      Token.Name.Variable salary
-      Token.Punctuation )
-      Token.Keyword.Reserved group by
-      Token.Name.Variable dept
-      Token.Keyword.Reserved pivot
-      Token.Name.Variable lunchTime
-      *****
-      * Parsing
-      *****
-      NotSupported  :(
-      
-      >>> parse("select lunchTime, sum(salary) group by lunchTime " \
-      ...       "pivot dept", 'pivot', 'cols', 'aggregate')
-      ...
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved select
-      Token.Name.Variable lunchTime
-      Token.Punctuation ,
-      Token.Name.Builtin sum
-      Token.Punctuation (
-      Token.Name.Variable salary
-      Token.Punctuation )
-      Token.Keyword.Reserved group by
-      Token.Name.Variable lunchTime
-      Token.Keyword.Reserved pivot
-      Token.Name.Variable dept
-      *****
-      * Parsing
-      *****
-      NotSupported  :(
-      """,
-  'Parsing ORDER BY (simple)' : r"""
-      >>> parse("order by   dept , salary desc   ", 'sort')
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved order by
-      Token.Name.Variable dept
-      Token.Punctuation ,
-      Token.Name.Variable salary
-      Token.Keyword desc
-      *****
-      * Parsing
-      *****
-      NotSupported  :(
-      
-      >>> parse("  select dept , lunchTime   group by dept "
-      ...       "   order by dept", 'sort', 'aggregate', 'cols')
-      ... 
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved select
-      Token.Name.Variable dept
-      Token.Punctuation ,
-      Token.Name.Variable lunchTime
-      Token.Keyword.Reserved group by
-      Token.Name.Variable dept
-      Token.Keyword.Reserved order by
-      Token.Name.Variable dept
-      *****
-      * Parsing
-      *****
-      NotSupported  :(
-      """,
-  'Parsing ORDER BY (complex)' : r"""
-      >>> parse("  select dept , max(salary)   group by dept "
-      ...      "   order by max(salary)", 'sort', 'aggregate', 'cols')
-      ... 
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved select
-      Token.Name.Variable dept
-      Token.Punctuation ,
-      Token.Name.Builtin max
-      Token.Punctuation (
-      Token.Name.Variable salary
-      Token.Punctuation )
-      Token.Keyword.Reserved group by
-      Token.Name.Variable dept
-      Token.Keyword.Reserved order by
-      Token.Name.Builtin max
-      Token.Punctuation (
-      Token.Name.Variable salary
-      Token.Punctuation )
-      *****
-      * Parsing
-      *****
-      NotSupported  :(
-      
-      >>> parse("  select dept , min(lunchTime)   group by dept "
-      ...       "   order by max(salary)", 'sort', 'aggregate', 'cols')
-      ... 
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved select
-      Token.Name.Variable dept
-      Token.Punctuation ,
-      Token.Name.Builtin min
-      Token.Punctuation (
-      Token.Name.Variable lunchTime
-      Token.Punctuation )
-      Token.Keyword.Reserved group by
-      Token.Name.Variable dept
-      Token.Keyword.Reserved order by
-      Token.Name.Builtin max
-      Token.Punctuation (
-      Token.Name.Variable salary
-      Token.Punctuation )
-      *****
-      * Parsing
-      *****
-      NotSupported  :(
-      """,
-  'Parsing LIMIT' : r"""
-      >>> parse("limit 4", 'cnt')
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved limit
-      Token.Literal.Number.Integer 4
-      *****
-      * Parsing
-      *****
-      4
-      *****
-      * Result
-      *****
-      = Columns =
-      name string
-      dept string
-      lunchTime timeofday
-      salary number
-      hireDate date
-      age number
-      isSenior boolean
-      seniorityStartTime datetime
-      = Row =
-         name = John
-         dept = Eng
-         lunchTime = 12:00:00
-         salary = 1000
-         hireDate = 2005-03-19
-         age = 35
-         isSenior = True
-         seniorityStartTime = 2007-12-02 15:56:00
-      = Row =
-         name = Dave
-         dept = Eng
-         lunchTime = 12:00:00
-         salary = 500
-         hireDate = 2006-04-19
-         age = 27
-         isSenior = False
-         seniorityStartTime = None
-      = Row =
-         name = Sally
-         dept = Eng
-         lunchTime = 13:00:00
-         salary = 600
-         hireDate = 2005-10-10
-         age = 30
-         isSenior = False
-         seniorityStartTime = None
-      = Row =
-         name = Ben
-         dept = Sales
-         lunchTime = 12:00:00
-         salary = 400
-         hireDate = 2002-10-10
-         age = 32
-         isSenior = True
-         seniorityStartTime = 2005-03-09 12:30:00
-      
-      >>> parse(" select `name`    limit   2  ", 'cnt', 'cols')
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved select
-      Token.Name.Variable `name`
-      Token.Keyword.Reserved limit
-      Token.Literal.Number.Integer 2
-      *****
-      * Parsing
-      *****
-      2
-      [u'name']
-      *****
-      * Result
-      *****
-      = Columns =
-      name string
-      = Row =
-         name = John
-      = Row =
-         name = Dave
-      
-      >>> parse("  select dept , lunchTime   group by dept "
-      ...       "   order by dept limit 100", 'cnt', 'cols', 'aggregate')
-      ... 
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved select
-      Token.Name.Variable dept
-      Token.Punctuation ,
-      Token.Name.Variable lunchTime
-      Token.Keyword.Reserved group by
-      Token.Name.Variable dept
-      Token.Keyword.Reserved order by
-      Token.Name.Variable dept
-      Token.Keyword.Reserved limit
-      Token.Literal.Number.Integer 100
-      *****
-      * Parsing
-      *****
-      NotSupported  :(
-      """,
-  'Parsing OFFSET' : r"""
-      >>> parse("offset 2", 'skip')
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved offset
-      Token.Literal.Number.Integer 2
-      *****
-      * Parsing
-      *****
-      2
-      *****
-      * Result
-      *****
-      = Columns =
-      name string
-      dept string
-      lunchTime timeofday
-      salary number
-      hireDate date
-      age number
-      isSenior boolean
-      seniorityStartTime datetime
-      = Row =
-         name = Sally
-         dept = Eng
-         lunchTime = 13:00:00
-         salary = 600
-         hireDate = 2005-10-10
-         age = 30
-         isSenior = False
-         seniorityStartTime = None
-      = Row =
-         name = Ben
-         dept = Sales
-         lunchTime = 12:00:00
-         salary = 400
-         hireDate = 2002-10-10
-         age = 32
-         isSenior = True
-         seniorityStartTime = 2005-03-09 12:30:00
-      = Row =
-         name = Dana
-         dept = Sales
-         lunchTime = 12:00:00
-         salary = 350
-         hireDate = 2004-09-08
-         age = 25
-         isSenior = False
-         seniorityStartTime = None
-      = Row =
-         name = Mike
-         dept = Marketing
-         lunchTime = 13:00:00
-         salary = 800
-         hireDate = 2005-01-10
-         age = 24
-         isSenior = True
-         seniorityStartTime = 2007-12-30 14:40:00
-      
-      >>> parse(" select *    limit 2 offset   3  ", 'skip', 'cnt', 'cols')
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved select
-      Token.Name.Other *
-      Token.Keyword.Reserved limit
-      Token.Literal.Number.Integer 2
-      Token.Keyword.Reserved offset
-      Token.Literal.Number.Integer 3
-      *****
-      * Parsing
-      *****
-      3
-      2
-      None
-      *****
-      * Result
-      *****
-      = Columns =
-      name string
-      dept string
-      lunchTime timeofday
-      salary number
-      hireDate date
-      age number
-      isSenior boolean
-      seniorityStartTime datetime
-      = Row =
-         name = Ben
-         dept = Sales
-         lunchTime = 12:00:00
-         salary = 400
-         hireDate = 2002-10-10
-         age = 32
-         isSenior = True
-         seniorityStartTime = 2005-03-09 12:30:00
-      = Row =
-         name = Dana
-         dept = Sales
-         lunchTime = 12:00:00
-         salary = 350
-         hireDate = 2004-09-08
-         age = 25
-         isSenior = False
-         seniorityStartTime = None
-      
-      >>> parse("  select dept , lunchTime   group by dept "
-      ...       " order by dept limit 25  offset 100 ", 'skip', 'cols', \
-      ...           'aggregate', 'cnt', 'sort')
-      ... 
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved select
-      Token.Name.Variable dept
-      Token.Punctuation ,
-      Token.Name.Variable lunchTime
-      Token.Keyword.Reserved group by
-      Token.Name.Variable dept
-      Token.Keyword.Reserved order by
-      Token.Name.Variable dept
-      Token.Keyword.Reserved limit
-      Token.Literal.Number.Integer 25
-      Token.Keyword.Reserved offset
-      Token.Literal.Number.Integer 100
-      *****
-      * Parsing
-      *****
-      NotSupported  :(
-      """,
-  'Parsing LABEL' : r"""
-      >>> parse("select name label    dept 'Department' , " \
-      ...           "name 'Employee Id' ", 'labels', 'cols')
-      ... 
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved select
-      Token.Name.Variable name
-      Token.Keyword.Reserved label
-      Token.Name.Variable dept
-      Token.Literal.String.Single 'Department'
-      Token.Punctuation ,
-      Token.Name.Variable name
-      Token.Literal.String.Single 'Employee Id'
-      *****
-      * Parsing
-      *****
-      [(u'dept', u'Department'), (u'name', u'Employee Id')]
-      [u'name']
-      *****
-      * Result
-      *****
-      = Columns =
-      name string Employee Id
-      = Row =
-         name = John
-      = Row =
-         name = Dave
-      = Row =
-         name = Sally
-      = Row =
-         name = Ben
-      = Row =
-         name = Dana
-      = Row =
-         name = Mike
-      
-      >>> parse("select *  label    dept 'Department'  , " \
-      ...       "name    'Employee Id'      ", 'labels', 'cols')
-      ... 
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved select
-      Token.Name.Other *
-      Token.Keyword.Reserved label
-      Token.Name.Variable dept
-      Token.Literal.String.Single 'Department'
-      Token.Punctuation ,
-      Token.Name.Variable name
-      Token.Literal.String.Single 'Employee Id'
-      *****
-      * Parsing
-      *****
-      [(u'dept', u'Department'), (u'name', u'Employee Id')]
-      None
-      *****
-      * Result
-      *****
-      = Columns =
-      name string Employee Id
-      dept string Department
-      lunchTime timeofday
-      salary number
-      hireDate date
-      age number
-      isSenior boolean
-      seniorityStartTime datetime
-      = Row =
-         name = John
-         dept = Eng
-         lunchTime = 12:00:00
-         salary = 1000
-         hireDate = 2005-03-19
-         age = 35
-         isSenior = True
-         seniorityStartTime = 2007-12-02 15:56:00
-      = Row =
-         name = Dave
-         dept = Eng
-         lunchTime = 12:00:00
-         salary = 500
-         hireDate = 2006-04-19
-         age = 27
-         isSenior = False
-         seniorityStartTime = None
-      = Row =
-         name = Sally
-         dept = Eng
-         lunchTime = 13:00:00
-         salary = 600
-         hireDate = 2005-10-10
-         age = 30
-         isSenior = False
-         seniorityStartTime = None
-      = Row =
-         name = Ben
-         dept = Sales
-         lunchTime = 12:00:00
-         salary = 400
-         hireDate = 2002-10-10
-         age = 32
-         isSenior = True
-         seniorityStartTime = 2005-03-09 12:30:00
-      = Row =
-         name = Dana
-         dept = Sales
-         lunchTime = 12:00:00
-         salary = 350
-         hireDate = 2004-09-08
-         age = 25
-         isSenior = False
-         seniorityStartTime = None
-      = Row =
-         name = Mike
-         dept = Marketing
-         lunchTime = 13:00:00
-         salary = 800
-         hireDate = 2005-01-10
-         age = 24
-         isSenior = True
-         seniorityStartTime = 2007-12-30 14:40:00
-      
-      >>> parse(r'''label dept 'Department', ''' \
-      ...         '''name "Employee Name", ''' \
-      ...         '''location 'Employee Location' ''', 'labels')
-      ... 
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved label
-      Token.Name.Variable dept
-      Token.Literal.String.Single 'Department'
-      Token.Punctuation ,
-      Token.Name.Variable name
-      Token.Literal.String.Double "Employee Name"
-      Token.Punctuation ,
-      Token.Name.Variable location
-      Token.Literal.String.Single 'Employee Location'
-      *****
-      * Parsing
-      *****
-      [(u'dept', u'Department'), (u'name', u'Employee Name'), 
-          (u'location', u'Employee Location')]
-      *****
-      * Result
-      *****
-      = Columns =
-      name string Employee Name
-      dept string Department
-      lunchTime timeofday
-      salary number
-      hireDate date
-      age number
-      isSenior boolean
-      seniorityStartTime datetime
-      = Row =
-         name = John
-         dept = Eng
-         lunchTime = 12:00:00
-         salary = 1000
-         hireDate = 2005-03-19
-         age = 35
-         isSenior = True
-         seniorityStartTime = 2007-12-02 15:56:00
-      = Row =
-         name = Dave
-         dept = Eng
-         lunchTime = 12:00:00
-         salary = 500
-         hireDate = 2006-04-19
-         age = 27
-         isSenior = False
-         seniorityStartTime = None
-      = Row =
-         name = Sally
-         dept = Eng
-         lunchTime = 13:00:00
-         salary = 600
-         hireDate = 2005-10-10
-         age = 30
-         isSenior = False
-         seniorityStartTime = None
-      = Row =
-         name = Ben
-         dept = Sales
-         lunchTime = 12:00:00
-         salary = 400
-         hireDate = 2002-10-10
-         age = 32
-         isSenior = True
-         seniorityStartTime = 2005-03-09 12:30:00
-      = Row =
-         name = Dana
-         dept = Sales
-         lunchTime = 12:00:00
-         salary = 350
-         hireDate = 2004-09-08
-         age = 25
-         isSenior = False
-         seniorityStartTime = None
-      = Row =
-         name = Mike
-         dept = Marketing
-         lunchTime = 13:00:00
-         salary = 800
-         hireDate = 2005-01-10
-         age = 24
-         isSenior = True
-         seniorityStartTime = 2007-12-30 14:40:00
-      """,
-  'Parsing FORMAT' : r"""
-      >>> parse("  format  salary   '#,##0.00' ", 'fmt')
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved format
-      Token.Name.Variable salary
-      Token.Literal.String.Single '#,##0.00'
-      *****
-      * Parsing
-      *****
-      NotSupported  :(
-      
-      >>> parse("  format  salary   '#,##0.00' ," \
-      ...       "hireDate 'dd-MMM-yyyy',      " \
-      ...       "isSenior     'not yet:of course!'    ", 'fmt')
-      ... 
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved format
-      Token.Name.Variable salary
-      Token.Literal.String.Single '#,##0.00'
-      Token.Punctuation ,
-      Token.Name.Variable hireDate
-      Token.Literal.String.Single 'dd-MMM-yyyy'
-      Token.Punctuation ,
-      Token.Name.Variable isSenior
-      Token.Literal.String.Single 'not yet:of course!'
-      *****
-      * Parsing
-      *****
-      NotSupported  :(
-      
-      >>> parse("format salary '#,##0.00', hireDate 'dd-MMM-yyyy', "
-      ...       "isSenior 'Yes!:Not yet'", 'fmt')
-      ... 
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved format
-      Token.Name.Variable salary
-      Token.Literal.String.Single '#,##0.00'
-      Token.Punctuation ,
-      Token.Name.Variable hireDate
-      Token.Literal.String.Single 'dd-MMM-yyyy'
-      Token.Punctuation ,
-      Token.Name.Variable isSenior
-      Token.Literal.String.Single 'Yes!:Not yet'
-      *****
-      * Parsing
-      *****
-      NotSupported  :(
-      
-      >>> parse("select salary, hireDate, isSenior   , lunchTime "
-      ...       "format salary '#,##0.00', hireDate 'dd-MMM-yyyy', "
-      ...       "isSenior 'Yes!:Not yet'", 'fmt', 'cols')
-      ... 
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved select
-      Token.Name.Variable salary
-      Token.Punctuation ,
-      Token.Name.Variable hireDate
-      Token.Punctuation ,
-      Token.Name.Variable isSenior
-      Token.Punctuation ,
-      Token.Name.Variable lunchTime
-      Token.Keyword.Reserved format
-      Token.Name.Variable salary
-      Token.Literal.String.Single '#,##0.00'
-      Token.Punctuation ,
-      Token.Name.Variable hireDate
-      Token.Literal.String.Single 'dd-MMM-yyyy'
-      Token.Punctuation ,
-      Token.Name.Variable isSenior
-      Token.Literal.String.Single 'Yes!:Not yet'
-      *****
-      * Parsing
-      *****
-      NotSupported  :(
-      """,
-  'Parsing OPTIONS' : r"""
-      >>> parse("  select *  options    no_format   ", 'opts', 'cols')
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved select
-      Token.Name.Other *
-      Token.Keyword.Reserved options
-      Token.Name.Variable no_format
-      *****
-      * Parsing
-      *****
-      NotSupported  :(
-      
-      >>> parse("select dept , salary options no_values", 'opts', 'cols')
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved select
-      Token.Name.Variable dept
-      Token.Punctuation ,
-      Token.Name.Variable salary
-      Token.Keyword.Reserved options
-      Token.Name.Variable no_values
-      *****
-      * Parsing
-      *****
-      NotSupported  :(
-      
-      >>> parse("select `email address`, name, `date` options no_values", \
-      ...           'opts', 'cols')
-      ... 
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved select
-      Token.Name.Variable `email address`
-      Token.Punctuation ,
-      Token.Name.Variable name
-      Token.Punctuation ,
-      Token.Name.Variable `date`
-      Token.Keyword.Reserved options
-      Token.Name.Variable no_values
-      *****
-      * Parsing
-      *****
-      NotSupported  :(
-      """,
-    'Parsing (failures)' : r"""
-      >>> parse("  select ", 'cols', fail=True)
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved select
-      *****
-      * Parsing
-      *****
-      Syntax error or unsupported feature. Unexpected token <EOL>.
-      
-      >>> parse("  select 7group ", 'cols', fail=True)
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved select
-      Token.Generic.Error 7group
-      *****
-      * Parsing
-      *****
-      Syntax error or unsupported feature. Unexpected token 7group.
-      
-      >>> parse("  select $group ", 'cols', fail=True)
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved select
-      Token.Generic.Error $
-      Token.Keyword group
-      *****
-      * Parsing
-      *****
-      Syntax error or unsupported feature. Unexpected token $.
-      
-      >>> parse("  select group ", 'cols', fail=True)
-      *****
-      * Tokens
-      *****
-      Token.Keyword.Reserved select
-      Token.Keyword group
-      *****
-      * Parsing
-      *****
-      Syntax error or unsupported feature. Unexpected token group.
-      """
-  }

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

+
+r"""Test cases and test data for GViz QL support.
+"""
+__author__ = 'Olemis Lang'
+
+from datetime import date, time, datetime
+
+TEST_DATA_GVIZDATA = [ \
+    ('John', 'Eng', time(12,0,0), 1000, date(2005,3,19), 35, True, datetime(2007,12,2,15,56,0)),
+    ('Dave', 'Eng', time(12,0,0), 500, date(2006,4,19), 27, False, None),
+    ('Sally', 'Eng', time(13,0,0), 600, date(2005,10,10), 30, False, None),
+    ('Ben', 'Sales', time(12,0,0), 400, date(2002,10,10), 32, True, datetime(2005,3,9,12,30,0)),
+    ('Dana', 'Sales', time(12,0,0), 350, date(2004,9,8), 25, False, None),
+    ('Mike', 'Marketing', time(13,0,0), 800, date(2005,1,10), 24, True, datetime(2007,12,30,14,40,0)),
+  ]
+
+#TEST_DATA_GVIZDATA = dict([item for row in TEST_DATA_GVIZDATA \
+#                            for item in izip( \
+#                                ('name', 'dept', 'lunchTime', \
+#                                  'salary', 'hireDate', 'age', \
+#                                  'isSenior', 'seniorityStartTime'), \
+#                                row)])
+
+TEST_DATA_GVIZSCHEMA = [
+    ('name', 'string'), ('dept', 'string'), ('lunchTime', 'timeofday'), \
+    ('salary', 'number'), ('hireDate', 'date'), ('age', 'number'), \
+    ('isSenior', 'boolean'), ('seniorityStartTime', 'datetime') \
+  ]
+
+#TEST_DATA_GVIZSCHEMA = dict([k, (v,)] for k,v in TEST_DATA_GVIZSCHEMA)
+
+__test__ = {
+  'Parser setup' : r"""
+      >>> kwds = (getattr(GVizQLParser, 'GVIZ_QL_' + a) \
+      ...           for a in ['KEYWS', 'OPS', 'FUNCS', 'CONST', 'CPREF'])
+      ...
+      >>> kwds = sum(kwds, [])
+      >>> print ' '.join(sorted(set(kwds)))
+      ...                             #doctest: +NORMALIZE_WHITESPACE 
+      ... 
+      and asc avg by count date datetime desc false 
+      format from group is label limit max min not null 
+      offset options or order pivot select sum timeofday 
+      timestamp true where
+      """,
+  'Parsing SELECT (simple)' : r"""
+      >>> parse("  select *  ", 'cols')
+      *****
+      * Tokens
+      *****
+      Token.Keyword.Reserved select
+      Token.Name.Other *
+      *****
+      * Parsing
+      *****
+      None
+      *****
+      * Result
+      *****
+      = Columns =
+      name string
+      dept string
+      lunchTime timeofday
+      salary number
+      hireDate date
+      age number
+      isSenior boolean
+      seniorityStartTime datetime
+      = Row =
+         name = John
+         dept = Eng
+         lunchTime = 12:00:00
+         salary = 1000
+         hireDate = 2005-03-19
+         age = 35
+         isSenior = True
+         seniorityStartTime = 2007-12-02 15:56:00
+      = Row =
+         name = Dave
+         dept = Eng
+         lunchTime = 12:00:00
+         salary = 500
+         hireDate = 2006-04-19
+         age = 27
+         isSenior = False
+         seniorityStartTime = None
+      = Row =
+         name = Sally
+         dept = Eng
+         lunchTime = 13:00:00
+         salary = 600
+         hireDate = 2005-10-10
+         age = 30
+         isSenior = False
+         seniorityStartTime = None
+      = Row =
+         name = Ben
+         dept = Sales
+         lunchTime = 12:00:00
+         salary = 400
+         hireDate = 2002-10-10
+         age = 32
+         isSenior = True
+         seniorityStartTime = 2005-03-09 12:30:00
+      = Row =
+         name = Dana
+         dept = Sales
+         lunchTime = 12:00:00
+         salary = 350
+         hireDate = 2004-09-08
+         age = 25
+         isSenior = False
+         seniorityStartTime = None
+      = Row =
+         name = Mike
+         dept = Marketing
+         lunchTime = 13:00:00
+         salary = 800
+         hireDate = 2005-01-10
+         age = 24
+         isSenior = True
+         seniorityStartTime = 2007-12-30 14:40:00
+      
+      >>> parse("  select `group`, selectme ", 'cols')
+      *****
+      * Tokens
+      *****
+      Token.Keyword.Reserved select
+      Token.Name.Variable `group`
+      Token.Punctuation ,
+      Token.Name.Variable selectme
+      *****
+      * Parsing
+      *****
+      [u'group', u'selectme']
+      *****
+      * Result
+      *****
+      GVizInvalidQuery  :  Unable to evaluate SELECT clause. Unknown column group.
+      
+      >>> parse("select dept, salary  ", 'cols')
+      *****
+      * Tokens
+      *****
+      Token.Keyword.Reserved select
+      Token.Name.Variable dept
+      Token.Punctuation ,
+      Token.Name.Variable salary
+      *****
+      * Parsing
+      *****
+      [u'dept', u'salary']
+      *****
+      * Result
+      *****
+      = Columns =
+      dept string
+      salary number
+      = Row =
+         dept = Eng
+         salary = 1000
+      = Row =
+         dept = Eng
+         salary = 500
+      = Row =
+         dept = Eng
+         salary = 600
+      = Row =
+         dept = Sales
+         salary = 400
+      = Row =
+         dept = Sales
+         salary = 350
+      = Row =
+         dept = Marketing
+         salary = 800
+      
+      >>> parse("select `email address`, name, `date`", 'cols')
+      *****
+      * Tokens
+      *****
+      Token.Keyword.Reserved select
+      Token.Name.Variable `email address`
+      Token.Punctuation ,
+      Token.Name.Variable name
+      Token.Punctuation ,
+      Token.Name.Variable `date`
+      *****
+      * Parsing
+      *****
+      [u'email address', u'name', u'date']
+      *****
+      * Result
+      *****
+      GVizInvalidQuery  :  Unable to evaluate SELECT clause. Unknown column email address.
+      
+      >>> parse("select lunchTime , name", 'cols')
+      *****
+      * Tokens
+      *****
+      Token.Keyword.Reserved select
+      Token.Name.Variable lunchTime
+      Token.Punctuation ,
+      Token.Name.Variable name
+      *****
+      * Parsing
+      *****
+      [u'lunchTime', u'name']
+      *****
+      * Result
+      *****
+      = Columns =
+      lunchTime timeofday
+      name string
+      = Row =
+         lunchTime = 12:00:00
+         name = John
+      = Row =
+         lunchTime = 12:00:00
+         name = Dave
+      = Row =
+         lunchTime = 13:00:00
+         name = Sally
+      = Row =
+         lunchTime = 12:00:00
+         name = Ben
+      = Row =
+         lunchTime = 12:00:00
+         name = Dana
+      = Row =
+         lunchTime = 13:00:00
+         name = Mike      
+      >>> parse("select    name ", 'cols')
+      *****
+      * Tokens
+      *****
+      Token.Keyword.Reserved select
+      Token.Name.Variable name
+      *****
+      * Parsing
+      *****
+      [u'name']
+      *****
+      * Result
+      *****
+      = Columns =
+      name string
+      = Row =
+         name = John
+      = Row =
+         name = Dave
+      = Row =
+         name = Sally
+      = Row =
+         name = Ben
+      = Row =
+         name = Dana
+      = Row =
+         name = Mike
+      """,
+  'Parsing SELECT (complex)' : r"""
+      >>> parse("select    max(salary)", 'cols')
+      *****
+      * Tokens
+      *****
+      Token.Keyword.Reserved select
+      Token.Name.Builtin max
+      Token.Punctuation (
+      Token.Name.Variable salary
+      Token.Punctuation )
+      *****
+      * Parsing
+      *****
+      NotSupported  :(
+      """,
+  'Parsing FROM' : r"""
+      >>> parse("  from employees", 'basetable') 
+      *****
+      * Tokens
+      *****
+      Token.Keyword.Reserved from
+      Token.Name.Variable employees
+      *****
+      * Parsing
+      *****
+      employees
+      *****
+      * Result
+      *****
+      GVizInvalidQuery  :  Unable to evaluate FROM clause. 
+                    Data source doesn't contain base table employees.
+     
+      >>> parse("from `employees`", 'basetable')
+      *****
+      * Tokens
+      *****
+      Token.Keyword.Reserved from
+      Token.Name.Variable `employees`
+      *****
+      * Parsing
+      *****
+      employees
+      *****
+      * Result
+      *****
+      GVizInvalidQuery  :  Unable to evaluate FROM clause. 
+                    Data source doesn't contain base table employees.
+      
+      >>> parse("select dept , salary from emp_data", 'basetable', 'cols')
+      *****
+      * Tokens
+      *****
+      Token.Keyword.Reserved select
+      Token.Name.Variable dept
+      Token.Punctuation ,
+      Token.Name.Variable salary
+      Token.Keyword.Reserved from
+      Token.Name.Variable emp_data
+      *****
+      * Parsing
+      *****
+      emp_data
+      [u'dept', u'salary']
+      *****
+      * Result
+      *****
+      GVizInvalidQuery  :  Unable to evaluate FROM clause. 
+                      Data source doesn't contain base table emp_data.
+      """,
+  'Parsing WHERE (simple)' : r"""
+      >>> parse("where salary >= 600", 'filter')
+      *****
+      * Tokens
+      *****
+      Token.Keyword.Reserved where
+      Token.Name.Variable salary
+      Token.Operator >=
+      Token.Literal.Number.Integer 600
+      *****
+      * Parsing
+      *****
+      NotSupported  :(
+      
+      >>> parse("where dept != 'Eng' and date '2005-01-21' < hireDate", \
+      ...       'filter')
+      ... 
+      *****
+      * Tokens
+      *****
+      Token.Keyword.Reserved where
+      Token.Name.Variable dept
+      Token.Operator !=
+      Token.Literal.String.Single 'Eng'
+      Token.Operator.Word and
+      Token.Literal.Date date '2005-01-21'
+      Token.Operator <
+      Token.Name.Variable hireDate
+      *****
+      * Parsing
+      *****
+      NotSupported  :(
+      
+      >>> parse("where salary > 700", 'filter')
+      *****
+      * Tokens
+      *****
+      Token.Keyword.Reserved where
+      Token.Name.Variable salary
+      Token.Operator >
+      Token.Literal.Number.Integer 700
+      *****
+      * Parsing
+      *****
+      NotSupported  :(
+      
+      >>> parse("where salary > 700.35", 'filter')
+      *****
+      * Tokens
+      *****
+      Token.Keyword.Reserved where
+      Token.Name.Variable salary
+      Token.Operator >
+      Token.Literal.Number 700.35
+      *****
+      * Parsing
+      *****
+      NotSupported  :(
+      
+      >>> parse("select name where salary > 700", 'filter', 'cols')
+      *****
+      * Tokens
+      *****
+      Token.Keyword.Reserved select
+      Token.Name.Variable name
+      Token.Keyword.Reserved where
+      Token.Name.Variable salary
+      Token.Operator >
+      Token.Literal.Number.Integer 700
+      *****
+      * Parsing
+      *****
+      NotSupported  :(
+      
+      """,
+  'Parsing WHERE (complex)' : r"""
+      >>> parse("where (dept<>'Eng' and isSenior=true) or " \
+      ...       "(dept='Sales') or seniorityStartTime is null", 'filter')
+      ...
+      *****
+      * Tokens
+      *****
+      Token.Keyword.Reserved where
+      Token.Punctuation (
+      Token.Name.Variable dept
+      Token.Operator <>
+      Token.Literal.String.Single 'Eng'
+      Token.Operator.Word and
+      Token.Name.Variable isSenior
+      Token.Operator =
+      Token.Name.Variable true
+      Token.Punctuation )
+      Token.Operator.Word or
+      Token.Punctuation (
+      Token.Name.Variable dept
+      Token.Operator =
+      Token.Literal.String.Single 'Sales'
+      Token.Punctuation )
+      Token.Operator.Word or
+      Token.Name.Variable seniorityStartTime
+      Token.Operator.Word is
+      Token.Keyword.Constant null
+      *****
+      * Parsing
+      *****
+      NotSupported  :(
+      
+      """,
+  'Parsing GROUP BY (simple)' : r"""
+      >>> parse("select dept  group by   dept", 'aggregate', 'cols')
+      *****
+      * Tokens
+      *****
+      Token.Keyword.Reserved select
+      Token.Name.Variable dept
+      Token.Keyword.Reserved group by
+      Token.Name.Variable dept
+      *****
+      * Parsing
+      *****
+      NotSupported  :(
+      
+      >>> parse("select dept, max(salary) group by   dept   ", \
+      ...           'aggregate', 'cols')
+      ... 
+      *****
+      * Tokens
+      *****
+      Token.Keyword.Reserved select
+      Token.Name.Variable dept
+      Token.Punctuation ,
+      Token.Name.Builtin max
+      Token.Punctuation (
+      Token.Name.Variable salary
+      Token.Punctuation )
+      Token.Keyword.Reserved group by
+      Token.Name.Variable dept
+      *****
+      * Parsing
+      *****
+      NotSupported  :(
+      
+      >>> parse("select lunchTime, avg(salary), count(age) " \
+      ...       "group by    isSenior,lunchTime", \
+      ...           'aggregate', 'cols')
+      ... 
+      *****
+      * Tokens
+      *****
+      Token.Keyword.Reserved select
+      Token.Name.Variable lunchTime
+      Token.Punctuation ,
+      Token.Name.Builtin avg
+      Token.Punctuation (
+      Token.Name.Variable salary
+      Token.Punctuation )
+      Token.Punctuation ,
+      Token.Name.Builtin count