simple-sql-parser supported SQL overview

simple-sql-parser home

This page has more details on the supported SQL in simple-sql-parser.

See the simple-sql-parser test cases page for examples.

The target dialect of SQL at this time is ISO/ANSI SQL:2011. The parser only supports queries. The parser and syntax does not follow the standard grammar closely - they permit a lot of things which the grammar in the standard forbids. The intended usage is that an additional pass over the ast can be made if you want to carefully prohibit everything that the standard doesn't allow.

Apart from this permissiveness, some work has been put into trying to get the best parser error messages possible.

Although the parser and syntax support some character set constructs, any source is always parsed in the default system encoding which Haskell uses, and any encoding/decoding is left to the system. I think this effectively means that you will usually be using utf-8 character set for the sql source.

Select lists

Supports value expressions, aliases with optional 'as'.

Doesn't support 'select * as (a,b,c) from t' yet.

Set quantifiers on select

Supports 'select distinct' and explicit 'select all'.

From clause

Group by clause

Supports value expressions, group by (), cube, rollup, grouping parentheses and grouping sets with nested grouping expressions.

Order by clause

Supports value expressions, asc/desc and nulls first/last.

Offset and fetch

Supports 'offset n rows' and 'fetch first n rows only'.

Set operators

Union, except, intersect + all/distinct and corresponding.

Table value constructor

For example: values (1,2),(3,4).

Explicit table

For example: 'table t', which is shorthand for 'select * from t'.

Value expressions

The value expressions type and parser is used in many contexts, including:

This doesn't exactly follow the ANSI Standards, which have separate grammars for most of these.

The supported value expressions include: