package
Parse Socrata SODA2 API to Abstract Syntax Tree (AST)
npm install node-soda2-parserGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Estimated unpacked size across 2 packages.
255.8 kB
Includes dependencies.
Parse Socrata's SODA2 API to Abstract Syntax Tree (AST). This library is 99% node-sqlparser and 1% SODA2 to SQL with SODA2 unit tests.
var Parser = require('node-soda2-parser');
var ast = Parser.parse("$select=date, type, magnitude&$where=magnitude > 3.0 and source = 'pr'&$group=type");{ type: 'select',
distinct: null,
columns:
[ { expr: { type: 'column_ref', table: '', column: 'date' },
as: null },
{ expr: { type: 'column_ref', table: '', column: 'type' },
as: null },
{ expr: { type: 'column_ref', table: '', column: 'magnitude' },
as: null } ],
from: null,
where:
{ type: 'binary_expr',
operator: 'AND',
left:
{ type: 'binary_expr',
With this AST, you can:
Parser.stringify.parse(ast) (as seen in soda-postgres)Unit tests in test/soda ensure the following functionality from the SODA2 docs (which is basically everything except what's listed under Unsupported)
$select=date_trunc_ym(datetime) AS month$select=depth * 3.28 AS depth_feetfoo=bar&animal=lion$where=within_box(incident_location, 47.5998951, -122.33707, 47.5942794, -122.3270522)$where=date between '2015-01-10T12:00:00' and '2015-01-10T14:00:00'$where=end - start < 1$where=foo % 2The following was tested and does not parse
$where=date not between '2015-01-10T12:00:00' and '2015-01-10T14:00:00' (reference)$where=text_value='Bob''s string' (reference)$select=theft_date, dc_dist || dc_num AS dist_dc (reference)$q=foobar (reference) (see issue)