Commits

Olemis Lang committed 1832ead

GViz QL : Test cases for label statements with scalar functions and operators. Lexical analysis ok

Comments (0)

Files changed (2)

trac-dev/gviz/TODO

 X GViz API QL: Augment GViz QL grammar to include SQL clauses and refactor 
   current parsing solution.
 
+- GViz API QL: Support arithmetic expressions in label and format clauses
+
 - Add `limit` parameter for history methods in VersionControlRPC.
 
 - Implement data source provider for Ticket->Query
 - GViz API QL: Incremental production definition for operator precedence 
   grammar parser
 
+- GViz API QL: Add test cases for complex GROUP BY statements
+

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

       GVizUnsupportedQueryOp  :  Unable to evaluate GROUP BY clause. Either the whole clause or an specific feature is not supported yet.
 
       """,
-  'Parsing LABEL' : r"""
+  'Parsing LABEL (simple)' : r"""
       >>> parse("select name label name 'Employee Id' ", 'labels', 'cols')
       ... 
       *****
          isSenior = True
          seniorityStartTime = 2007-12-30 14:40:00
       """,
+  'Parsing LABEL (complex)' : r"""
+      >>> parse("select    max(salary) label max(salary) 'Better paid'", 
+      ...       'cols', 'labels')
+      ...
+      *****
+      * Tokens
+      *****
+      Token.Keyword.Reserved select
+      Token.Name.Builtin max
+      Token.Punctuation (
+      Token.Name.Variable salary
+      Token.Punctuation )
+      Token.Keyword.Reserved label
+      Token.Name.Builtin max
+      Token.Punctuation (
+      Token.Name.Variable salary
+      Token.Punctuation )
+      Token.Literal.String.Single 'Better paid'
+      *****
+      * Parsing
+      *****
+      ['max(salary)']
+      [('max(salary)', 'Better paid')]
+      *****
+      * Result
+      *****
+      = Columns =
+      max(salary) number
+      <BLANKLINE>
+      NotImplementedError  :  Feature not supported ... yet
+
+      >>> parse(r'''select lower(name) + '@example.com', upper(dept) 
+      ...       label lower(name) + '@example.com' 'E-mail', 
+      ...       upper(dept) "DEPT" ''',
+      ...       'cols', 'labels')
+      ...
+      *****
+      * Tokens
+      *****
+      Token.Keyword.Reserved select
+      Token.Name.Function lower
+      Token.Punctuation (
+      Token.Name.Variable name
+      Token.Punctuation )
+      Token.Operator.Arithmetic +
+      Token.Literal.String.Single '@example.com'
+      Token.Punctuation ,
+      Token.Name.Function upper
+      Token.Punctuation (
+      Token.Name.Variable dept
+      Token.Punctuation )
+      Token.Keyword.Reserved label
+      Token.Name.Function lower
+      Token.Punctuation (
+      Token.Name.Variable name
+      Token.Punctuation )
+      Token.Operator.Arithmetic +
+      Token.Literal.String.Single '@example.com'
+      Token.Literal.String.Single 'E-mail'
+      Token.Punctuation ,
+      Token.Name.Function upper
+      Token.Punctuation (
+      Token.Name.Variable dept
+      Token.Punctuation )
+      Token.Literal.String.Double "DEPT"
+      *****
+      * Parsing
+      *****
+      ["lower(name) + '@example.com'", 'upper(dept)']
+      [("lower(name) + '@example.com'", 'E-mail'), ('upper(dept)', 'DEPT')]
+      *****
+      * Result
+      *****
+      = Columns =
+      lower(name) + '@example.com' number
+      upper(dept) string
+      = Row =
+         lower(name) + '@example.com' = john@example.com
+         upper(dept) = ENG
+      = Row =
+         lower(name) + '@example.com' = dave@example.com
+         upper(dept) = ENG
+      = Row =
+         lower(name) + '@example.com' = sally@example.com
+         upper(dept) = ENG
+      = Row =
+         lower(name) + '@example.com' = ben@example.com
+         upper(dept) = SALES
+      = Row =
+         lower(name) + '@example.com' = dana@example.com
+         upper(dept) = SALES
+      = Row =
+         lower(name) + '@example.com' = mike@example.com
+         upper(dept) = MARKETING
+
+      """,
   'Parsing FORMAT' : r"""
       >>> parse("  format  salary   '#,##0.00' ", 'fmt')
       *****