Commits

Olemis Lang committed 434293c

GViz QL : Test cases for format clause. Lexical analysis ... [ok]

Comments (0)

Files changed (2)

trac-dev/gviz/TODO

 
 X GViz API QL: Support arithmetic expressions in label and format clauses
 
+- GViz API QL: Implement `format` clause using PyICU
+
 - Add `limit` parameter for history methods in VersionControlRPC.
 
 - Implement data source provider for Ticket->Query
 
-- GViz API QL: Add tasks to support `where`, `group by`, 
-  `pivot`, `order by`, `format` and `options` clauses.
+- GViz API QL: Add tasks to support `group by`, 
+  `pivot`, `order by`, and `options` clauses.
 
 - Allow data source providers to control the details needed to handle 
   queries.

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

          upper(dept) = MARKETING
 
       """,
-  'Parsing FORMAT' : r"""
+  'Parsing FORMAT (simple)' : r"""
       >>> parse("  format  salary   '#,##0.00' ", 'fmt')
       *****
       * Tokens
       GVizUnsupportedQueryOp  :  Unable to evaluate FORMAT clause. Either the whole clause or an specific feature is not supported yet.
 
       """,
+  'Parsing FORMAT (complex)' : r"""
+      >>> parse(r'''select max(salary) label `max(salary)` 'Better paid' 
+      ...       format `max(salary)` "#,##0.00" ''',
+      ...       'fmt', '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.Variable `max(salary)`
+      Token.Literal.String.Single 'Better paid'
+      Token.Keyword.Reserved format
+      Token.Name.Variable `max(salary)`
+      Token.Literal.String.Double "#,##0.00"
+      *****
+      * Parsing
+      *****
+      [('max(salary)', '#,##0.00')]
+      ['max(salary)']
+      [('max(salary)', 'Better paid')]
+      *****
+      * Result
+      *****
+      = Columns =
+      max(salary) number Better paid
+      <BLANKLINE>
+      NotImplementedError  :  Feature not supported ... yet
+
+      >>> parse(r'''select lower(name) + '@example.com', upper(dept), 
+      ...       isSenior, seniorityStartTime, salary * 0.05
+      ...       label `lower(name) + '@example.com'` 'E-mail', 
+      ...       `upper(dept)` "DEPT" 
+      ...       format isSenior "SKILLED:beginner", `salary * 0.05` '#,##0.00',
+      ...       seniorityStartTime "EEE, MMM d, ''yy" ''',
+      ...       'fmt', '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.Punctuation ,
+      Token.Name.Variable isSenior
+      Token.Punctuation ,
+      Token.Name.Variable seniorityStartTime
+      Token.Punctuation ,
+      Token.Name.Variable salary
+      Token.Operator.Arithmetic *
+      Token.Literal.Number 0.05
+      Token.Keyword.Reserved label
+      Token.Name.Variable `lower(name) + '@example.com'`
+      Token.Literal.String.Single 'E-mail'
+      Token.Punctuation ,
+      Token.Name.Variable `upper(dept)`
+      Token.Literal.String.Double "DEPT"
+      Token.Keyword.Reserved format
+      Token.Name.Variable isSenior
+      Token.Literal.String.Double "SKILLED:beginner"
+      Token.Punctuation ,
+      Token.Name.Variable `salary * 0.05`
+      Token.Literal.String.Single '#,##0.00'
+      Token.Punctuation ,
+      Token.Name.Variable seniorityStartTime
+      Token.Literal.String.Double "EEE, MMM d, ''yy"
+      *****
+      * Parsing
+      *****
+      [('isSenior', 'SKILLED:beginner'), ('salary * 0.05', '#,##0.00'), ('seniorityStartTime', "EEE, MMM d, ''yy")]
+      ["lower(name) + '@example.com'", 'upper(dept)', 'isSenior', 'seniorityStartTime', 'salary * 0.05']
+      [("lower(name) + '@example.com'", 'E-mail'), ('upper(dept)', 'DEPT')]
+      *****
+      * Result
+      *****
+      = Columns =
+      lower(name) + '@example.com' number E-mail
+      upper(dept) string DEPT
+      = 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 OPTIONS' : r"""
       >>> parse("  select *  options    no_format   ", 'opts', 'cols')
       *****