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. It uses FFI to communicate with it.
Requirements:
- gcc 5+ or clang 5+
Installation:
tarantoolctl rocks install sqlparser
Usage:
local parser = require("sqlparser")
local ast = parser.parse("select a from test;")
ast
variable now contains:
{
"parameters": [],
"errorLine": 0,
"statements": [
{
"fromTable": {
"type": "table",
"name": "test"
},
"selectList": [
{
"type": "columnRef",
"name": "a"
}
],
"selectDistinct": false,
"type": "select"
}
],
"isValid": true
}
And backwards:
local queries = parser.tostring(ast)
queries[1]
is:
select "a" from "test";