update readme

This commit is contained in:
HSunboy 2018-08-16 19:30:22 +08:00
parent d7aa6a3e60
commit e4ee8218e4
2 changed files with 39 additions and 3 deletions

View File

@ -5,6 +5,7 @@
1. 解析sql生成语法树(不支持CREATE等语句具体可以查看`core/astParser`文件)支持单条sql语句
2. 去除sql中的的注释(目前支持`--`,`/**/`类型注释)
3. sql分割,根据`;`将sql分割为数组
4. 校验sqlhive sql等语法并给予错误信息与建议提示
## 用法
@ -35,4 +36,39 @@ aaaaaa*/ from user where isDeleted=0
console.log(dtFilter.parse(sql))//注意目前只支持单条sql语句所以需要自己调用sql分割一条一条处理
```
语法解析模块代码来自[nquery](http://github.com/alibaba/nquery/)
### 校验hive sql语法
``` javascript
const dtSqlParser=require("dt-sql-parser").parser;
console.log(dtSqlParser.parseSyntax("selet * form",'','hive'));
/*
{
"text": "selet",//错误部分
"token": "REGULAR_IDENTIFIER",//类型
"line": 0,
"loc": {//错误位置信息
"first_line": 1,
"last_line": 1,
"first_column": 0,
"last_column": 5
},
"ruleId": "0",
"expected": [//建议输入内容
{
"text": "select",//建议内容
"distance": 1//建议优先级
},
{
"text": "delete",
"distance": 2
}
],
"recoverable": false,
"incompleteStatement": true
}
*/
```
sql语法解析模块代码来自[nquery](https://github.com/alibaba/nquery/)
hive语法解析模块代码来自[Hue](https://github.com/cloudera/hue)

View File

@ -6,8 +6,8 @@ for(let [key,value] of testMap){
console.log(`******${key}********`)
console.log(value)
console.log(`******result********`)
// console.log(dtSqlParser.parser.parse(value));
console.log(dtSqlParser.filter.splitSql(value))
console.log(dtSqlParser.parser.parseSyntax(value));
// console.log(dtSqlParser.filter.splitSql(value))
console.log(`********************`)
}