https://github.com/tarantool/sqlparser
An SQL parser for Tarantool based on Hyrise
https://github.com/tarantool/sqlparser
Last synced: 9 months ago
JSON representation
An SQL parser for Tarantool based on Hyrise
- Host: GitHub
- URL: https://github.com/tarantool/sqlparser
- Owner: tarantool
- License: mit
- Created: 2020-05-20T10:20:24.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-11-11T09:33:46.000Z (over 3 years ago)
- Last Synced: 2025-10-11T14:34:39.312Z (9 months ago)
- Language: Lua
- Size: 53.7 KB
- Stars: 5
- Watchers: 20
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Tarantool SQL Parser
An SQL parser for LuaJIT. It takes an SQL string as an input and returns an AST.
The project is based on [Hyrise SQL parser](https://github.com/hyrise/sql-parser). It uses FFI to communicate with it.
## Requirements:
- gcc 5+ or clang 5+
## Installation:
```shell
tarantoolctl rocks install sqlparser
```
## Usage:
```Lua
local parser = require("sqlparser")
local ast = parser.parse("select a from test;")
```
`ast` variable now contains:
```json
{
"parameters": [],
"errorLine": 0,
"statements": [
{
"fromTable": {
"type": "table",
"name": "test"
},
"selectList": [
{
"type": "columnRef",
"name": "a"
}
],
"selectDistinct": false,
"type": "select"
}
],
"isValid": true
}
```
And backwards:
```Lua
local queries = parser.tostring(ast)
```
`queries[1]` is:
```
select "a" from "test";
```