Rook Parser
Rook Parser uses Apache DataFusion SQL Parser to parse SQL statements into an AST (Abstract Syntax Tree).
The generated AST is then converted into JSON using the Serde JSON crate.
Based on this parsed JSON representation, Rook Parser constructs a minimal endpoint output JSON tailored to the specific requirements of RookDB.
Rook Parser is published as a Rust crate and is available at: Rook Parser Crate
The crate exposes APIs that take a SQL statement as input and return a custom JSON output tailored to the requirements of RookDB.
Supporting Statement API's
SHOW DATABASES;SHOW TABLES;CREATE DATABASE db_name;USE db_name;
API output Response
{
category: CategoryEnum,
stmt_type: StatementTypeEnum,
params: ParamsEnum
}
enum CategoryEnum {
DDL,
DML,
DQL,
SPECIAL
}
enum StatementTypeEnum {
ShowDatabases,
CreateDatabase,
SelectDatabase,
ShowTables,
CreateTable,
Select,
Insert
}
enum ParamsEnum {
ShowDatabases,
CreateDatabase {
database: String,
if_not_exists: bool
},
SelectDatabase {
database: String
},
ShowTables,
CreateTable {
table: String,
columns: Vec<Column>
},
Select {
tables: Vec<String>,
projection: Vec<String>,
filter: Option<String>
},
Insert {
table: String,
columns: Vec<String>,
values: Vec<Vec<String>>
}
}
Example Output
{
"category": "DQL",
"type": "ShowDatabases",
"params": {}
}