orql 0.1.0

A toy SQL parser for a subset of the Oracle dialect.
Documentation
  • Coverage
  • 65.71%
    550 out of 837 items documented2 out of 18 items with examples
  • Size
  • Source code size: 727.28 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 53.94 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 1m 13s Average build duration of successful builds.
  • all releases: 1m 13s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • xitep

orql

A toy SQL parser for a subset of the Oracle dialect.

motivation

The motivation for parser is to parse Oracle SQL statements into as an Abstract Syntax Tree while allowing the complete reconstruction of the orignally parsed source code. Therefore, the parser tries to preserve and expose token location as well as comments.

At the same time, the challenge is to not pay additional costs when not being interested in token location information and/or comments.

example

let sql = "select * from dual";
let stmts = parser::parse(sql).expect("bad sql!");
for stmt in stmts {
   println!("{:#?}", stmt);
}

Advanced examples demo'ing access to locations and comments can be found in the rustdoc of the individual, public modules.

status

not supported syntax

SQL syntax noted next is not supported by design:

multiple ON clauses

Example:

select *
  from (select 1 as alpha, 'alpha' as name from dual) a
  left join (select 1 as beta, 'beta' as name from dual) b
  join (select 1 as gamma, 'gamma' as name from dual) c
    on 1=1 -- causes `b` and `c` to be joined first ...
    on 1=1 -- ... on then this gets evaluated over of the previous inner join with `a`
;

Explanation: https://www.sqlservercentral.com/forums/topic/multiple-on-clauses-in-one-join

references / related projects

  • Oracle's SQL Language Reference

  • SQL 2016 Syntax Reference

  • datafusion-sqlparser-rs — A mature and complete SQL parser covering the full ANSI/ISO SQL Standard with support for database product specific extensions. Its exposed AST is general purpose — a union of all supported dialect specific features. Since sqlparser's AST doesn't contain nodes for every token in the parsed SQL, it's difficult to reconstruct the originally parsed SQL with regards to possible comments and indentation.