ifql-parser
A nearley based ifql parser and analyzer
Last updated 2 years ago by lmangani .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install ifql-parser 
SYNC missed versions from official npm registry.

ifql-parser

InfluxDB Query Language parser

Status

  • Work in progress! Testers and Contributors welcome

Todo

  • Parser
    • [x] Baseline SQL parser
    • [x] FROM parser
    • [x] TIME math
    • [ ] Quotes parser
    • [ ] Cleanup & Tests
  • Output
    • [x] JSON output
    • [x] Elastic DSL output

JSON Example

const parser = require('ifql-parser')();
parser.parse('SELECT sum('load') AS mean_cpu FROM telegraf.autogen.cpu WHERE time > now() - 6h GROUP BY time(3600)');
Output
{ referencedTables: [ 'cpu' ],
  createdTables: undefined,
  sourceTables: [ 'cpu' ],
  operation: 'select',
  parsed:
   { type: 'select',
     top: undefined,
     all_distinct: undefined,
     selection:
      { type: 'selection_columns',
        columns:
         [ { type: 'column',
             expression:
              { type: 'function_call',
                name: { value: 'sum' },
                parameters: [ { type: 'string', string: 'load' } ] },
             alias: { type: 'identifier', value: 'mean_cpu' } } ] },
     table_exp:
      { type: 'from_table',
        from:
         { type: 'from',
           table_refs:
            [ { type: 'table', table: 'cpu', db: 'telegraf', ret: 'autogen' } ] },
        where:
         { type: 'where',
           condition:
            { type: 'operator',
              operator: '>',
              left: { type: 'identifier', value: 'time' },
              right:
               { type: 'operator',
                 operator: '-',
                 left:
                  { type: 'function_call',
                    name:
                     { value: 'now',
                       from_timestamp: 1545482191716,
                       to_timestamp: 1545482213317 },
                    parameters: [] },
                 right:
                  { type: 'decimal',
                    value: 6,
                    range: { type: 'data_type', data_type: 'hour', size: undefined } } } } },
        groupby:
         { type: 'group_by',
           columns:
            { type: 'selection_columns',
              columns:
               [ { type: 'column',
                   expression:
                    { type: 'function_call',
                      name: { value: 'time' },
                      parameters: [ { type: 'decimal', value: 3600 } ] } } ] } },
        having: undefined,
        order: undefined } },
  joins: [],
  returnColumns: [ { name: 'mean_cpu', sourceColumns: [] } ] }
Credits

Current Tags

  • 0.2.1                                ...           latest (2 years ago)

4 Versions

  • 0.2.1                                ...           2 years ago
  • 0.2.0                                ...           2 years ago
  • 0.1.9                                ...           2 years ago
  • 0.1.6                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 1
Dependencies (3)
Dev Dependencies (1)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |