Merge branch 'dev' into 'master'
Dev See merge request dt-insight-front/infrastructure/dt-sql-parser!8
This commit is contained in:
commit
81dc491407
31
.eslintrc.js
Normal file
31
.eslintrc.js
Normal file
@ -0,0 +1,31 @@
|
||||
module.exports = {
|
||||
'env': {
|
||||
'browser': true,
|
||||
'es6': true,
|
||||
},
|
||||
'extends': [
|
||||
'google',
|
||||
],
|
||||
'globals': {
|
||||
'Atomics': 'readonly',
|
||||
'SharedArrayBuffer': 'readonly',
|
||||
},
|
||||
'parser': '@typescript-eslint/parser',
|
||||
'parserOptions': {
|
||||
'ecmaFeatures': {
|
||||
},
|
||||
'ecmaVersion': 11,
|
||||
'sourceType': 'module',
|
||||
},
|
||||
'plugins': [
|
||||
'@typescript-eslint',
|
||||
],
|
||||
'rules': {
|
||||
'indent': ['error', 4],
|
||||
'object-curly-spacing': ['error', 'always'],
|
||||
'max-len': ['error', { 'ignoreComments': true }],
|
||||
'require-jsdoc': 0,
|
||||
'valid-jsdoc': 0,
|
||||
'no-unused-vars': 0,
|
||||
},
|
||||
};
|
4
.gitignore
vendored
4
.gitignore
vendored
@ -2,3 +2,7 @@ node_modules
|
||||
package-lock.json
|
||||
.DS_Store
|
||||
.vscode
|
||||
.history
|
||||
dist/
|
||||
src/**/.antlr
|
||||
coverage
|
45
.gitlab-ci.yml
Normal file
45
.gitlab-ci.yml
Normal file
@ -0,0 +1,45 @@
|
||||
# Read more: https://docs.gitlab.com/12.7/ee/ci/yaml/README.html
|
||||
cache:
|
||||
paths:
|
||||
- .yarn
|
||||
- node_modules/
|
||||
|
||||
before_script:
|
||||
- yarn install --cache-folder .yarn
|
||||
|
||||
stages:
|
||||
- static-checking
|
||||
- type-checking
|
||||
- test
|
||||
- build
|
||||
|
||||
static-checking:
|
||||
stage: static-checking
|
||||
script:
|
||||
- yarn eslint
|
||||
only:
|
||||
- merge_requests
|
||||
- dev
|
||||
|
||||
type-checking:
|
||||
stage: type-checking
|
||||
script:
|
||||
- yarn check-types
|
||||
only:
|
||||
- merge_requests
|
||||
- dev
|
||||
|
||||
test:
|
||||
stage: test
|
||||
script:
|
||||
- yarn test
|
||||
only:
|
||||
- merge_requests
|
||||
- dev
|
||||
|
||||
build:
|
||||
stage: build
|
||||
script:
|
||||
- yarn build
|
||||
only:
|
||||
- dev
|
@ -3,4 +3,9 @@ node_modules
|
||||
package-lock.json
|
||||
.DS_Store
|
||||
.git
|
||||
.github
|
||||
.history
|
||||
site
|
||||
src/
|
||||
docs
|
||||
lib/grammar
|
||||
|
10
CONTRIBUTING.md
Normal file
10
CONTRIBUTING.md
Normal file
@ -0,0 +1,10 @@
|
||||
# dt-sql-parser
|
||||
|
||||
|
||||
## Prerequisites
|
||||
|
||||
|
||||
## Branch Organization
|
||||
|
||||
|
||||
## Source Code Organization
|
228
README-zh_CN.md
Normal file
228
README-zh_CN.md
Normal file
@ -0,0 +1,228 @@
|
||||
# dt-sql-parser
|
||||
|
||||
[![NPM version][npm-image]][npm-url]
|
||||
|
||||
[npm-image]: https://img.shields.io/npm/v/dt-sql-parser.svg?style=flat-square
|
||||
[npm-url]: https://www.npmjs.com/package/dt-sql-parser
|
||||
|
||||
[English](./README.md) | 简体中文
|
||||
|
||||
dt-sql-parser 是一个基于 [ANTLR4](https://github.com/antlr/antlr4) 开发的, 针对大数据领域的 **SQL Parser** 项目。通过[ANTLR4](https://github.com/antlr/antlr4) 默认生成的 Parser、Visitor 和 Listener 对象,我们可以轻松的做到对 SQL 语句的**语法检查**(Syntax Validation)、**词法分析**(Tokenizer)、 **遍历 AST** 节点等功能。此外,还提供了几个辅助方法, 例如 SQL 切割(Split)、过滤 SQL 语句中的 `--` 和 `/**/` 等类型的注释。
|
||||
|
||||
已支持的 SQL 类型:
|
||||
|
||||
- MySQL
|
||||
- Flink SQL
|
||||
- Spark SQL
|
||||
- Hive SQL
|
||||
- PL/SQL
|
||||
|
||||
> 提示:当前的 Parser 是 `Javascript` 语言版本,如果有必要,可以尝试编译 Grammar 文件到其他目标语言
|
||||
|
||||
## 安装
|
||||
|
||||
```bash
|
||||
// use npm
|
||||
npm i dt-sql-parser --save
|
||||
|
||||
// use yarn
|
||||
yarn add dt-sql-parser
|
||||
```
|
||||
|
||||
## 使用
|
||||
|
||||
### 语法校验(Syntax Validation)
|
||||
|
||||
首先需要声明相应的 Parser 对象,不同的 SQL 类型需要引入不同的 Parser 对象处理,例如如果是
|
||||
针对 **Flink SQL**,则需要单独引入 **FlinkSQL** Parser,这里我们使用 **GenericSQL** 作为示例:
|
||||
|
||||
```javascript
|
||||
import { GenericSQL } from 'dt-sql-parser';
|
||||
|
||||
const parser = new GenericSQL();
|
||||
|
||||
const correctSql = 'select id,name from user1;';
|
||||
const errors = parser.validate(correctSql);
|
||||
console.log(errors);
|
||||
```
|
||||
|
||||
输出:
|
||||
|
||||
```javascript
|
||||
/*
|
||||
[]
|
||||
*/
|
||||
```
|
||||
|
||||
校验失败示例:
|
||||
|
||||
```javascript
|
||||
const incorrectSql = 'selec id,name from user1;'
|
||||
const errors = parser.validate(incorrectSql);
|
||||
console.log(errors);
|
||||
```
|
||||
|
||||
输出:
|
||||
|
||||
```javascript
|
||||
/*
|
||||
[
|
||||
{
|
||||
endCol: 5,
|
||||
endLine: 1,
|
||||
startCol: 0,
|
||||
startLine: 1,
|
||||
message: "mismatched input 'SELEC' expecting {<EOF>, 'ALTER', 'ANALYZE', 'CALL', 'CHANGE', 'CHECK', 'CREATE', 'DELETE', 'DESC', 'DESCRIBE', 'DROP', 'EXPLAIN', 'GET', 'GRANT', 'INSERT', 'KILL', 'LOAD', 'LOCK', 'OPTIMIZE', 'PURGE', 'RELEASE', 'RENAME', 'REPLACE', 'RESIGNAL', 'REVOKE', 'SELECT', 'SET', 'SHOW', 'SIGNAL', 'UNLOCK', 'UPDATE', 'USE', 'BEGIN', 'BINLOG', 'CACHE', 'CHECKSUM', 'COMMIT', 'DEALLOCATE', 'DO', 'FLUSH', 'HANDLER', 'HELP', 'INSTALL', 'PREPARE', 'REPAIR', 'RESET', 'ROLLBACK', 'SAVEPOINT', 'START', 'STOP', 'TRUNCATE', 'UNINSTALL', 'XA', 'EXECUTE', 'SHUTDOWN', '--', '(', ';'}"
|
||||
}
|
||||
]
|
||||
*/
|
||||
```
|
||||
|
||||
先实例化 Parser 对象,然后使用 `validate` 方法对 SQL 语句进行校验,如果校验失败,则返回一个包含 `error` 信息的数组。
|
||||
|
||||
### 词法分析(Tokenizer)
|
||||
|
||||
必要场景下,可单独对 SQL 语句进行词法分析,获取所有的 Tokens 对象:
|
||||
|
||||
```javascript
|
||||
import { GenericSQL } from 'dt-sql-parser';
|
||||
|
||||
const parser = new GenericSQL()
|
||||
const sql = 'select id,name,sex from user1;'
|
||||
const tokens = parser.getAllTokens(sql)
|
||||
console.log(tokens)
|
||||
/*
|
||||
[
|
||||
{
|
||||
channel: 0
|
||||
column: 0
|
||||
line: 1
|
||||
source: [SqlLexer, InputStream]
|
||||
start: 0
|
||||
stop: 5
|
||||
tokenIndex: -1
|
||||
type: 137
|
||||
_text: null
|
||||
text: "SELECT"
|
||||
},
|
||||
...
|
||||
]
|
||||
*/
|
||||
```
|
||||
|
||||
### 访问者模式(Visitor)
|
||||
|
||||
使用 Visitor 模式访问 AST 中的指定节点
|
||||
|
||||
```javascript
|
||||
import { GenericSQL, SqlParserVisitor } from 'dt-sql-parser';
|
||||
|
||||
const parser = new GenericSQL()
|
||||
const sql = `select id,name from user1;`
|
||||
// parseTree
|
||||
const tree = parser.parse(sql)
|
||||
class MyVisitor extends SqlParserVisitor {
|
||||
// 重写 visitTableName 方法
|
||||
visitTableName(ctx) {
|
||||
let tableName = ctx.getText().toLowerCase()
|
||||
console.log('TableName', tableName)
|
||||
}
|
||||
// 重写 visitSelectElements 方法
|
||||
visitSelectElements(ctx) {
|
||||
let selectElements = ctx.getText().toLowerCase()
|
||||
console.log('SelectElements', selectElements)
|
||||
}
|
||||
}
|
||||
const visitor = new MyVisitor()
|
||||
visitor.visit(tree)
|
||||
|
||||
/*
|
||||
SelectElements id,name
|
||||
TableName user1
|
||||
*/
|
||||
|
||||
```
|
||||
|
||||
> 提示:使用 Visitor 模式时,节点的方法名称可以在对应 SQL 目录下的 Visitor 文件中查找
|
||||
|
||||
### 监听器(Listener)
|
||||
|
||||
Listener 模式,利用 [ANTLR4](https://github.com/antlr/antlr4) 提供的 ParseTreeWalker 对象遍历 AST,进入各个节点时调用对应的方法。
|
||||
|
||||
```javascript
|
||||
import { GenericSQL, SqlParserListener } from 'dt-sql-parser';
|
||||
|
||||
const parser = new GenericSQL();
|
||||
const sql = 'select id,name from user1;'
|
||||
// parseTree
|
||||
const tree = parser.parse(sql)
|
||||
class MyListener extends SqlParserListener {
|
||||
enterTableName(ctx) {
|
||||
let tableName = ctx.getText().toLowerCase()
|
||||
console.log('TableName', tableName)
|
||||
}
|
||||
enterSelectElements(ctx) {
|
||||
let selectElements = ctx.getText().toLowerCase()
|
||||
log('SelectElements', selectElements)
|
||||
}
|
||||
}
|
||||
const listenTableName = new MyListener();
|
||||
parser.listen(listenTableName, tree);
|
||||
|
||||
/*
|
||||
SelectElements id,name
|
||||
TableName user1
|
||||
*/
|
||||
|
||||
```
|
||||
|
||||
> 提示:使用 Listener 模式时,节点的方法名称可以在对应 SQL 目录下的 Listener 文件中查找
|
||||
|
||||
### 清理注释内容
|
||||
|
||||
清除注释和前后空格
|
||||
|
||||
```javascript
|
||||
import { cleanSql } from 'dt-sql-parser';
|
||||
|
||||
const sql = `-- comment comment
|
||||
select id,name from user1; `
|
||||
const cleanedSql = cleanSql(sql)
|
||||
console.log(cleanedSql)
|
||||
|
||||
/*
|
||||
select id,name from user1;
|
||||
*/
|
||||
```
|
||||
|
||||
### 切割 SQL (Split)
|
||||
|
||||
SQL 太大的情况下,我们可以先将SQL语句按 `;` 切割,然后逐句处理。
|
||||
|
||||
```javascript
|
||||
import { splitSql } from 'dt-sql-parser';
|
||||
|
||||
const sql = `select id,name from user1;
|
||||
select id,name from user2;`
|
||||
const sqlList = splitSql(sql)
|
||||
console.log(sqlList)
|
||||
|
||||
/*
|
||||
["select id,name from user1;", "\nselect id,name from user2;"]
|
||||
*/
|
||||
```
|
||||
|
||||
### 其他 API
|
||||
|
||||
- parserTreeToString (input: string)
|
||||
|
||||
将 SQL 解析成 `List-like` 风格的树形字符串, 一般用于测试
|
||||
|
||||
## 路线图
|
||||
|
||||
- Auto-complete
|
||||
- Format code
|
||||
|
||||
## 许可证
|
||||
|
||||
[MIT](./LICENSE)
|
271
README.md
271
README.md
@ -1,108 +1,233 @@
|
||||
> 如果你只想单纯的解析(SQL/SparkSQL),请使用 [cuopyue](https://github.com/HSunboy/cuopyue)
|
||||
|
||||
# dt-sql-parser
|
||||
|
||||
[![NPM version][npm-image]][npm-url]
|
||||
|
||||
English | [简体中文](./README-zh_CN.md)
|
||||
|
||||
[npm-image]: https://img.shields.io/npm/v/dt-sql-parser.svg?style=flat-square
|
||||
[npm-url]: https://www.npmjs.com/package/dt-sql-parser
|
||||
|
||||
本项目用于处理SQL,目前含有功能
|
||||
dt-sql-parser is a **SQL Parser** project built with [ANTLR4](https://github.com/antlr/antlr4), and it's mainly for the **BigData** domain. The [ANTLR4](https://github.com/antlr/antlr4) generated the basic Parser, Visitor, and Listener, so it's easy to complete the **syntax validation**, **tokenizer**, **traverse** the AST, and so on features.
|
||||
|
||||
1. 校验SQL,hive SQL,impala SQL,flinkSQL 等语法,并给予错误信息与建议提示
|
||||
2. SQL分割,根据`;`将sql分割为数组
|
||||
3. 去除SQL中的的注释(目前支持`--`,`/**/`类型注释)
|
||||
Besides, it' provides some helper methods, like **split** SQL, and filter the `--` and `/**/` types of comments in SQL.
|
||||
|
||||
Supported SQL:
|
||||
|
||||
## 用法
|
||||
- MySQL
|
||||
- Flink SQL
|
||||
- Spark SQL
|
||||
- Hive SQL
|
||||
- PL/SQL
|
||||
|
||||
### 过滤注释 / SQL分割
|
||||
>Tips: This project is the default for Javascript language, also you can try to compile it to other languages if you need.
|
||||
|
||||
``` javascript
|
||||
const dtFilter=require("dt-sql-parser").filter;
|
||||
const sql=`
|
||||
/*sttttttttart*/create table /*hhhhhhhh
|
||||
hhhhhh
|
||||
aaaaaa*/ sql_task_comment_test(id int comment 'id') comment 'sql test';
|
||||
--eeeeeeeend
|
||||
`
|
||||
console.log(dtFilter.filterComments(sql))//过滤注释
|
||||
console.log(dtFilter.splitSql(sql));//分割sql
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
// use npm
|
||||
npm i dt-sql-parser --save
|
||||
|
||||
// use yarn
|
||||
yarn add dt-sql-parser
|
||||
```
|
||||
|
||||
### 校验hive sql语法
|
||||
``` javascript
|
||||
const dtSqlParser=require("dt-sql-parser").parser;
|
||||
## Usage
|
||||
|
||||
console.log(dtSqlParser.parseSyntax("selet * form",'hive'));
|
||||
### Syntax Validation
|
||||
|
||||
First, we need to import the **Parser** object from `dt-sql-parser`, the different language needs
|
||||
different Parser, so if you need to handle the **Flink SQL**, you can import the **FlinkSQL Parser**.
|
||||
|
||||
The below is a **GenericSQL Parser** example:
|
||||
|
||||
```javascript
|
||||
import { GenericSQL } from 'dt-sql-parser';
|
||||
|
||||
const parser = new GenericSQL();
|
||||
|
||||
const correctSql = 'select id,name from user1;';
|
||||
const errors = parser.validate(correctSql);
|
||||
console.log(errors);
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```javascript
|
||||
/*
|
||||
{
|
||||
"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
|
||||
}
|
||||
[]
|
||||
*/
|
||||
```
|
||||
|
||||
## API
|
||||
Validate failed:
|
||||
|
||||
### filter
|
||||
```javascript
|
||||
const incorrectSql = 'selec id,name from user1;'
|
||||
const errors = parser.validate(incorrectSql);
|
||||
console.log(errors);
|
||||
```
|
||||
|
||||
#### function filterComments(sql:string):string
|
||||
过滤 `sql` 注释(支持`/*`和`--`)
|
||||
Output:
|
||||
|
||||
#### function splitSql(sql:string):Array<string>
|
||||
自动去除注释,并且提取出各个 `sql`
|
||||
```javascript
|
||||
/*
|
||||
[
|
||||
{
|
||||
endCol: 5,
|
||||
endLine: 1,
|
||||
startCol: 0,
|
||||
startLine: 1,
|
||||
message: "mismatched input 'SELEC' expecting {<EOF>, 'ALTER', 'ANALYZE', 'CALL', 'CHANGE', 'CHECK', 'CREATE', 'DELETE', 'DESC', 'DESCRIBE', 'DROP', 'EXPLAIN', 'GET', 'GRANT', 'INSERT', 'KILL', 'LOAD', 'LOCK', 'OPTIMIZE', 'PURGE', 'RELEASE', 'RENAME', 'REPLACE', 'RESIGNAL', 'REVOKE', 'SELECT', 'SET', 'SHOW', 'SIGNAL', 'UNLOCK', 'UPDATE', 'USE', 'BEGIN', 'BINLOG', 'CACHE', 'CHECKSUM', 'COMMIT', 'DEALLOCATE', 'DO', 'FLUSH', 'HANDLER', 'HELP', 'INSTALL', 'PREPARE', 'REPAIR', 'RESET', 'ROLLBACK', 'SAVEPOINT', 'START', 'STOP', 'TRUNCATE', 'UNINSTALL', 'XA', 'EXECUTE', 'SHUTDOWN', '--', '(', ';'}"
|
||||
}
|
||||
]
|
||||
*/
|
||||
```
|
||||
|
||||
### parser
|
||||
We instanced a Parser object, and use the **validate** method to check the SQL syntax, if failed
|
||||
returns an array object includes **error** message.
|
||||
|
||||
#### function parseSyntax(sql:string|Array<string>, type?:string):Object|boolean
|
||||
校验 `sql` 语法,如果没错误,则返回 `false`,否则返回错误详细信息
|
||||
### Tokenizer
|
||||
|
||||
可以提供一个含有两个字符串的数组,代表被光标分割的两个 `sql片段`
|
||||
Get all **tokens** by the Parser:
|
||||
|
||||
#### function parserSql(sql:string|Array<string>, type?:string):Object
|
||||
解析 `sql` 语法,根据上下文提示补全字段与其它辅助信息
|
||||
```javascript
|
||||
import { GenericSQL } from 'dt-sql-parser';
|
||||
|
||||
可以提供一个含有两个字符串的数组,代表被光标分割的两个sql片段
|
||||
const parser = new GenericSQL()
|
||||
const sql = 'select id,name,sex from user1;'
|
||||
const tokens = parser.getAllTokens(sql)
|
||||
console.log(tokens)
|
||||
/*
|
||||
[
|
||||
{
|
||||
channel: 0
|
||||
column: 0
|
||||
line: 1
|
||||
source: [SqlLexer, InputStream]
|
||||
start: 0
|
||||
stop: 5
|
||||
tokenIndex: -1
|
||||
type: 137
|
||||
_text: null
|
||||
text: "SELECT"
|
||||
},
|
||||
...
|
||||
]
|
||||
*/
|
||||
```
|
||||
|
||||
### flinksqlParser
|
||||
### Visitor
|
||||
|
||||
#### function flinksqlParser (sql: sql): SyntaxError
|
||||
校验 `flinksql` 语法。
|
||||
Traverse the tree node by the Visitor:
|
||||
|
||||
>本项目文档不是很详细,也不准确(暂时没精力写),项目功能可以满足 hivesql,sql,impala,flinksql 的语法检查和提示功能。
|
||||
具体使用方式可以参照代码中的 ts 类型。
|
||||
----
|
||||
```javascript
|
||||
import { GenericSQL, SqlParserVisitor } from 'dt-sql-parser';
|
||||
|
||||
hive,impala语法解析文件来自[Hue](https://github.com/cloudera/hue)
|
||||
const parser = new GenericSQL()
|
||||
const sql = `select id,name from user1;`
|
||||
// parseTree
|
||||
const tree = parser.parse(sql)
|
||||
class MyVisitor extends SqlParserVisitor {
|
||||
// overwrite visitTableName
|
||||
visitTableName(ctx) {
|
||||
let tableName = ctx.getText().toLowerCase()
|
||||
console.log('TableName', tableName)
|
||||
}
|
||||
// overwrite visitSelectElements
|
||||
visitSelectElements(ctx) {
|
||||
let selectElements = ctx.getText().toLowerCase()
|
||||
console.log('SelectElements', selectElements)
|
||||
}
|
||||
}
|
||||
const visitor = new MyVisitor()
|
||||
visitor.visit(tree)
|
||||
|
||||
----
|
||||
/*
|
||||
SelectElements id,name
|
||||
TableName user1
|
||||
*/
|
||||
|
||||
### ChangeLog
|
||||
```
|
||||
|
||||
- 1.1.8 添加转义字符支持
|
||||
- 1.1.9 添加函数的中括号语法支持( split(nameList)[0] )
|
||||
- 1.2.0 添加 ts,添加测试
|
||||
- 2.0.0 添加flinksql语法检查
|
||||
- 3.0.0 拆分hive,impala,集成最新 `HUE` 方案
|
||||
> Tips: The node's method name can be found in the Visitor file under the corresponding SQL directory
|
||||
|
||||
### Listener
|
||||
|
||||
Access the specified node in the AST by the Listener
|
||||
|
||||
```javascript
|
||||
import { GenericSQL, SqlParserListener } from 'dt-sql-parser';
|
||||
|
||||
const parser = new GenericSQL();
|
||||
const sql = 'select id,name from user1;'
|
||||
// parseTree
|
||||
const tree = parser.parse(sql)
|
||||
class MyListener extends SqlParserListener {
|
||||
enterTableName(ctx) {
|
||||
let tableName = ctx.getText().toLowerCase()
|
||||
console.log('TableName', tableName)
|
||||
}
|
||||
enterSelectElements(ctx) {
|
||||
let selectElements = ctx.getText().toLowerCase()
|
||||
log('SelectElements', selectElements)
|
||||
}
|
||||
}
|
||||
const listenTableName = new MyListener();
|
||||
parser.listen(listenTableName, tree);
|
||||
|
||||
/*
|
||||
SelectElements id,name
|
||||
TableName user1
|
||||
*/
|
||||
|
||||
```
|
||||
|
||||
> Tips: The node's method name can be found in the Listener file under the corresponding SQL directory
|
||||
|
||||
### Clean
|
||||
|
||||
Clear the **comments** and **spaces** before and after
|
||||
|
||||
```javascript
|
||||
import { cleanSql } from 'dt-sql-parser';
|
||||
|
||||
const sql = `-- comment comment
|
||||
select id,name from user1; `
|
||||
const cleanedSql = cleanSql(sql)
|
||||
console.log(cleanedSql)
|
||||
|
||||
/*
|
||||
select id,name from user1;
|
||||
*/
|
||||
```
|
||||
|
||||
### Split SQL
|
||||
|
||||
When the SQL text is very big, you can think about to split it by `;` , and handle it by each line.
|
||||
|
||||
```javascript
|
||||
import { splitSql } from 'dt-sql-parser';
|
||||
|
||||
const sql = `select id,name from user1;
|
||||
select id,name from user2;`
|
||||
const sqlList = splitSql(sql)
|
||||
console.log(sqlList)
|
||||
|
||||
/*
|
||||
["select id,name from user1;", "\nselect id,name from user2;"]
|
||||
*/
|
||||
```
|
||||
|
||||
### Other API
|
||||
|
||||
- parserTreeToString(input: string)
|
||||
|
||||
Parse the input and convert the AST to a `List-like` tree string.
|
||||
|
||||
## Roadmap
|
||||
|
||||
- Auto-complete
|
||||
- Format code
|
||||
|
||||
## License
|
||||
|
||||
[MIT](./LICENSE)
|
||||
|
BIN
build/antlr-4.8-complete.jar
Normal file
BIN
build/antlr-4.8-complete.jar
Normal file
Binary file not shown.
35
build/antlr4.js
Normal file
35
build/antlr4.js
Normal file
@ -0,0 +1,35 @@
|
||||
const path = require('path');
|
||||
const exec = require('child_process').exec;
|
||||
|
||||
const antlr4 = path.resolve(__dirname, 'antlr-4.8-complete.jar');
|
||||
const grammars = path.resolve(__dirname, '../src/grammar');
|
||||
const output = path.resolve(__dirname, '../src/lib');
|
||||
|
||||
const entry = [
|
||||
'generic',
|
||||
'hive',
|
||||
'plsql',
|
||||
'spark',
|
||||
'impala',
|
||||
'flinksql',
|
||||
];
|
||||
|
||||
entry.forEach((language) => {
|
||||
const cmd = `
|
||||
java -jar ${antlr4}
|
||||
-Dlanguage=JavaScript
|
||||
-visitor
|
||||
-listener
|
||||
-o ${output}/${language}
|
||||
${grammars}/${language}/*.g4
|
||||
`.replace(/\n/g, '');
|
||||
console.log('cmd:', cmd);
|
||||
exec(cmd, (err) => {
|
||||
if (err) {
|
||||
console.error('Antlr4 build error: ' + language, err);
|
||||
} else {
|
||||
console.log(`Build ${language} success.`);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
19
docs/Roadmap.md
Normal file
19
docs/Roadmap.md
Normal file
@ -0,0 +1,19 @@
|
||||
# RoadMap
|
||||
|
||||
## Supported SQL Language
|
||||
|
||||
- Generic SQL
|
||||
|
||||
<https://github.com/mysql/mysql-workbench/tree/8.0/library/parsers/grammars>
|
||||
- [x] PLSQL
|
||||
- [x] Hive SQL
|
||||
- [x] Unify parser generate to Antlr4
|
||||
- [ ] Impala SQL
|
||||
- [ ] Spark SQL
|
||||
- [ ] FLink SQL
|
||||
|
||||
## TODO
|
||||
|
||||
- Libra SQL
|
||||
- TiDB
|
||||
MySQL Compatible Syntax
|
17
docs/Tutorials.md
Normal file
17
docs/Tutorials.md
Normal file
@ -0,0 +1,17 @@
|
||||
# Tutorials
|
||||
|
||||
## Antlr4 installation
|
||||
|
||||
## How to extend new grammar
|
||||
|
||||
## How to expose Javascript interface in this project
|
||||
|
||||
## Integrate with Monaco Editor
|
||||
|
||||
## Reference
|
||||
|
||||
- <https://tomassetti.me/writing-a-browser-based-editor-using-monaco-and-antlr/>
|
||||
- [SQL](https://en.wikipedia.org/wiki/SQL)
|
||||
- [FlinkSQL](https://github.com/apache/flink/blob/master/flink-table/flink-sql-parser/src/test/java/org/apache/flink/sql/parser/CreateTableLikeTest.java)
|
||||
- [antlr4 grammar](https://github.com/antlr/grammars-v4/tree/master/sql)
|
||||
- <https://github.com/apache/spark/blob/master/sql/catalyst/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBase.g4>
|
@ -27,9 +27,7 @@ module.exports = {
|
||||
// coverageDirectory: null,
|
||||
|
||||
// An array of regexp pattern strings used to skip coverage collection
|
||||
coveragePathIgnorePatterns: [
|
||||
"/node_modules/"
|
||||
],
|
||||
coveragePathIgnorePatterns: ['/node_modules/'],
|
||||
|
||||
// A list of reporter names that Jest uses when writing coverage reports
|
||||
// coverageReporters: [
|
||||
@ -58,7 +56,9 @@ module.exports = {
|
||||
// globalTeardown: null,
|
||||
|
||||
// A set of global variables that need to be available in all test environments
|
||||
// globals: {},
|
||||
globals: {
|
||||
window: {},
|
||||
},
|
||||
|
||||
// An array of directory names to be searched recursively up from the requiring module's location
|
||||
// moduleDirectories: [
|
||||
@ -129,7 +129,7 @@ module.exports = {
|
||||
// snapshotSerializers: [],
|
||||
|
||||
// The test environment that will be used for testing
|
||||
testEnvironment: "node",
|
||||
testEnvironment: 'node',
|
||||
|
||||
// Options that will be passed to the testEnvironment
|
||||
// testEnvironmentOptions: {},
|
||||
@ -144,9 +144,7 @@ module.exports = {
|
||||
// ],
|
||||
|
||||
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
|
||||
testPathIgnorePatterns: [
|
||||
"/node_modules/"
|
||||
],
|
||||
testPathIgnorePatterns: ['/node_modules/'],
|
||||
|
||||
// The regexp pattern or array of patterns that Jest uses to detect test files
|
||||
// testRegex: [],
|
||||
@ -165,13 +163,11 @@ module.exports = {
|
||||
|
||||
// A map from regular expressions to paths to transformers
|
||||
transform: {
|
||||
'^.+\\.(t|j)sx?$': 'ts-jest'
|
||||
'^.+\\.(t|j)sx?$': 'ts-jest',
|
||||
},
|
||||
|
||||
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
|
||||
transformIgnorePatterns: [
|
||||
"/node_modules/"
|
||||
],
|
||||
transformIgnorePatterns: ['/node_modules/'],
|
||||
|
||||
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
|
||||
// unmockedModulePathPatterns: undefined,
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@ -1,887 +0,0 @@
|
||||
// Generated from ./grammar/sql.g4 by ANTLR 4.7.1
|
||||
// jshint ignore: start
|
||||
var antlr4 = require('antlr4/index');
|
||||
// This class defines a complete generic visitor for a parse tree produced by sqlParser.
|
||||
function sqlVisitor() {
|
||||
antlr4.tree.ParseTreeVisitor.call(this);
|
||||
return this;
|
||||
}
|
||||
sqlVisitor.prototype = Object.create(antlr4.tree.ParseTreeVisitor.prototype);
|
||||
sqlVisitor.prototype.constructor = sqlVisitor;
|
||||
// Visit a parse tree produced by sqlParser#singleStatement.
|
||||
sqlVisitor.prototype.visitSingleStatement = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#singleExpression.
|
||||
sqlVisitor.prototype.visitSingleExpression = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#singleTableIdentifier.
|
||||
sqlVisitor.prototype.visitSingleTableIdentifier = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#singleFunctionIdentifier.
|
||||
sqlVisitor.prototype.visitSingleFunctionIdentifier = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#singleDataType.
|
||||
sqlVisitor.prototype.visitSingleDataType = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#singleTableSchema.
|
||||
sqlVisitor.prototype.visitSingleTableSchema = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#statementDefault.
|
||||
sqlVisitor.prototype.visitStatementDefault = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#use.
|
||||
sqlVisitor.prototype.visitUse = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#createDatabase.
|
||||
sqlVisitor.prototype.visitCreateDatabase = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#setDatabaseProperties.
|
||||
sqlVisitor.prototype.visitSetDatabaseProperties = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#dropDatabase.
|
||||
sqlVisitor.prototype.visitDropDatabase = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#createTable.
|
||||
sqlVisitor.prototype.visitCreateTable = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#createHiveTable.
|
||||
sqlVisitor.prototype.visitCreateHiveTable = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#createFlinkTable.
|
||||
sqlVisitor.prototype.visitCreateFlinkTable = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#createTableLike.
|
||||
sqlVisitor.prototype.visitCreateTableLike = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#analyze.
|
||||
sqlVisitor.prototype.visitAnalyze = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#addTableColumns.
|
||||
sqlVisitor.prototype.visitAddTableColumns = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#renameTable.
|
||||
sqlVisitor.prototype.visitRenameTable = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#setTableProperties.
|
||||
sqlVisitor.prototype.visitSetTableProperties = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#unsetTableProperties.
|
||||
sqlVisitor.prototype.visitUnsetTableProperties = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#changeColumn.
|
||||
sqlVisitor.prototype.visitChangeColumn = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#setTableSerDe.
|
||||
sqlVisitor.prototype.visitSetTableSerDe = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#addTablePartition.
|
||||
sqlVisitor.prototype.visitAddTablePartition = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#renameTablePartition.
|
||||
sqlVisitor.prototype.visitRenameTablePartition = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#dropTablePartitions.
|
||||
sqlVisitor.prototype.visitDropTablePartitions = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#setTableLocation.
|
||||
sqlVisitor.prototype.visitSetTableLocation = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#recoverPartitions.
|
||||
sqlVisitor.prototype.visitRecoverPartitions = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#dropTable.
|
||||
sqlVisitor.prototype.visitDropTable = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#createView.
|
||||
sqlVisitor.prototype.visitCreateView = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#createTempViewUsing.
|
||||
sqlVisitor.prototype.visitCreateTempViewUsing = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#alterViewQuery.
|
||||
sqlVisitor.prototype.visitAlterViewQuery = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#createFunction.
|
||||
sqlVisitor.prototype.visitCreateFunction = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#dropFunction.
|
||||
sqlVisitor.prototype.visitDropFunction = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#explain.
|
||||
sqlVisitor.prototype.visitExplain = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#showTables.
|
||||
sqlVisitor.prototype.visitShowTables = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#showTable.
|
||||
sqlVisitor.prototype.visitShowTable = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#showDatabases.
|
||||
sqlVisitor.prototype.visitShowDatabases = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#showTblProperties.
|
||||
sqlVisitor.prototype.visitShowTblProperties = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#showColumns.
|
||||
sqlVisitor.prototype.visitShowColumns = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#showPartitions.
|
||||
sqlVisitor.prototype.visitShowPartitions = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#showFunctions.
|
||||
sqlVisitor.prototype.visitShowFunctions = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#showCreateTable.
|
||||
sqlVisitor.prototype.visitShowCreateTable = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#describeFunction.
|
||||
sqlVisitor.prototype.visitDescribeFunction = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#describeDatabase.
|
||||
sqlVisitor.prototype.visitDescribeDatabase = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#describeTable.
|
||||
sqlVisitor.prototype.visitDescribeTable = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#refreshTable.
|
||||
sqlVisitor.prototype.visitRefreshTable = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#refreshResource.
|
||||
sqlVisitor.prototype.visitRefreshResource = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#cacheTable.
|
||||
sqlVisitor.prototype.visitCacheTable = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#uncacheTable.
|
||||
sqlVisitor.prototype.visitUncacheTable = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#clearCache.
|
||||
sqlVisitor.prototype.visitClearCache = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#loadData.
|
||||
sqlVisitor.prototype.visitLoadData = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#truncateTable.
|
||||
sqlVisitor.prototype.visitTruncateTable = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#repairTable.
|
||||
sqlVisitor.prototype.visitRepairTable = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#manageResource.
|
||||
sqlVisitor.prototype.visitManageResource = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#failNativeCommand.
|
||||
sqlVisitor.prototype.visitFailNativeCommand = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#setConfiguration.
|
||||
sqlVisitor.prototype.visitSetConfiguration = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#resetConfiguration.
|
||||
sqlVisitor.prototype.visitResetConfiguration = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#unsupportedHiveNativeCommands.
|
||||
sqlVisitor.prototype.visitUnsupportedHiveNativeCommands = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#createTableHeader.
|
||||
sqlVisitor.prototype.visitCreateTableHeader = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#bucketSpec.
|
||||
sqlVisitor.prototype.visitBucketSpec = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#skewSpec.
|
||||
sqlVisitor.prototype.visitSkewSpec = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#locationSpec.
|
||||
sqlVisitor.prototype.visitLocationSpec = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#query.
|
||||
sqlVisitor.prototype.visitQuery = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#insertOverwriteTable.
|
||||
sqlVisitor.prototype.visitInsertOverwriteTable = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#insertIntoTable.
|
||||
sqlVisitor.prototype.visitInsertIntoTable = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#insertOverwriteHiveDir.
|
||||
sqlVisitor.prototype.visitInsertOverwriteHiveDir = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#insertOverwriteDir.
|
||||
sqlVisitor.prototype.visitInsertOverwriteDir = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#partitionSpecLocation.
|
||||
sqlVisitor.prototype.visitPartitionSpecLocation = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#partitionSpec.
|
||||
sqlVisitor.prototype.visitPartitionSpec = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#partitionVal.
|
||||
sqlVisitor.prototype.visitPartitionVal = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#describeFuncName.
|
||||
sqlVisitor.prototype.visitDescribeFuncName = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#describeColName.
|
||||
sqlVisitor.prototype.visitDescribeColName = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#ctes.
|
||||
sqlVisitor.prototype.visitCtes = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#namedQuery.
|
||||
sqlVisitor.prototype.visitNamedQuery = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#tableProvider.
|
||||
sqlVisitor.prototype.visitTableProvider = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#tablePropertyList.
|
||||
sqlVisitor.prototype.visitTablePropertyList = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#tableProperty.
|
||||
sqlVisitor.prototype.visitTableProperty = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#tablePropertyKey.
|
||||
sqlVisitor.prototype.visitTablePropertyKey = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#tablePropertyValue.
|
||||
sqlVisitor.prototype.visitTablePropertyValue = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#constantList.
|
||||
sqlVisitor.prototype.visitConstantList = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#nestedConstantList.
|
||||
sqlVisitor.prototype.visitNestedConstantList = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#createFileFormat.
|
||||
sqlVisitor.prototype.visitCreateFileFormat = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#tableFileFormat.
|
||||
sqlVisitor.prototype.visitTableFileFormat = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#genericFileFormat.
|
||||
sqlVisitor.prototype.visitGenericFileFormat = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#storageHandler.
|
||||
sqlVisitor.prototype.visitStorageHandler = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#resource.
|
||||
sqlVisitor.prototype.visitResource = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#singleInsertQuery.
|
||||
sqlVisitor.prototype.visitSingleInsertQuery = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#multiInsertQuery.
|
||||
sqlVisitor.prototype.visitMultiInsertQuery = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#queryOrganization.
|
||||
sqlVisitor.prototype.visitQueryOrganization = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#multiInsertQueryBody.
|
||||
sqlVisitor.prototype.visitMultiInsertQueryBody = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#queryTermDefault.
|
||||
sqlVisitor.prototype.visitQueryTermDefault = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#setOperation.
|
||||
sqlVisitor.prototype.visitSetOperation = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#queryPrimaryDefault.
|
||||
sqlVisitor.prototype.visitQueryPrimaryDefault = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#table.
|
||||
sqlVisitor.prototype.visitTable = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#inlineTableDefault1.
|
||||
sqlVisitor.prototype.visitInlineTableDefault1 = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#subquery.
|
||||
sqlVisitor.prototype.visitSubquery = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#sortItem.
|
||||
sqlVisitor.prototype.visitSortItem = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#querySpecification.
|
||||
sqlVisitor.prototype.visitQuerySpecification = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#hint.
|
||||
sqlVisitor.prototype.visitHint = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#hintStatement.
|
||||
sqlVisitor.prototype.visitHintStatement = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#fromClause.
|
||||
sqlVisitor.prototype.visitFromClause = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#aggregation.
|
||||
sqlVisitor.prototype.visitAggregation = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#groupingSet.
|
||||
sqlVisitor.prototype.visitGroupingSet = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#pivotClause.
|
||||
sqlVisitor.prototype.visitPivotClause = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#pivotColumn.
|
||||
sqlVisitor.prototype.visitPivotColumn = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#pivotValue.
|
||||
sqlVisitor.prototype.visitPivotValue = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#lateralView.
|
||||
sqlVisitor.prototype.visitLateralView = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#setQuantifier.
|
||||
sqlVisitor.prototype.visitSetQuantifier = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#relation.
|
||||
sqlVisitor.prototype.visitRelation = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#joinRelation.
|
||||
sqlVisitor.prototype.visitJoinRelation = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#joinType.
|
||||
sqlVisitor.prototype.visitJoinType = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#joinCriteria.
|
||||
sqlVisitor.prototype.visitJoinCriteria = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#sample.
|
||||
sqlVisitor.prototype.visitSample = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#sampleByPercentile.
|
||||
sqlVisitor.prototype.visitSampleByPercentile = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#sampleByRows.
|
||||
sqlVisitor.prototype.visitSampleByRows = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#sampleByBucket.
|
||||
sqlVisitor.prototype.visitSampleByBucket = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#sampleByBytes.
|
||||
sqlVisitor.prototype.visitSampleByBytes = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#identifierList.
|
||||
sqlVisitor.prototype.visitIdentifierList = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#identifierSeq.
|
||||
sqlVisitor.prototype.visitIdentifierSeq = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#orderedIdentifierList.
|
||||
sqlVisitor.prototype.visitOrderedIdentifierList = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#orderedIdentifier.
|
||||
sqlVisitor.prototype.visitOrderedIdentifier = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#identifierCommentList.
|
||||
sqlVisitor.prototype.visitIdentifierCommentList = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#identifierComment.
|
||||
sqlVisitor.prototype.visitIdentifierComment = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#tableName.
|
||||
sqlVisitor.prototype.visitTableName = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#aliasedQuery.
|
||||
sqlVisitor.prototype.visitAliasedQuery = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#aliasedRelation.
|
||||
sqlVisitor.prototype.visitAliasedRelation = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#inlineTableDefault2.
|
||||
sqlVisitor.prototype.visitInlineTableDefault2 = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#tableValuedFunction.
|
||||
sqlVisitor.prototype.visitTableValuedFunction = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#matchRecognize.
|
||||
sqlVisitor.prototype.visitMatchRecognize = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#measureColumn.
|
||||
sqlVisitor.prototype.visitMeasureColumn = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#condition1.
|
||||
sqlVisitor.prototype.visitCondition1 = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#variable.
|
||||
sqlVisitor.prototype.visitVariable = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#pattern1.
|
||||
sqlVisitor.prototype.visitPattern1 = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#patternTerm.
|
||||
sqlVisitor.prototype.visitPatternTerm = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#patternFactor.
|
||||
sqlVisitor.prototype.visitPatternFactor = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#patternQuantifier.
|
||||
sqlVisitor.prototype.visitPatternQuantifier = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#minRepeat.
|
||||
sqlVisitor.prototype.visitMinRepeat = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#maxRepeat.
|
||||
sqlVisitor.prototype.visitMaxRepeat = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#repeat.
|
||||
sqlVisitor.prototype.visitRepeat = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#inlineTable.
|
||||
sqlVisitor.prototype.visitInlineTable = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#functionTable.
|
||||
sqlVisitor.prototype.visitFunctionTable = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#tableAlias.
|
||||
sqlVisitor.prototype.visitTableAlias = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#rowFormatSerde.
|
||||
sqlVisitor.prototype.visitRowFormatSerde = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#rowFormatDelimited.
|
||||
sqlVisitor.prototype.visitRowFormatDelimited = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#tableIdentifier.
|
||||
sqlVisitor.prototype.visitTableIdentifier = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#functionIdentifier.
|
||||
sqlVisitor.prototype.visitFunctionIdentifier = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#namedExpression.
|
||||
sqlVisitor.prototype.visitNamedExpression = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#namedExpressionSeq.
|
||||
sqlVisitor.prototype.visitNamedExpressionSeq = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#expression.
|
||||
sqlVisitor.prototype.visitExpression = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#logicalNot.
|
||||
sqlVisitor.prototype.visitLogicalNot = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#predicated.
|
||||
sqlVisitor.prototype.visitPredicated = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#exists.
|
||||
sqlVisitor.prototype.visitExists = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#logicalBinary.
|
||||
sqlVisitor.prototype.visitLogicalBinary = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#predicate.
|
||||
sqlVisitor.prototype.visitPredicate = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#valueExpressionDefault.
|
||||
sqlVisitor.prototype.visitValueExpressionDefault = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#comparison.
|
||||
sqlVisitor.prototype.visitComparison = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#arithmeticBinary.
|
||||
sqlVisitor.prototype.visitArithmeticBinary = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#arithmeticUnary.
|
||||
sqlVisitor.prototype.visitArithmeticUnary = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#struct.
|
||||
sqlVisitor.prototype.visitStruct = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#dereference.
|
||||
sqlVisitor.prototype.visitDereference = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#simpleCase.
|
||||
sqlVisitor.prototype.visitSimpleCase = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#columnReference.
|
||||
sqlVisitor.prototype.visitColumnReference = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#rowConstructor.
|
||||
sqlVisitor.prototype.visitRowConstructor = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#last.
|
||||
sqlVisitor.prototype.visitLast = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#star.
|
||||
sqlVisitor.prototype.visitStar = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#subscript.
|
||||
sqlVisitor.prototype.visitSubscript = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#subqueryExpression.
|
||||
sqlVisitor.prototype.visitSubqueryExpression = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#cast.
|
||||
sqlVisitor.prototype.visitCast = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#constantDefault.
|
||||
sqlVisitor.prototype.visitConstantDefault = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#lambda.
|
||||
sqlVisitor.prototype.visitLambda = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#parenthesizedExpression.
|
||||
sqlVisitor.prototype.visitParenthesizedExpression = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#extract.
|
||||
sqlVisitor.prototype.visitExtract = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#functionCall.
|
||||
sqlVisitor.prototype.visitFunctionCall = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#searchedCase.
|
||||
sqlVisitor.prototype.visitSearchedCase = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#position.
|
||||
sqlVisitor.prototype.visitPosition = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#first.
|
||||
sqlVisitor.prototype.visitFirst = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#nullLiteral.
|
||||
sqlVisitor.prototype.visitNullLiteral = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#intervalLiteral.
|
||||
sqlVisitor.prototype.visitIntervalLiteral = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#typeConstructor.
|
||||
sqlVisitor.prototype.visitTypeConstructor = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#numericLiteral.
|
||||
sqlVisitor.prototype.visitNumericLiteral = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#booleanLiteral.
|
||||
sqlVisitor.prototype.visitBooleanLiteral = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#stringLiteral.
|
||||
sqlVisitor.prototype.visitStringLiteral = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#comparisonOperator.
|
||||
sqlVisitor.prototype.visitComparisonOperator = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#arithmeticOperator.
|
||||
sqlVisitor.prototype.visitArithmeticOperator = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#predicateOperator.
|
||||
sqlVisitor.prototype.visitPredicateOperator = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#booleanValue.
|
||||
sqlVisitor.prototype.visitBooleanValue = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#interval.
|
||||
sqlVisitor.prototype.visitInterval = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#intervalField.
|
||||
sqlVisitor.prototype.visitIntervalField = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#intervalValue.
|
||||
sqlVisitor.prototype.visitIntervalValue = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#colPosition.
|
||||
sqlVisitor.prototype.visitColPosition = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#complexDataType.
|
||||
sqlVisitor.prototype.visitComplexDataType = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#primitiveDataType.
|
||||
sqlVisitor.prototype.visitPrimitiveDataType = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#colTypeList.
|
||||
sqlVisitor.prototype.visitColTypeList = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#colType.
|
||||
sqlVisitor.prototype.visitColType = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#dtColTypeList.
|
||||
sqlVisitor.prototype.visitDtColTypeList = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#dtColType.
|
||||
sqlVisitor.prototype.visitDtColType = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#dtColIdentifier.
|
||||
sqlVisitor.prototype.visitDtColIdentifier = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#complexColTypeList.
|
||||
sqlVisitor.prototype.visitComplexColTypeList = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#complexColType.
|
||||
sqlVisitor.prototype.visitComplexColType = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#whenClause.
|
||||
sqlVisitor.prototype.visitWhenClause = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#windows.
|
||||
sqlVisitor.prototype.visitWindows = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#namedWindow.
|
||||
sqlVisitor.prototype.visitNamedWindow = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#windowRef.
|
||||
sqlVisitor.prototype.visitWindowRef = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#windowDef.
|
||||
sqlVisitor.prototype.visitWindowDef = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#windowFrame.
|
||||
sqlVisitor.prototype.visitWindowFrame = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#frameBound.
|
||||
sqlVisitor.prototype.visitFrameBound = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#qualifiedName.
|
||||
sqlVisitor.prototype.visitQualifiedName = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#identifier.
|
||||
sqlVisitor.prototype.visitIdentifier = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#unquotedIdentifier.
|
||||
sqlVisitor.prototype.visitUnquotedIdentifier = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#quotedIdentifierAlternative.
|
||||
sqlVisitor.prototype.visitQuotedIdentifierAlternative = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#quotedIdentifier.
|
||||
sqlVisitor.prototype.visitQuotedIdentifier = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#decimalLiteral.
|
||||
sqlVisitor.prototype.visitDecimalLiteral = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#integerLiteral.
|
||||
sqlVisitor.prototype.visitIntegerLiteral = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#bigIntLiteral.
|
||||
sqlVisitor.prototype.visitBigIntLiteral = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#smallIntLiteral.
|
||||
sqlVisitor.prototype.visitSmallIntLiteral = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#tinyIntLiteral.
|
||||
sqlVisitor.prototype.visitTinyIntLiteral = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#doubleLiteral.
|
||||
sqlVisitor.prototype.visitDoubleLiteral = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#bigDecimalLiteral.
|
||||
sqlVisitor.prototype.visitBigDecimalLiteral = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
// Visit a parse tree produced by sqlParser#nonReserved.
|
||||
sqlVisitor.prototype.visitNonReserved = function (ctx) {
|
||||
return this.visitChildren(ctx);
|
||||
};
|
||||
exports.sqlVisitor = sqlVisitor;
|
@ -1,521 +0,0 @@
|
||||
/*
|
||||
* Generated by PEG.js 0.10.0.
|
||||
*
|
||||
* http://pegjs.org/
|
||||
*/
|
||||
(function (root, factory) {
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define([], factory);
|
||||
}
|
||||
else if (typeof module === "object" && module.exports) {
|
||||
module.exports = factory();
|
||||
}
|
||||
})(this, function () {
|
||||
"use strict";
|
||||
function peg$subclass(child, parent) {
|
||||
function ctor() { this.constructor = child; }
|
||||
ctor.prototype = parent.prototype;
|
||||
child.prototype = new ctor();
|
||||
}
|
||||
function peg$SyntaxError(message, expected, found, location) {
|
||||
this.message = message;
|
||||
this.expected = expected;
|
||||
this.found = found;
|
||||
this.location = location;
|
||||
this.name = "SyntaxError";
|
||||
if (typeof Error.captureStackTrace === "function") {
|
||||
Error.captureStackTrace(this, peg$SyntaxError);
|
||||
}
|
||||
}
|
||||
peg$subclass(peg$SyntaxError, Error);
|
||||
peg$SyntaxError.buildMessage = function (expected, found) {
|
||||
var DESCRIBE_EXPECTATION_FNS = {
|
||||
literal: function (expectation) {
|
||||
return "\"" + literalEscape(expectation.text) + "\"";
|
||||
},
|
||||
"class": function (expectation) {
|
||||
var escapedParts = "", i;
|
||||
for (i = 0; i < expectation.parts.length; i++) {
|
||||
escapedParts += expectation.parts[i] instanceof Array
|
||||
? classEscape(expectation.parts[i][0]) + "-" + classEscape(expectation.parts[i][1])
|
||||
: classEscape(expectation.parts[i]);
|
||||
}
|
||||
return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]";
|
||||
},
|
||||
any: function (expectation) {
|
||||
return "any character";
|
||||
},
|
||||
end: function (expectation) {
|
||||
return "end of input";
|
||||
},
|
||||
other: function (expectation) {
|
||||
return expectation.description;
|
||||
}
|
||||
};
|
||||
function hex(ch) {
|
||||
return ch.charCodeAt(0).toString(16).toUpperCase();
|
||||
}
|
||||
function literalEscape(s) {
|
||||
return s
|
||||
.replace(/\\/g, '\\\\')
|
||||
.replace(/"/g, '\\"')
|
||||
.replace(/\0/g, '\\0')
|
||||
.replace(/\t/g, '\\t')
|
||||
.replace(/\n/g, '\\n')
|
||||
.replace(/\r/g, '\\r')
|
||||
.replace(/[\x00-\x0F]/g, function (ch) { return '\\x0' + hex(ch); })
|
||||
.replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) { return '\\x' + hex(ch); });
|
||||
}
|
||||
function classEscape(s) {
|
||||
return s
|
||||
.replace(/\\/g, '\\\\')
|
||||
.replace(/\]/g, '\\]')
|
||||
.replace(/\^/g, '\\^')
|
||||
.replace(/-/g, '\\-')
|
||||
.replace(/\0/g, '\\0')
|
||||
.replace(/\t/g, '\\t')
|
||||
.replace(/\n/g, '\\n')
|
||||
.replace(/\r/g, '\\r')
|
||||
.replace(/[\x00-\x0F]/g, function (ch) { return '\\x0' + hex(ch); })
|
||||
.replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) { return '\\x' + hex(ch); });
|
||||
}
|
||||
function describeExpectation(expectation) {
|
||||
return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
|
||||
}
|
||||
function describeExpected(expected) {
|
||||
var descriptions = new Array(expected.length), i, j;
|
||||
for (i = 0; i < expected.length; i++) {
|
||||
descriptions[i] = describeExpectation(expected[i]);
|
||||
}
|
||||
descriptions.sort();
|
||||
if (descriptions.length > 0) {
|
||||
for (i = 1, j = 1; i < descriptions.length; i++) {
|
||||
if (descriptions[i - 1] !== descriptions[i]) {
|
||||
descriptions[j] = descriptions[i];
|
||||
j++;
|
||||
}
|
||||
}
|
||||
descriptions.length = j;
|
||||
}
|
||||
switch (descriptions.length) {
|
||||
case 1:
|
||||
return descriptions[0];
|
||||
case 2:
|
||||
return descriptions[0] + " or " + descriptions[1];
|
||||
default:
|
||||
return descriptions.slice(0, -1).join(", ")
|
||||
+ ", or "
|
||||
+ descriptions[descriptions.length - 1];
|
||||
}
|
||||
}
|
||||
function describeFound(found) {
|
||||
return found ? "\"" + literalEscape(found) + "\"" : "end of input";
|
||||
}
|
||||
return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
|
||||
};
|
||||
function peg$parse(input, options) {
|
||||
options = options !== void 0 ? options : {};
|
||||
var peg$FAILED = {}, peg$startRuleIndices = { start: 0 }, peg$startRuleIndex = 0, peg$consts = [
|
||||
function (union_stmt) {
|
||||
return { lines, text: union_stmt };
|
||||
},
|
||||
peg$anyExpectation(),
|
||||
function (word) { return word; },
|
||||
function (words, comment) { return ''; },
|
||||
function (words, quote) { return quote; },
|
||||
";",
|
||||
peg$literalExpectation(";", false),
|
||||
function (words) { isSplit = true; return ";"; },
|
||||
function (words, stmt) {
|
||||
const text = words.join("") + stmt;
|
||||
let index = Math.max(lines.length - 1, 0);
|
||||
lines[index] = (lines[index] || '') + text;
|
||||
if (isSplit) {
|
||||
isSplit = false;
|
||||
lines.push('');
|
||||
}
|
||||
return text;
|
||||
},
|
||||
function (stmt, other) {
|
||||
const text = stmt.join("") + other.join("");
|
||||
let index = Math.max(lines.length - 1, 0);
|
||||
lines[index] = lines[index] + other.join("");
|
||||
return text;
|
||||
},
|
||||
function (comment) {
|
||||
return comment;
|
||||
},
|
||||
/^[^\r\n]/,
|
||||
peg$classExpectation(["\r", "\n"], true, false),
|
||||
function (start, words) {
|
||||
return start + words.join("");
|
||||
},
|
||||
"*/",
|
||||
peg$literalExpectation("*/", false),
|
||||
function (start, word) { return word; },
|
||||
function (start, words, end) { return start + words.join("") + end; },
|
||||
"\"",
|
||||
peg$literalExpectation("\"", false),
|
||||
/^[^"]/,
|
||||
peg$classExpectation(["\""], true, false),
|
||||
function (start, words, end) { return start + words.join("") + end; },
|
||||
"'",
|
||||
peg$literalExpectation("'", false),
|
||||
/^[^']/,
|
||||
peg$classExpectation(["'"], true, false),
|
||||
"--",
|
||||
peg$literalExpectation("--", false),
|
||||
/^[\r\n]/,
|
||||
peg$classExpectation(["\r", "\n"], false, false),
|
||||
"/*",
|
||||
peg$literalExpectation("/*", false),
|
||||
/^[ \t\r\n]/,
|
||||
peg$classExpectation([" ", "\t", "\r", "\n"], false, false)
|
||||
], peg$bytecode = [
|
||||
peg$decode("%;!/' 8!: !! )"),
|
||||
peg$decode("%$%$%%<;&=.##&&!&'#/6#1\"\"5!7!/($8\":\"\"! )(\"'#&'#0L*%%<;&=.##&&!&'#/6#1\"\"5!7!/($8\":\"\"! )(\"'#&'#&/j#%;\"/( 8!:#!\"\" ).H &%;%/( 8!:$!\"\" ).5 &%2%\"\"6%7&/' 8!:'!!\")/)$8\":(\"\"! )(\"'#&'#0\xCD*%$%%<;&=.##&&!&'#/6#1\"\"5!7!/($8\":\"\"! )(\"'#&'#0L*%%<;&=.##&&!&'#/6#1\"\"5!7!/($8\":\"\"! )(\"'#&'#&/j#%;\"/( 8!:#!\"\" ).H &%;%/( 8!:$!\"\" ).5 &%2%\"\"6%7&/' 8!:'!!\")/)$8\":(\"\"! )(\"'#&'#&/C#$1\"\"5!7!0(*1\"\"5!7!&/)$8\":)\"\"! )(\"'#&'#"),
|
||||
peg$decode("%;$.# &;#/' 8!:*!! )"),
|
||||
peg$decode("%;'/E#$4+\"\"5!7,0)*4+\"\"5!7,&/)$8\":-\"\"! )(\"'#&'#"),
|
||||
peg$decode("%;)/\xA3#$%%<2.\"\"6.7/=.##&&!&'#/7#1\"\"5!7!/)$8\":0\"\"$ )(\"'#&'#0S*%%<2.\"\"6.7/=.##&&!&'#/7#1\"\"5!7!/)$8\":0\"\"$ )(\"'#&'#&/3$;*/*$8#:1##\"! )(#'#(\"'#&'#"),
|
||||
peg$decode("%22\"\"6273/U#$44\"\"5!750)*44\"\"5!75&/9$22\"\"6273/*$8#:6##\"! )(#'#(\"'#&'#.e &%27\"\"6778/U#$49\"\"5!7:0)*49\"\"5!7:&/9$27\"\"6778/*$8#:6##\"! )(#'#(\"'#&'#"),
|
||||
peg$decode(";'.G &;).A &22\"\"6273.5 &27\"\"6778.) &2%\"\"6%7&"),
|
||||
peg$decode("2;\"\"6;7<"),
|
||||
peg$decode("4=\"\"5!7>"),
|
||||
peg$decode("2?\"\"6?7@"),
|
||||
peg$decode("2.\"\"6.7/"),
|
||||
peg$decode("$;,0#*;,&"),
|
||||
peg$decode("4A\"\"5!7B")
|
||||
], peg$currPos = 0, peg$savedPos = 0, peg$posDetailsCache = [{ line: 1, column: 1 }], peg$maxFailPos = 0, peg$maxFailExpected = [], peg$silentFails = 0, peg$result;
|
||||
if ("startRule" in options) {
|
||||
if (!(options.startRule in peg$startRuleIndices)) {
|
||||
throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
|
||||
}
|
||||
peg$startRuleIndex = peg$startRuleIndices[options.startRule];
|
||||
}
|
||||
function text() {
|
||||
return input.substring(peg$savedPos, peg$currPos);
|
||||
}
|
||||
function location() {
|
||||
return peg$computeLocation(peg$savedPos, peg$currPos);
|
||||
}
|
||||
function expected(description, location) {
|
||||
location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos);
|
||||
throw peg$buildStructuredError([peg$otherExpectation(description)], input.substring(peg$savedPos, peg$currPos), location);
|
||||
}
|
||||
function error(message, location) {
|
||||
location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos);
|
||||
throw peg$buildSimpleError(message, location);
|
||||
}
|
||||
function peg$literalExpectation(text, ignoreCase) {
|
||||
return { type: "literal", text: text, ignoreCase: ignoreCase };
|
||||
}
|
||||
function peg$classExpectation(parts, inverted, ignoreCase) {
|
||||
return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase };
|
||||
}
|
||||
function peg$anyExpectation() {
|
||||
return { type: "any" };
|
||||
}
|
||||
function peg$endExpectation() {
|
||||
return { type: "end" };
|
||||
}
|
||||
function peg$otherExpectation(description) {
|
||||
return { type: "other", description: description };
|
||||
}
|
||||
function peg$computePosDetails(pos) {
|
||||
var details = peg$posDetailsCache[pos], p;
|
||||
if (details) {
|
||||
return details;
|
||||
}
|
||||
else {
|
||||
p = pos - 1;
|
||||
while (!peg$posDetailsCache[p]) {
|
||||
p--;
|
||||
}
|
||||
details = peg$posDetailsCache[p];
|
||||
details = {
|
||||
line: details.line,
|
||||
column: details.column
|
||||
};
|
||||
while (p < pos) {
|
||||
if (input.charCodeAt(p) === 10) {
|
||||
details.line++;
|
||||
details.column = 1;
|
||||
}
|
||||
else {
|
||||
details.column++;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
peg$posDetailsCache[pos] = details;
|
||||
return details;
|
||||
}
|
||||
}
|
||||
function peg$computeLocation(startPos, endPos) {
|
||||
var startPosDetails = peg$computePosDetails(startPos), endPosDetails = peg$computePosDetails(endPos);
|
||||
return {
|
||||
start: {
|
||||
offset: startPos,
|
||||
line: startPosDetails.line,
|
||||
column: startPosDetails.column
|
||||
},
|
||||
end: {
|
||||
offset: endPos,
|
||||
line: endPosDetails.line,
|
||||
column: endPosDetails.column
|
||||
}
|
||||
};
|
||||
}
|
||||
function peg$fail(expected) {
|
||||
if (peg$currPos < peg$maxFailPos) {
|
||||
return;
|
||||
}
|
||||
if (peg$currPos > peg$maxFailPos) {
|
||||
peg$maxFailPos = peg$currPos;
|
||||
peg$maxFailExpected = [];
|
||||
}
|
||||
peg$maxFailExpected.push(expected);
|
||||
}
|
||||
function peg$buildSimpleError(message, location) {
|
||||
return new peg$SyntaxError(message, null, null, location);
|
||||
}
|
||||
function peg$buildStructuredError(expected, found, location) {
|
||||
return new peg$SyntaxError(peg$SyntaxError.buildMessage(expected, found), expected, found, location);
|
||||
}
|
||||
function peg$decode(s) {
|
||||
var bc = new Array(s.length), i;
|
||||
for (i = 0; i < s.length; i++) {
|
||||
bc[i] = s.charCodeAt(i) - 32;
|
||||
}
|
||||
return bc;
|
||||
}
|
||||
function peg$parseRule(index) {
|
||||
var bc = peg$bytecode[index], ip = 0, ips = [], end = bc.length, ends = [], stack = [], params, i;
|
||||
while (true) {
|
||||
while (ip < end) {
|
||||
switch (bc[ip]) {
|
||||
case 0:
|
||||
stack.push(peg$consts[bc[ip + 1]]);
|
||||
ip += 2;
|
||||
break;
|
||||
case 1:
|
||||
stack.push(void 0);
|
||||
ip++;
|
||||
break;
|
||||
case 2:
|
||||
stack.push(null);
|
||||
ip++;
|
||||
break;
|
||||
case 3:
|
||||
stack.push(peg$FAILED);
|
||||
ip++;
|
||||
break;
|
||||
case 4:
|
||||
stack.push([]);
|
||||
ip++;
|
||||
break;
|
||||
case 5:
|
||||
stack.push(peg$currPos);
|
||||
ip++;
|
||||
break;
|
||||
case 6:
|
||||
stack.pop();
|
||||
ip++;
|
||||
break;
|
||||
case 7:
|
||||
peg$currPos = stack.pop();
|
||||
ip++;
|
||||
break;
|
||||
case 8:
|
||||
stack.length -= bc[ip + 1];
|
||||
ip += 2;
|
||||
break;
|
||||
case 9:
|
||||
stack.splice(-2, 1);
|
||||
ip++;
|
||||
break;
|
||||
case 10:
|
||||
stack[stack.length - 2].push(stack.pop());
|
||||
ip++;
|
||||
break;
|
||||
case 11:
|
||||
stack.push(stack.splice(stack.length - bc[ip + 1], bc[ip + 1]));
|
||||
ip += 2;
|
||||
break;
|
||||
case 12:
|
||||
stack.push(input.substring(stack.pop(), peg$currPos));
|
||||
ip++;
|
||||
break;
|
||||
case 13:
|
||||
ends.push(end);
|
||||
ips.push(ip + 3 + bc[ip + 1] + bc[ip + 2]);
|
||||
if (stack[stack.length - 1]) {
|
||||
end = ip + 3 + bc[ip + 1];
|
||||
ip += 3;
|
||||
}
|
||||
else {
|
||||
end = ip + 3 + bc[ip + 1] + bc[ip + 2];
|
||||
ip += 3 + bc[ip + 1];
|
||||
}
|
||||
break;
|
||||
case 14:
|
||||
ends.push(end);
|
||||
ips.push(ip + 3 + bc[ip + 1] + bc[ip + 2]);
|
||||
if (stack[stack.length - 1] === peg$FAILED) {
|
||||
end = ip + 3 + bc[ip + 1];
|
||||
ip += 3;
|
||||
}
|
||||
else {
|
||||
end = ip + 3 + bc[ip + 1] + bc[ip + 2];
|
||||
ip += 3 + bc[ip + 1];
|
||||
}
|
||||
break;
|
||||
case 15:
|
||||
ends.push(end);
|
||||
ips.push(ip + 3 + bc[ip + 1] + bc[ip + 2]);
|
||||
if (stack[stack.length - 1] !== peg$FAILED) {
|
||||
end = ip + 3 + bc[ip + 1];
|
||||
ip += 3;
|
||||
}
|
||||
else {
|
||||
end = ip + 3 + bc[ip + 1] + bc[ip + 2];
|
||||
ip += 3 + bc[ip + 1];
|
||||
}
|
||||
break;
|
||||
case 16:
|
||||
if (stack[stack.length - 1] !== peg$FAILED) {
|
||||
ends.push(end);
|
||||
ips.push(ip);
|
||||
end = ip + 2 + bc[ip + 1];
|
||||
ip += 2;
|
||||
}
|
||||
else {
|
||||
ip += 2 + bc[ip + 1];
|
||||
}
|
||||
break;
|
||||
case 17:
|
||||
ends.push(end);
|
||||
ips.push(ip + 3 + bc[ip + 1] + bc[ip + 2]);
|
||||
if (input.length > peg$currPos) {
|
||||
end = ip + 3 + bc[ip + 1];
|
||||
ip += 3;
|
||||
}
|
||||
else {
|
||||
end = ip + 3 + bc[ip + 1] + bc[ip + 2];
|
||||
ip += 3 + bc[ip + 1];
|
||||
}
|
||||
break;
|
||||
case 18:
|
||||
ends.push(end);
|
||||
ips.push(ip + 4 + bc[ip + 2] + bc[ip + 3]);
|
||||
if (input.substr(peg$currPos, peg$consts[bc[ip + 1]].length) === peg$consts[bc[ip + 1]]) {
|
||||
end = ip + 4 + bc[ip + 2];
|
||||
ip += 4;
|
||||
}
|
||||
else {
|
||||
end = ip + 4 + bc[ip + 2] + bc[ip + 3];
|
||||
ip += 4 + bc[ip + 2];
|
||||
}
|
||||
break;
|
||||
case 19:
|
||||
ends.push(end);
|
||||
ips.push(ip + 4 + bc[ip + 2] + bc[ip + 3]);
|
||||
if (input.substr(peg$currPos, peg$consts[bc[ip + 1]].length).toLowerCase() === peg$consts[bc[ip + 1]]) {
|
||||
end = ip + 4 + bc[ip + 2];
|
||||
ip += 4;
|
||||
}
|
||||
else {
|
||||
end = ip + 4 + bc[ip + 2] + bc[ip + 3];
|
||||
ip += 4 + bc[ip + 2];
|
||||
}
|
||||
break;
|
||||
case 20:
|
||||
ends.push(end);
|
||||
ips.push(ip + 4 + bc[ip + 2] + bc[ip + 3]);
|
||||
if (peg$consts[bc[ip + 1]].test(input.charAt(peg$currPos))) {
|
||||
end = ip + 4 + bc[ip + 2];
|
||||
ip += 4;
|
||||
}
|
||||
else {
|
||||
end = ip + 4 + bc[ip + 2] + bc[ip + 3];
|
||||
ip += 4 + bc[ip + 2];
|
||||
}
|
||||
break;
|
||||
case 21:
|
||||
stack.push(input.substr(peg$currPos, bc[ip + 1]));
|
||||
peg$currPos += bc[ip + 1];
|
||||
ip += 2;
|
||||
break;
|
||||
case 22:
|
||||
stack.push(peg$consts[bc[ip + 1]]);
|
||||
peg$currPos += peg$consts[bc[ip + 1]].length;
|
||||
ip += 2;
|
||||
break;
|
||||
case 23:
|
||||
stack.push(peg$FAILED);
|
||||
if (peg$silentFails === 0) {
|
||||
peg$fail(peg$consts[bc[ip + 1]]);
|
||||
}
|
||||
ip += 2;
|
||||
break;
|
||||
case 24:
|
||||
peg$savedPos = stack[stack.length - 1 - bc[ip + 1]];
|
||||
ip += 2;
|
||||
break;
|
||||
case 25:
|
||||
peg$savedPos = peg$currPos;
|
||||
ip++;
|
||||
break;
|
||||
case 26:
|
||||
params = bc.slice(ip + 4, ip + 4 + bc[ip + 3]);
|
||||
for (i = 0; i < bc[ip + 3]; i++) {
|
||||
params[i] = stack[stack.length - 1 - params[i]];
|
||||
}
|
||||
stack.splice(stack.length - bc[ip + 2], bc[ip + 2], peg$consts[bc[ip + 1]].apply(null, params));
|
||||
ip += 4 + bc[ip + 3];
|
||||
break;
|
||||
case 27:
|
||||
stack.push(peg$parseRule(bc[ip + 1]));
|
||||
ip += 2;
|
||||
break;
|
||||
case 28:
|
||||
peg$silentFails++;
|
||||
ip++;
|
||||
break;
|
||||
case 29:
|
||||
peg$silentFails--;
|
||||
ip++;
|
||||
break;
|
||||
default:
|
||||
throw new Error("Invalid opcode: " + bc[ip] + ".");
|
||||
}
|
||||
}
|
||||
if (ends.length > 0) {
|
||||
end = ends.pop();
|
||||
ip = ips.pop();
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return stack[0];
|
||||
}
|
||||
let lines = [];
|
||||
let isSplit = false;
|
||||
peg$result = peg$parseRule(peg$startRuleIndex);
|
||||
if (peg$result !== peg$FAILED && peg$currPos === input.length) {
|
||||
return peg$result;
|
||||
}
|
||||
else {
|
||||
if (peg$result !== peg$FAILED && peg$currPos < input.length) {
|
||||
peg$fail(peg$endExpectation());
|
||||
}
|
||||
throw peg$buildStructuredError(peg$maxFailExpected, peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null, peg$maxFailPos < input.length
|
||||
? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)
|
||||
: peg$computeLocation(peg$maxFailPos, peg$maxFailPos));
|
||||
}
|
||||
}
|
||||
return {
|
||||
SyntaxError: peg$SyntaxError,
|
||||
parse: peg$parse
|
||||
};
|
||||
});
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,84 +0,0 @@
|
||||
"use strict";
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* AUTOCOMPLETE_MODULES and SYNTAX_MODULES are generated, do not edit manually, see tools/jison/generateParsers.js
|
||||
*/
|
||||
const AUTOCOMPLETE_MODULES = {
|
||||
calcite: require("calcite/calciteAutocompleteParser"),
|
||||
druid: require("druid/druidAutocompleteParser"),
|
||||
elasticsearch: require("elasticsearch/elasticsearchAutocompleteParser"),
|
||||
flink: require("flink/flinkAutocompleteParser"),
|
||||
generic: require("generic/genericAutocompleteParser"),
|
||||
hive: require("hive/hiveAutocompleteParser"),
|
||||
impala: require("impala/impalaAutocompleteParser"),
|
||||
ksql: require("ksql/ksqlAutocompleteParser"),
|
||||
phoenix: require("phoenix/phoenixAutocompleteParser"),
|
||||
presto: require("presto/prestoAutocompleteParser")
|
||||
};
|
||||
const SYNTAX_MODULES = {
|
||||
calcite: require("calcite/calciteSyntaxParser"),
|
||||
druid: require("druid/druidSyntaxParser"),
|
||||
elasticsearch: require("elasticsearch/elasticsearchSyntaxParser"),
|
||||
flink: require("flink/flinkSyntaxParser"),
|
||||
generic: require("generic/genericSyntaxParser"),
|
||||
hive: require("hive/hiveSyntaxParser"),
|
||||
impala: require("impala/impalaSyntaxParser"),
|
||||
ksql: require("ksql/ksqlSyntaxParser"),
|
||||
phoenix: require("phoenix/phoenixSyntaxParser"),
|
||||
presto: require("presto/prestoSyntaxParser")
|
||||
};
|
||||
/* eslint-enable */
|
||||
class SqlParserRepository {
|
||||
constructor() {
|
||||
this.modulePromises = {};
|
||||
}
|
||||
getParser(sourceType, parserType) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (!this.modulePromises[sourceType + parserType]) {
|
||||
const modules = parserType === 'Autocomplete' ? AUTOCOMPLETE_MODULES : SYNTAX_MODULES;
|
||||
this.modulePromises[sourceType + parserType] = new Promise((resolve, reject) => {
|
||||
const targetModule = modules[sourceType] || modules.generic;
|
||||
resolve(targetModule);
|
||||
});
|
||||
}
|
||||
return this.modulePromises[sourceType + parserType];
|
||||
});
|
||||
}
|
||||
getAutocompleter(sourceType) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return this.getParser(sourceType, 'Autocomplete');
|
||||
});
|
||||
}
|
||||
getSyntaxParser(sourceType) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return this.getParser(sourceType, 'Syntax');
|
||||
});
|
||||
}
|
||||
}
|
||||
const sqlParserRepository = new SqlParserRepository();
|
||||
exports.default = sqlParserRepository;
|
@ -1,75 +0,0 @@
|
||||
"use strict";
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
/**
|
||||
* Calculates the Optimal String Alignment distance between two strings. Returns 0 when the strings are equal and the
|
||||
* distance when not, distances is less than or equal to the length of the longest string.
|
||||
*
|
||||
* @param strA
|
||||
* @param strB
|
||||
* @param [ignoreCase]
|
||||
* @returns {number} The similarity
|
||||
*/
|
||||
const stringDistance = function (strA, strB, ignoreCase) {
|
||||
if (ignoreCase) {
|
||||
strA = strA.toLowerCase();
|
||||
strB = strB.toLowerCase();
|
||||
}
|
||||
// TODO: Consider other algorithms for performance
|
||||
const strALength = strA.length;
|
||||
const strBLength = strB.length;
|
||||
if (strALength === 0) {
|
||||
return strBLength;
|
||||
}
|
||||
if (strBLength === 0) {
|
||||
return strALength;
|
||||
}
|
||||
const distances = new Array(strALength);
|
||||
let cost, deletion, insertion, substitution, transposition;
|
||||
for (let i = 0; i <= strALength; i++) {
|
||||
distances[i] = new Array(strBLength);
|
||||
distances[i][0] = i;
|
||||
for (let j = 1; j <= strBLength; j++) {
|
||||
if (!i) {
|
||||
distances[0][j] = j;
|
||||
}
|
||||
else {
|
||||
cost = strA[i - 1] === strB[j - 1] ? 0 : 1;
|
||||
deletion = distances[i - 1][j] + 1;
|
||||
insertion = distances[i][j - 1] + 1;
|
||||
substitution = distances[i - 1][j - 1] + cost;
|
||||
if (deletion <= insertion && deletion <= substitution) {
|
||||
distances[i][j] = deletion;
|
||||
}
|
||||
else if (insertion <= deletion && insertion <= substitution) {
|
||||
distances[i][j] = insertion;
|
||||
}
|
||||
else {
|
||||
distances[i][j] = substitution;
|
||||
}
|
||||
if (i > 1 && j > 1 && strA[i] === strB[j - 1] && strA[i - 1] === strB[j]) {
|
||||
transposition = distances[i - 2][j - 2] + cost;
|
||||
if (transposition < distances[i][j]) {
|
||||
distances[i][j] = transposition;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return distances[strALength][strBLength];
|
||||
};
|
||||
exports.default = stringDistance;
|
@ -1,8 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const parser = require("./lib/parser");
|
||||
exports.parser = parser;
|
||||
const filter = require("./lib/filter");
|
||||
exports.filter = filter;
|
||||
const flinkParser_1 = require("./lib/flinkParser");
|
||||
exports.flinksqlParser = flinkParser_1.default;
|
@ -1,27 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const commentFilter = require("../core/comment");
|
||||
/**
|
||||
* 过滤--注释
|
||||
* @param {String} sql
|
||||
*/
|
||||
function filterComments(sql) {
|
||||
return commentFilter.parse(sql).text;
|
||||
}
|
||||
exports.filterComments = filterComments;
|
||||
/**
|
||||
* 清除注释和前后空格
|
||||
* @param {String} sql
|
||||
*/
|
||||
function cleanSql(sql) {
|
||||
return filterComments(sql);
|
||||
}
|
||||
exports.cleanSql = cleanSql;
|
||||
/**
|
||||
* 分割sql
|
||||
* @param {String} sql
|
||||
*/
|
||||
function splitSql(sql) {
|
||||
return commentFilter.parse(sql).lines;
|
||||
}
|
||||
exports.splitSql = splitSql;
|
@ -1,53 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const antlr4 = require("antlr4");
|
||||
const error_1 = require("antlr4/error");
|
||||
const sqlLexer_1 = require("../antlr4/flinksql/sqlLexer");
|
||||
const sqlParser_1 = require("../antlr4/flinksql/sqlParser");
|
||||
const utils_1 = require("../utils");
|
||||
class SqlErrorListener extends error_1.ErrorListener {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.error = null;
|
||||
}
|
||||
syntaxError(recognizer, offendingSymbol, line, charPositionInLine, msg, e) {
|
||||
this.error = {
|
||||
line,
|
||||
column: charPositionInLine,
|
||||
token: offendingSymbol,
|
||||
errorMsg: msg
|
||||
};
|
||||
}
|
||||
}
|
||||
function parserSingle(sql) {
|
||||
if (!sql || !sql.trim()) {
|
||||
return null;
|
||||
}
|
||||
const inputStream = new antlr4.InputStream(sql.toUpperCase());
|
||||
const lexer = new sqlLexer_1.sqlLexer(inputStream);
|
||||
const tokenStream = new antlr4.CommonTokenStream(lexer);
|
||||
const parser = new sqlParser_1.sqlParser(tokenStream);
|
||||
parser.buildParseTrees = true;
|
||||
let listener = new SqlErrorListener();
|
||||
parser.addErrorListener(listener);
|
||||
parser.singleStatement();
|
||||
return listener.error;
|
||||
}
|
||||
function parserSyntax(sql) {
|
||||
let runSql = typeof sql == 'string' ? sql : sql.join('');
|
||||
const sqls = utils_1.splitSql(runSql);
|
||||
for (let i = 0, index = 0; i < sqls.length; i++) {
|
||||
let end = runSql[sqls[i]] == ';' ? sqls[i] : sqls[i] + 1;
|
||||
/**
|
||||
* 这边不取分号
|
||||
*/
|
||||
let sql = new Array(index).fill(' ').join('') + runSql.substring(index, end);
|
||||
let err = parserSingle(sql);
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
index = sqls[i] + 1;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
exports.default = parserSyntax;
|
@ -1,76 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
// import * as sqlSyntaxParser from '../core/sqlSyntaxParser';
|
||||
const hiveSyntaxParser_1 = require("../core/parse/hive/hiveSyntaxParser");
|
||||
const hiveAutocompleteParser_1 = require("../core/parse/hive/hiveAutocompleteParser");
|
||||
const impalaSyntaxParser_1 = require("../core/parse/impala/impalaSyntaxParser");
|
||||
const impalaAutocompleteParser_1 = require("../core/parse/impala/impalaAutocompleteParser");
|
||||
const genericSyntaxParser_1 = require("../core/parse/generic/genericSyntaxParser");
|
||||
const genericAutocompleteParser_1 = require("../core/parse/generic/genericAutocompleteParser");
|
||||
function getSyntaxParser(type) {
|
||||
switch (type) {
|
||||
case sqlType.Hive: {
|
||||
return hiveSyntaxParser_1.default;
|
||||
}
|
||||
case sqlType.Impala: {
|
||||
return impalaSyntaxParser_1.default;
|
||||
}
|
||||
case sqlType.None: {
|
||||
return genericSyntaxParser_1.default;
|
||||
}
|
||||
default: {
|
||||
return hiveSyntaxParser_1.default;
|
||||
}
|
||||
}
|
||||
}
|
||||
function getAutoCompleteParser(type) {
|
||||
switch (type) {
|
||||
case sqlType.Hive: {
|
||||
return hiveAutocompleteParser_1.default;
|
||||
}
|
||||
case sqlType.Impala: {
|
||||
return impalaAutocompleteParser_1.default;
|
||||
}
|
||||
case sqlType.None: {
|
||||
return genericAutocompleteParser_1.default;
|
||||
}
|
||||
default: {
|
||||
return hiveAutocompleteParser_1.default;
|
||||
}
|
||||
}
|
||||
}
|
||||
var sqlType;
|
||||
(function (sqlType) {
|
||||
sqlType["Hive"] = "hive";
|
||||
sqlType["None"] = "sql";
|
||||
sqlType["Impala"] = "impala";
|
||||
})(sqlType || (sqlType = {}));
|
||||
exports.sqlType = sqlType;
|
||||
function sqlToParserArgs(sql) {
|
||||
let preSql = '', sufSql = '';
|
||||
if (Object.prototype.toString.call(sql) == '[object Array]') {
|
||||
preSql = sql[0];
|
||||
sufSql = sql[1];
|
||||
}
|
||||
else {
|
||||
preSql = sql;
|
||||
}
|
||||
return [preSql, sufSql];
|
||||
}
|
||||
/**
|
||||
* 校验语法
|
||||
*/
|
||||
function parseSyntax(sql, type = sqlType.Hive) {
|
||||
const parserArgs = sqlToParserArgs(sql);
|
||||
console.log(getSyntaxParser(type));
|
||||
return getSyntaxParser(type).parseSyntax(parserArgs[0], parserArgs[1], type, false);
|
||||
}
|
||||
exports.parseSyntax = parseSyntax;
|
||||
/**
|
||||
* 自动补全提示
|
||||
*/
|
||||
function parserSql(sql, type = sqlType.Hive) {
|
||||
const parserArgs = sqlToParserArgs(sql);
|
||||
return getAutoCompleteParser(type).parseSql(parserArgs[0], parserArgs[1], type, false);
|
||||
}
|
||||
exports.parserSql = parserSql;
|
@ -1,467 +0,0 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const exec = require('child_process').exec;
|
||||
const LICENSE = '// Licensed to Cloudera, Inc. under one\n' +
|
||||
'// or more contributor license agreements. See the NOTICE file\n' +
|
||||
'// distributed with this work for additional information\n' +
|
||||
'// regarding copyright ownership. Cloudera, Inc. licenses this file\n' +
|
||||
'// to you under the Apache License, Version 2.0 (the\n' +
|
||||
'// "License"); you may not use this file except in compliance\n' +
|
||||
'// with the License. You may obtain a copy of the License at\n' +
|
||||
'//\n' +
|
||||
'// http://www.apache.org/licenses/LICENSE-2.0\n' +
|
||||
'//\n' +
|
||||
'// Unless required by applicable law or agreed to in writing, software\n' +
|
||||
'// distributed under the License is distributed on an "AS IS" BASIS,\n' +
|
||||
'// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n' +
|
||||
'// See the License for the specific language governing permissions and\n' +
|
||||
'// limitations under the License.\n';
|
||||
const SQL_STATEMENTS_PARSER_JSDOC = '/**\n' +
|
||||
' * @param {string} input\n' +
|
||||
' *\n' +
|
||||
' * @return {SqlStatementsParserResult}\n' +
|
||||
' */\n';
|
||||
const PARSER_FOLDER = path.join(process.cwd(), 'src/core/parse/');
|
||||
const JISON_FOLDER = path.join(process.cwd(), 'src/jison/');
|
||||
const SQL_PARSER_REPOSITORY_PATH = path.join(PARSER_FOLDER, 'sqlParserRepository.js');
|
||||
const SYNTAX_PARSER_IMPORT_TEMPLATE = ' KEY: require("KEY/KEYSyntaxParser")';
|
||||
const AUTOCOMPLETE_PARSER_IMPORT_TEMPLATE = ' KEY: require("KEY/KEYAutocompleteParser")';
|
||||
const parserDefinitions = {
|
||||
globalSearchParser: {
|
||||
sources: [path.join(JISON_FOLDER, 'globalSearchParser.jison')],
|
||||
target: path.join(JISON_FOLDER, 'globalSearchParser.jison'),
|
||||
outputFolder: PARSER_FOLDER,
|
||||
afterParse: contents => new Promise(resolve => {
|
||||
resolve(LICENSE +
|
||||
contents.replace('var globalSearchParser = ', "import SqlParseSupport from './sqlParseSupport';\n\nvar globalSearchParser = ") +
|
||||
'\nexport default globalSearchParser;\n');
|
||||
})
|
||||
},
|
||||
solrFormulaParser: {
|
||||
sources: [path.join(JISON_FOLDER, 'solrFormulaParser.jison')],
|
||||
target: path.join(JISON_FOLDER, 'solrFormulaParser.jison'),
|
||||
outputFolder: PARSER_FOLDER,
|
||||
afterParse: contents => new Promise(resolve => {
|
||||
resolve(LICENSE + contents + 'export default solrFormulaParser;\n');
|
||||
})
|
||||
},
|
||||
solrQueryParser: {
|
||||
sources: [path.join(JISON_FOLDER, 'solrQueryParser.jison')],
|
||||
target: path.join(JISON_FOLDER, 'solrQueryParser.jison'),
|
||||
outputFolder: PARSER_FOLDER,
|
||||
afterParse: contents => new Promise(resolve => {
|
||||
resolve(LICENSE + contents + 'export default solrQueryParser;\n');
|
||||
})
|
||||
},
|
||||
sqlStatementsParser: {
|
||||
sources: [path.join(JISON_FOLDER, 'sqlStatementsParser.jison')],
|
||||
target: path.join(JISON_FOLDER, 'sqlStatementsParser.jison'),
|
||||
outputFolder: PARSER_FOLDER,
|
||||
afterParse: contents => new Promise(resolve => {
|
||||
resolve(LICENSE +
|
||||
contents.replace('parse: function parse', SQL_STATEMENTS_PARSER_JSDOC + 'parse: function parse') +
|
||||
'export default sqlStatementsParser;\n');
|
||||
})
|
||||
}
|
||||
};
|
||||
const mkdir = path => new Promise((resolve, reject) => {
|
||||
if (fs.existsSync(path)) {
|
||||
resolve();
|
||||
}
|
||||
else {
|
||||
fs.mkdir(path, err => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
});
|
||||
const readFile = path => new Promise((resolve, reject) => {
|
||||
fs.readFile(path, (err, buf) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
}
|
||||
resolve(buf ? buf.toString() : '');
|
||||
});
|
||||
});
|
||||
const writeFile = (path, contents) => new Promise((resolve, reject) => {
|
||||
fs.writeFile(path, contents, err => {
|
||||
if (err) {
|
||||
reject();
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
const copyFile = (source, destination, contentsCallback) => new Promise((resolve, reject) => {
|
||||
readFile(source)
|
||||
.then(contents => {
|
||||
writeFile(destination, contentsCallback ? contentsCallback(contents) : contents)
|
||||
.then(resolve)
|
||||
.catch(reject);
|
||||
})
|
||||
.catch(reject);
|
||||
});
|
||||
const deleteFile = path => {
|
||||
fs.unlinkSync(path);
|
||||
};
|
||||
const execCmd = cmd => new Promise((resolve, reject) => {
|
||||
exec(cmd, (err, stdout, stderr) => {
|
||||
if (err) {
|
||||
reject('stderr:\n' + stderr + '\n\nstdout:\n' + stdout);
|
||||
}
|
||||
resolve(stdout);
|
||||
});
|
||||
});
|
||||
const generateParser = parserName => new Promise((resolve, reject) => {
|
||||
const parserConfig = parserDefinitions[parserName];
|
||||
/**
|
||||
* 合并jison文件,生成待编译文件
|
||||
*/
|
||||
const concatPromise = new Promise((resolve, reject) => {
|
||||
if (parserConfig.sources.length > 1 && parserConfig.target) {
|
||||
console.log('Concatenating files...');
|
||||
const promises = parserConfig.sources.map(fileName => readFile(fileName));
|
||||
Promise.all(promises)
|
||||
.then(contents => {
|
||||
writeFile(parserConfig.target, contents.join('')).then(() => {
|
||||
resolve(parserConfig.target);
|
||||
});
|
||||
})
|
||||
.catch(reject);
|
||||
}
|
||||
else if (parserConfig.sources.length === 1) {
|
||||
resolve(parserConfig.sources[0]);
|
||||
}
|
||||
else {
|
||||
reject('No jison source specified');
|
||||
}
|
||||
});
|
||||
concatPromise
|
||||
.then(targetPath => {
|
||||
console.log(`Generate precomplier jison success(${targetPath})...`);
|
||||
let jisonCommand = 'jison ' + targetPath;
|
||||
if (parserConfig.lexer) {
|
||||
jisonCommand += ' ' + parserConfig.lexer;
|
||||
}
|
||||
jisonCommand += ' -m js';
|
||||
console.log('Generating parser...');
|
||||
execCmd(jisonCommand)
|
||||
.then(stdout => {
|
||||
if (/\S/.test(stdout)) {
|
||||
console.log('got output for: ' + jisonCommand);
|
||||
console.log(stdout);
|
||||
}
|
||||
if (parserConfig.sources.length > 1) {
|
||||
deleteFile(targetPath); // Remove concatenated file
|
||||
}
|
||||
console.log('Adjusting JS...');
|
||||
/**
|
||||
* 删除生成文件,复制到配置的文件夹中
|
||||
*/
|
||||
const generatedJsFileName = parserConfig.target
|
||||
.replace('.jison', '.js')
|
||||
.replace(/^.*\/([^/]+)$/, '$1');
|
||||
readFile(generatedJsFileName)
|
||||
.then(contents => {
|
||||
parserConfig
|
||||
.afterParse(contents)
|
||||
.then(finalContents => {
|
||||
writeFile(path.join(parserConfig.outputFolder, generatedJsFileName), finalContents)
|
||||
.then(() => {
|
||||
deleteFile(generatedJsFileName);
|
||||
resolve();
|
||||
})
|
||||
.catch(reject);
|
||||
})
|
||||
.catch(reject);
|
||||
})
|
||||
.catch(reject);
|
||||
})
|
||||
.catch(reject);
|
||||
})
|
||||
.catch(reject);
|
||||
});
|
||||
let parsersToGenerate = [];
|
||||
const invalid = [];
|
||||
let all = false;
|
||||
const listDir = folder => new Promise(resolve => {
|
||||
fs.readdir(folder, (err, files) => {
|
||||
resolve(files);
|
||||
});
|
||||
});
|
||||
/**
|
||||
* 构造,添加子语言模块编译配置
|
||||
* @param {*} fileIndex 文件的存在表
|
||||
* @param {*} folder 对应的子语言文件夹
|
||||
* @param {*} sharedFiles 子语言核心jison文件
|
||||
* @param {*} autocomplete 是否为补全文件
|
||||
*/
|
||||
const findParser = (fileIndex, folder, sharedFiles, autocomplete) => {
|
||||
const prefix = autocomplete ? 'autocomplete' : 'syntax';
|
||||
if (fileIndex[prefix + '_header.jison'] && fileIndex[prefix + '_footer.jison']) {
|
||||
const parserName = folder + (autocomplete ? 'AutocompleteParser' : 'SyntaxParser');
|
||||
const parserDefinition = {
|
||||
sources: [path.join(JISON_FOLDER, 'sql', folder, prefix + '_header.jison')].concat(sharedFiles),
|
||||
lexer: path.join(JISON_FOLDER, 'sql', folder, '/sql.jisonlex'),
|
||||
target: path.join(JISON_FOLDER, 'sql', folder, parserName + '.jison'),
|
||||
sqlParser: autocomplete ? 'AUTOCOMPLETE' : 'SYNTAX',
|
||||
outputFolder: path.join(PARSER_FOLDER, folder),
|
||||
afterParse: contents => new Promise(resolve => {
|
||||
resolve(LICENSE +
|
||||
contents
|
||||
.replace('var ' + parserName + ' = ', "import SqlParseSupport from " +
|
||||
"'./sqlParseSupport';\n\nvar " +
|
||||
parserName +
|
||||
' = ')
|
||||
.replace('loc: yyloc,', "loc: lexer.yylloc, ruleId: stack.slice(stack.length - 2, stack.length).join(''),") +
|
||||
'\nexport default ' +
|
||||
parserName +
|
||||
';\n');
|
||||
})
|
||||
};
|
||||
parserDefinition.sources.push(path.join(JISON_FOLDER, 'sql', folder, prefix + '_footer.jison'));
|
||||
parserDefinitions[parserName] = parserDefinition;
|
||||
}
|
||||
else {
|
||||
console.log("Warn: Could not find '" +
|
||||
prefix +
|
||||
"_header.jison' or '" +
|
||||
prefix +
|
||||
"_footer.jison' in " +
|
||||
JISON_FOLDER +
|
||||
'sql/' +
|
||||
folder +
|
||||
'/');
|
||||
}
|
||||
};
|
||||
/**
|
||||
* 添加所有子语言编译配置
|
||||
*/
|
||||
const identifySqlParsers = () => new Promise(resolve => {
|
||||
listDir(JISON_FOLDER + 'sql').then(files => {
|
||||
const promises = [];
|
||||
files.forEach(folder => {
|
||||
const subLanguageJisonFolder = path.join(JISON_FOLDER, 'sql', folder);
|
||||
promises.push(
|
||||
/**
|
||||
* 遍历具体的语言目录
|
||||
*/
|
||||
listDir(subLanguageJisonFolder).then(jisonFiles => {
|
||||
/**
|
||||
* 文件目录记录表
|
||||
*/
|
||||
const fileIndex = {};
|
||||
jisonFiles.forEach(jisonFile => {
|
||||
fileIndex[jisonFile] = true;
|
||||
});
|
||||
/**
|
||||
* 挑选核心的jison文件(剥除autocomplate,syntax的功能文件)
|
||||
*/
|
||||
const sharedFiles = jisonFiles
|
||||
.filter(jisonFile => jisonFile.indexOf('sql_') !== -1)
|
||||
.map(jisonFile => path.join(subLanguageJisonFolder, jisonFile));
|
||||
if (fileIndex['sql.jisonlex']) {
|
||||
/**
|
||||
* 添加子语言自动补全编译配置
|
||||
* 加入了error.jison,为了在校验失败的情况下也能够提示?
|
||||
*/
|
||||
findParser(fileIndex, folder, sharedFiles, true);
|
||||
/**
|
||||
* 添加子语言语法检查配置
|
||||
*/
|
||||
findParser(fileIndex, folder, sharedFiles.filter(path => path.indexOf('_error.jison') === -1), false);
|
||||
}
|
||||
else {
|
||||
console.log("Warn: Could not find 'sql.jisonlex' in " + JISON_FOLDER + 'sql/' + folder + '/');
|
||||
}
|
||||
}));
|
||||
});
|
||||
Promise.all(promises).then(resolve);
|
||||
});
|
||||
});
|
||||
const copyTests = (source, target) => new Promise((resolve, reject) => {
|
||||
const replaceRegexp = new RegExp(source + '(Autocomplete|Syntax)Parser', 'g');
|
||||
mkdir(PARSER_FOLDER + target)
|
||||
.then(() => {
|
||||
mkdir(PARSER_FOLDER + target + '/test')
|
||||
.then(() => {
|
||||
listDir(PARSER_FOLDER + source + '/test')
|
||||
.then(testFiles => {
|
||||
const copyPromises = [];
|
||||
testFiles.forEach(testFile => {
|
||||
copyPromises.push(copyFile(PARSER_FOLDER + source + '/test/' + testFile, PARSER_FOLDER + target + '/test/' + testFile.replace(source, target), contents => contents.replace(replaceRegexp, target + '$1Parser')));
|
||||
});
|
||||
Promise.all(copyPromises)
|
||||
.then(resolve)
|
||||
.catch(reject);
|
||||
})
|
||||
.catch(reject);
|
||||
})
|
||||
.catch(reject);
|
||||
})
|
||||
.catch(reject);
|
||||
});
|
||||
/**
|
||||
* 校验,配置自定义语言
|
||||
*/
|
||||
const prepareForNewParser = () => new Promise((resolve, reject) => {
|
||||
/**
|
||||
* 根据一个子语言文件夹来生成一个特殊sql名字的语法文件
|
||||
* -new generic postgresql
|
||||
* 根据generic文件夹生成postgresql语法文件
|
||||
*/
|
||||
if (process.argv.length === 3 && process.argv[0] === '-new') {
|
||||
process.argv.shift();
|
||||
const source = process.argv.shift();
|
||||
const target = process.argv.shift();
|
||||
console.log("Generating new parser '" + target + "' based on '" + source + "'...");
|
||||
process.argv.push(target);
|
||||
if (!Object.keys(parserDefinitions).some(key => {
|
||||
if (key.indexOf(source) === 0) {
|
||||
copyTests(source, target)
|
||||
.then(() => {
|
||||
mkdir(JISON_FOLDER + 'sql/' + target)
|
||||
.then(() => {
|
||||
listDir(JISON_FOLDER + 'sql/' + source).then(files => {
|
||||
const copyPromises = [];
|
||||
files.forEach(file => {
|
||||
copyPromises.push(copyFile(JISON_FOLDER + 'sql/' + source + '/' + file, JISON_FOLDER + 'sql/' + target + '/' + file));
|
||||
});
|
||||
Promise.all(copyPromises).then(() => {
|
||||
const autocompleteSources = [
|
||||
'sql/' + target + '/autocomplete_header.jison'
|
||||
];
|
||||
const syntaxSources = ['sql/' + target + '/syntax_header.jison'];
|
||||
files.forEach(file => {
|
||||
if (file.indexOf('sql_') === 0) {
|
||||
autocompleteSources.push('sql/' + target + '/' + file);
|
||||
syntaxSources.push('sql/' + target + '/' + file);
|
||||
}
|
||||
});
|
||||
autocompleteSources.push('sql/' + target + '/autocomplete_footer.jison');
|
||||
syntaxSources.push('sql/' + target + '/syntax_footer.jison');
|
||||
mkdir('desktop/core/src/desktop/js/parse/sql/' + target).then(() => {
|
||||
copyFile('desktop/core/src/desktop/js/parse/sql/' +
|
||||
source +
|
||||
'/sqlParseSupport.js', 'desktop/core/src/desktop/js/parse/sql/' +
|
||||
target +
|
||||
'/sqlParseSupport.js', contents => contents.replace(/parser\.yy\.activeDialect = '[^']+';'/g, "parser.yy.activeDialect = '" + target + "';")).then(() => {
|
||||
identifySqlParsers()
|
||||
.then(resolve)
|
||||
.catch(reject);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
})
|
||||
.catch(reject);
|
||||
return true;
|
||||
}
|
||||
})) {
|
||||
reject("No existing parser found for '" + source + "'");
|
||||
}
|
||||
}
|
||||
else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
identifySqlParsers().then(() => {
|
||||
process.argv.shift();
|
||||
process.argv.shift();
|
||||
console.log('Generate sub language success...');
|
||||
prepareForNewParser().then(() => {
|
||||
console.log('Generate custom language success...');
|
||||
process.argv.forEach(arg => {
|
||||
if (arg === 'all') {
|
||||
/**
|
||||
* 编译全部
|
||||
*/
|
||||
all = true;
|
||||
}
|
||||
else if (parserDefinitions[arg]) {
|
||||
/**
|
||||
* 特点编译目标
|
||||
*/
|
||||
parsersToGenerate.push(arg);
|
||||
}
|
||||
else {
|
||||
/**
|
||||
* 根据关键字匹配编译目标
|
||||
*/
|
||||
let prefixFound = false;
|
||||
Object.keys(parserDefinitions).forEach(key => {
|
||||
if (key.indexOf(arg) === 0) {
|
||||
prefixFound = true;
|
||||
parsersToGenerate.push(key);
|
||||
}
|
||||
});
|
||||
if (!prefixFound) {
|
||||
invalid.push(arg);
|
||||
}
|
||||
}
|
||||
});
|
||||
if (all) {
|
||||
parsersToGenerate = Object.keys(parserDefinitions);
|
||||
}
|
||||
if (invalid.length) {
|
||||
console.log("No parser config found for: '" + invalid.join("', '") + "'");
|
||||
console.log('\nPossible options are:\n ' +
|
||||
['all'].concat(Object.keys(parserDefinitions)).join('\n ') +
|
||||
'\n');
|
||||
return;
|
||||
}
|
||||
const parserCount = parsersToGenerate.length;
|
||||
let idx = 0;
|
||||
/**
|
||||
* 执行编译
|
||||
*/
|
||||
const generateRecursive = () => {
|
||||
idx++;
|
||||
if (parsersToGenerate.length) {
|
||||
const parserName = parsersToGenerate.pop();
|
||||
if (parserCount > 1) {
|
||||
console.log("Generating '" + parserName + "' (" + idx + '/' + parserCount + ')...');
|
||||
}
|
||||
else {
|
||||
console.log("Generating '" + parserName + "'...");
|
||||
}
|
||||
generateParser(parserName)
|
||||
.then(generateRecursive)
|
||||
.catch(error => {
|
||||
console.log(error);
|
||||
console.log('FAIL!');
|
||||
});
|
||||
}
|
||||
else {
|
||||
const autocompParsers = [];
|
||||
const syntaxParsers = [];
|
||||
console.log('Updating sqlParserRepository.js...');
|
||||
Object.keys(parserDefinitions).forEach(key => {
|
||||
if (parserDefinitions[key].sqlParser === 'AUTOCOMPLETE') {
|
||||
autocompParsers.push(AUTOCOMPLETE_PARSER_IMPORT_TEMPLATE.replace(/KEY/g, key.replace('AutocompleteParser', '')));
|
||||
}
|
||||
else if (parserDefinitions[key].sqlParser === 'SYNTAX') {
|
||||
syntaxParsers.push(SYNTAX_PARSER_IMPORT_TEMPLATE.replace(/KEY/g, key.replace('SyntaxParser', '')));
|
||||
}
|
||||
});
|
||||
readFile(SQL_PARSER_REPOSITORY_PATH).then(contents => {
|
||||
contents = contents.replace(/const SYNTAX_MODULES = [^}]+}/, 'const SYNTAX_MODULES = {\n' + syntaxParsers.sort().join(',\n') + '\n}');
|
||||
contents = contents.replace(/const AUTOCOMPLETE_MODULES = [^}]+}/, 'const AUTOCOMPLETE_MODULES = {\n' + autocompParsers.sort().join(',\n') + '\n}');
|
||||
writeFile(SQL_PARSER_REPOSITORY_PATH, contents).then(() => {
|
||||
console.log('Done!\n');
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
/**
|
||||
* 集中精力办大事
|
||||
*/
|
||||
generateRecursive();
|
||||
});
|
||||
});
|
||||
/* eslint-enable no-restricted-syntax */
|
@ -1,118 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
function replaceStrFormIndexArr(str, replaceStr, indexArr) {
|
||||
let arr = [];
|
||||
let result = "";
|
||||
let index = 0;
|
||||
if (!indexArr || indexArr.length < 1) {
|
||||
return str;
|
||||
}
|
||||
for (let i = 0; i < indexArr.length; i++) {
|
||||
let indexItem = indexArr[i];
|
||||
let begin = indexItem.begin;
|
||||
result = result + str.substring(index, begin) + replaceStr;
|
||||
index = indexItem.end + 1;
|
||||
if (i == indexArr.length - 1) {
|
||||
result = result + str.substring(index);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
exports.replaceStrFormIndexArr = replaceStrFormIndexArr;
|
||||
function splitSql(sql) {
|
||||
let haveEnd = true;
|
||||
if (!sql.endsWith(';')) {
|
||||
sql += ';';
|
||||
haveEnd = false;
|
||||
}
|
||||
function pushSql(parser, sql) {
|
||||
if (!haveEnd && parser.index == sql.length - 1) {
|
||||
parser.sqls.push(parser.index - 1);
|
||||
parser.queue = '';
|
||||
}
|
||||
else {
|
||||
parser.sqls.push(parser.index);
|
||||
parser.queue = '';
|
||||
}
|
||||
}
|
||||
// 处理引号
|
||||
function quoteToken(parser, sql) {
|
||||
let queue = parser.queue;
|
||||
let endsWith = queue[queue.length - 1];
|
||||
if (endsWith == '\'' || endsWith == '"') {
|
||||
let nextToken = sql.indexOf(endsWith, parser.index + 1);
|
||||
if (nextToken != -1) {
|
||||
parser.index = nextToken;
|
||||
parser.queue = '';
|
||||
}
|
||||
else {
|
||||
parser.index = sql.length - 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
// 处理单行注释
|
||||
function singleLineCommentToken(parser, sql) {
|
||||
let queue = parser.queue;
|
||||
if (queue.endsWith('--')) {
|
||||
let nextToken = sql.indexOf('\n', parser.index + 1);
|
||||
if (nextToken != -1) {
|
||||
parser.index = nextToken;
|
||||
queue = '';
|
||||
}
|
||||
else {
|
||||
parser.index = sql.length - 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
// 处理多行注释
|
||||
function multipleLineCommentToken(parser, sql) {
|
||||
let queue = parser.queue;
|
||||
if (queue.endsWith('/*')) {
|
||||
let nextToken = sql.indexOf('*/', parser.index + 1);
|
||||
if (nextToken != -1) {
|
||||
parser.index = nextToken + 1;
|
||||
parser.queue = '';
|
||||
}
|
||||
else {
|
||||
parser.index = sql.length - 1;
|
||||
parser.queue = '';
|
||||
}
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
function splitToken(parser, sql) {
|
||||
let queue = parser.queue;
|
||||
if (queue.endsWith(';')) {
|
||||
pushSql(parser, sql);
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
let parser = {
|
||||
index: 0,
|
||||
queue: '',
|
||||
sqls: []
|
||||
};
|
||||
for (parser.index = 0; parser.index < sql.length; parser.index++) {
|
||||
let char = sql[parser.index];
|
||||
parser.queue += char;
|
||||
let tokenFuncs = [quoteToken, singleLineCommentToken, multipleLineCommentToken, splitToken];
|
||||
for (let i = 0; i < tokenFuncs.length; i++) {
|
||||
tokenFuncs[i](parser, sql);
|
||||
}
|
||||
if (parser.index == sql.length - 1 && parser.queue) {
|
||||
pushSql(parser, sql);
|
||||
}
|
||||
}
|
||||
return parser.sqls;
|
||||
}
|
||||
exports.splitSql = splitSql;
|
33
package.json
33
package.json
@ -1,31 +1,38 @@
|
||||
{
|
||||
"name": "dt-sql-parser",
|
||||
"version": "3.0.5",
|
||||
"description": "sql,hive,parser ",
|
||||
"version": "4.0.0-beta",
|
||||
"description": "There are some sql parsers in javascript and generated by antlr4",
|
||||
"keywords": [
|
||||
"hive",
|
||||
"hql",
|
||||
"sql",
|
||||
"parser"
|
||||
"parser",
|
||||
"monaco-editor",
|
||||
"hive",
|
||||
"spark",
|
||||
"flink",
|
||||
"impala",
|
||||
"bigdata"
|
||||
],
|
||||
"main": "lib/index.js",
|
||||
"main": "dist/index.js",
|
||||
"scripts": {
|
||||
"build:parse": "pegjs -o core/astParser.js peg/nquery.pegjs ",
|
||||
"build:filter": "pegjs -o core/comment.js peg/comment.pegjs ",
|
||||
"build:syntax": "node ./src/scripts/generateParsers.js impala",
|
||||
"build": "npm test && rm -rf lib && tsc",
|
||||
"antlr4": "node build/antlr4.js",
|
||||
"build": "rm -rf dist && tsc",
|
||||
"eslint": "eslint ./src/**/*.ts",
|
||||
"check-types": "tsc --skipLibCheck",
|
||||
"test": "jest"
|
||||
},
|
||||
"author": "xiaokang",
|
||||
"author": "dt-insight-front",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"@types/jest": "^24.0.13",
|
||||
"@typescript-eslint/eslint-plugin": "^3.10.1",
|
||||
"@typescript-eslint/parser": "^3.10.1",
|
||||
"eslint": "^7.7.0",
|
||||
"eslint-config-google": "^0.14.0",
|
||||
"jest": "^24.8.0",
|
||||
"pegjs": "^0.10.0",
|
||||
"ts-jest": "^24.1.0",
|
||||
"typescript": "^3.6.3"
|
||||
},
|
||||
"git repository": "https://github.com/HSunboy/dt-sql-parser",
|
||||
"git repository": "https://github.com/DTStack/dt-sql-parser",
|
||||
"dependencies": {
|
||||
"@types/antlr4": "4.7.0",
|
||||
"antlr4": "4.7.2"
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@ -1,662 +0,0 @@
|
||||
/*
|
||||
* Generated by PEG.js 0.10.0.
|
||||
*
|
||||
* http://pegjs.org/
|
||||
*/
|
||||
(function(root, factory) {
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define([], factory);
|
||||
} else if (typeof module === "object" && module.exports) {
|
||||
module.exports = factory();
|
||||
}
|
||||
})(this, function() {
|
||||
"use strict";
|
||||
|
||||
function peg$subclass(child, parent) {
|
||||
function ctor() { this.constructor = child; }
|
||||
ctor.prototype = parent.prototype;
|
||||
child.prototype = new ctor();
|
||||
}
|
||||
|
||||
function peg$SyntaxError(message, expected, found, location) {
|
||||
this.message = message;
|
||||
this.expected = expected;
|
||||
this.found = found;
|
||||
this.location = location;
|
||||
this.name = "SyntaxError";
|
||||
|
||||
if (typeof Error.captureStackTrace === "function") {
|
||||
Error.captureStackTrace(this, peg$SyntaxError);
|
||||
}
|
||||
}
|
||||
|
||||
peg$subclass(peg$SyntaxError, Error);
|
||||
|
||||
peg$SyntaxError.buildMessage = function(expected, found) {
|
||||
var DESCRIBE_EXPECTATION_FNS = {
|
||||
literal: function(expectation) {
|
||||
return "\"" + literalEscape(expectation.text) + "\"";
|
||||
},
|
||||
|
||||
"class": function(expectation) {
|
||||
var escapedParts = "",
|
||||
i;
|
||||
|
||||
for (i = 0; i < expectation.parts.length; i++) {
|
||||
escapedParts += expectation.parts[i] instanceof Array
|
||||
? classEscape(expectation.parts[i][0]) + "-" + classEscape(expectation.parts[i][1])
|
||||
: classEscape(expectation.parts[i]);
|
||||
}
|
||||
|
||||
return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]";
|
||||
},
|
||||
|
||||
any: function(expectation) {
|
||||
return "any character";
|
||||
},
|
||||
|
||||
end: function(expectation) {
|
||||
return "end of input";
|
||||
},
|
||||
|
||||
other: function(expectation) {
|
||||
return expectation.description;
|
||||
}
|
||||
};
|
||||
|
||||
function hex(ch) {
|
||||
return ch.charCodeAt(0).toString(16).toUpperCase();
|
||||
}
|
||||
|
||||
function literalEscape(s) {
|
||||
return s
|
||||
.replace(/\\/g, '\\\\')
|
||||
.replace(/"/g, '\\"')
|
||||
.replace(/\0/g, '\\0')
|
||||
.replace(/\t/g, '\\t')
|
||||
.replace(/\n/g, '\\n')
|
||||
.replace(/\r/g, '\\r')
|
||||
.replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); })
|
||||
.replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); });
|
||||
}
|
||||
|
||||
function classEscape(s) {
|
||||
return s
|
||||
.replace(/\\/g, '\\\\')
|
||||
.replace(/\]/g, '\\]')
|
||||
.replace(/\^/g, '\\^')
|
||||
.replace(/-/g, '\\-')
|
||||
.replace(/\0/g, '\\0')
|
||||
.replace(/\t/g, '\\t')
|
||||
.replace(/\n/g, '\\n')
|
||||
.replace(/\r/g, '\\r')
|
||||
.replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); })
|
||||
.replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); });
|
||||
}
|
||||
|
||||
function describeExpectation(expectation) {
|
||||
return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
|
||||
}
|
||||
|
||||
function describeExpected(expected) {
|
||||
var descriptions = new Array(expected.length),
|
||||
i, j;
|
||||
|
||||
for (i = 0; i < expected.length; i++) {
|
||||
descriptions[i] = describeExpectation(expected[i]);
|
||||
}
|
||||
|
||||
descriptions.sort();
|
||||
|
||||
if (descriptions.length > 0) {
|
||||
for (i = 1, j = 1; i < descriptions.length; i++) {
|
||||
if (descriptions[i - 1] !== descriptions[i]) {
|
||||
descriptions[j] = descriptions[i];
|
||||
j++;
|
||||
}
|
||||
}
|
||||
descriptions.length = j;
|
||||
}
|
||||
|
||||
switch (descriptions.length) {
|
||||
case 1:
|
||||
return descriptions[0];
|
||||
|
||||
case 2:
|
||||
return descriptions[0] + " or " + descriptions[1];
|
||||
|
||||
default:
|
||||
return descriptions.slice(0, -1).join(", ")
|
||||
+ ", or "
|
||||
+ descriptions[descriptions.length - 1];
|
||||
}
|
||||
}
|
||||
|
||||
function describeFound(found) {
|
||||
return found ? "\"" + literalEscape(found) + "\"" : "end of input";
|
||||
}
|
||||
|
||||
return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
|
||||
};
|
||||
|
||||
function peg$parse(input, options) {
|
||||
options = options !== void 0 ? options : {};
|
||||
|
||||
var peg$FAILED = {},
|
||||
|
||||
peg$startRuleIndices = { start: 0 },
|
||||
peg$startRuleIndex = 0,
|
||||
|
||||
peg$consts = [
|
||||
function(union_stmt) {
|
||||
return {lines,text:union_stmt};
|
||||
},
|
||||
peg$anyExpectation(),
|
||||
function(word) {return word},
|
||||
function(words, comment) {return ''},
|
||||
function(words, quote) {return quote},
|
||||
";",
|
||||
peg$literalExpectation(";", false),
|
||||
function(words) {isSplit=true;return ";"},
|
||||
function(words, stmt) {
|
||||
const text=words.join("")+stmt;
|
||||
let index=Math.max(lines.length-1,0);
|
||||
lines[index]=(lines[index]||'')+text;
|
||||
if(isSplit){
|
||||
isSplit=false;
|
||||
lines.push('');
|
||||
}
|
||||
return text;
|
||||
},
|
||||
function(stmt, other) {
|
||||
const text=stmt.join("")+other.join("")
|
||||
let index=Math.max(lines.length-1,0);
|
||||
lines[index]=lines[index]+other.join("");
|
||||
return text;
|
||||
},
|
||||
function(comment) {
|
||||
return comment;
|
||||
},
|
||||
/^[^\r\n]/,
|
||||
peg$classExpectation(["\r", "\n"], true, false),
|
||||
function(start, words) {
|
||||
return start+words.join("")
|
||||
},
|
||||
"*/",
|
||||
peg$literalExpectation("*/", false),
|
||||
function(start, word) {return word },
|
||||
function(start, words, end) {return start+words.join("")+end },
|
||||
"\"",
|
||||
peg$literalExpectation("\"", false),
|
||||
/^[^"]/,
|
||||
peg$classExpectation(["\""], true, false),
|
||||
function(start, words, end) {return start+words.join("")+end;},
|
||||
"'",
|
||||
peg$literalExpectation("'", false),
|
||||
/^[^']/,
|
||||
peg$classExpectation(["'"], true, false),
|
||||
"--",
|
||||
peg$literalExpectation("--", false),
|
||||
/^[\r\n]/,
|
||||
peg$classExpectation(["\r", "\n"], false, false),
|
||||
"/*",
|
||||
peg$literalExpectation("/*", false),
|
||||
/^[ \t\r\n]/,
|
||||
peg$classExpectation([" ", "\t", "\r", "\n"], false, false)
|
||||
],
|
||||
|
||||
peg$bytecode = [
|
||||
peg$decode("%;!/' 8!: !! )"),
|
||||
peg$decode("%$%$%%<;&=.##&&!&'#/6#1\"\"5!7!/($8\":\"\"! )(\"'#&'#0L*%%<;&=.##&&!&'#/6#1\"\"5!7!/($8\":\"\"! )(\"'#&'#&/j#%;\"/( 8!:#!\"\" ).H &%;%/( 8!:$!\"\" ).5 &%2%\"\"6%7&/' 8!:'!!\")/)$8\":(\"\"! )(\"'#&'#0\xCD*%$%%<;&=.##&&!&'#/6#1\"\"5!7!/($8\":\"\"! )(\"'#&'#0L*%%<;&=.##&&!&'#/6#1\"\"5!7!/($8\":\"\"! )(\"'#&'#&/j#%;\"/( 8!:#!\"\" ).H &%;%/( 8!:$!\"\" ).5 &%2%\"\"6%7&/' 8!:'!!\")/)$8\":(\"\"! )(\"'#&'#&/C#$1\"\"5!7!0(*1\"\"5!7!&/)$8\":)\"\"! )(\"'#&'#"),
|
||||
peg$decode("%;$.# &;#/' 8!:*!! )"),
|
||||
peg$decode("%;'/E#$4+\"\"5!7,0)*4+\"\"5!7,&/)$8\":-\"\"! )(\"'#&'#"),
|
||||
peg$decode("%;)/\xA3#$%%<2.\"\"6.7/=.##&&!&'#/7#1\"\"5!7!/)$8\":0\"\"$ )(\"'#&'#0S*%%<2.\"\"6.7/=.##&&!&'#/7#1\"\"5!7!/)$8\":0\"\"$ )(\"'#&'#&/3$;*/*$8#:1##\"! )(#'#(\"'#&'#"),
|
||||
peg$decode("%22\"\"6273/U#$44\"\"5!750)*44\"\"5!75&/9$22\"\"6273/*$8#:6##\"! )(#'#(\"'#&'#.e &%27\"\"6778/U#$49\"\"5!7:0)*49\"\"5!7:&/9$27\"\"6778/*$8#:6##\"! )(#'#(\"'#&'#"),
|
||||
peg$decode(";'.G &;).A &22\"\"6273.5 &27\"\"6778.) &2%\"\"6%7&"),
|
||||
peg$decode("2;\"\"6;7<"),
|
||||
peg$decode("4=\"\"5!7>"),
|
||||
peg$decode("2?\"\"6?7@"),
|
||||
peg$decode("2.\"\"6.7/"),
|
||||
peg$decode("$;,0#*;,&"),
|
||||
peg$decode("4A\"\"5!7B")
|
||||
],
|
||||
|
||||
peg$currPos = 0,
|
||||
peg$savedPos = 0,
|
||||
peg$posDetailsCache = [{ line: 1, column: 1 }],
|
||||
peg$maxFailPos = 0,
|
||||
peg$maxFailExpected = [],
|
||||
peg$silentFails = 0,
|
||||
|
||||
peg$result;
|
||||
|
||||
if ("startRule" in options) {
|
||||
if (!(options.startRule in peg$startRuleIndices)) {
|
||||
throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
|
||||
}
|
||||
|
||||
peg$startRuleIndex = peg$startRuleIndices[options.startRule];
|
||||
}
|
||||
|
||||
function text() {
|
||||
return input.substring(peg$savedPos, peg$currPos);
|
||||
}
|
||||
|
||||
function location() {
|
||||
return peg$computeLocation(peg$savedPos, peg$currPos);
|
||||
}
|
||||
|
||||
function expected(description, location) {
|
||||
location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos)
|
||||
|
||||
throw peg$buildStructuredError(
|
||||
[peg$otherExpectation(description)],
|
||||
input.substring(peg$savedPos, peg$currPos),
|
||||
location
|
||||
);
|
||||
}
|
||||
|
||||
function error(message, location) {
|
||||
location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos)
|
||||
|
||||
throw peg$buildSimpleError(message, location);
|
||||
}
|
||||
|
||||
function peg$literalExpectation(text, ignoreCase) {
|
||||
return { type: "literal", text: text, ignoreCase: ignoreCase };
|
||||
}
|
||||
|
||||
function peg$classExpectation(parts, inverted, ignoreCase) {
|
||||
return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase };
|
||||
}
|
||||
|
||||
function peg$anyExpectation() {
|
||||
return { type: "any" };
|
||||
}
|
||||
|
||||
function peg$endExpectation() {
|
||||
return { type: "end" };
|
||||
}
|
||||
|
||||
function peg$otherExpectation(description) {
|
||||
return { type: "other", description: description };
|
||||
}
|
||||
|
||||
function peg$computePosDetails(pos) {
|
||||
var details = peg$posDetailsCache[pos], p;
|
||||
|
||||
if (details) {
|
||||
return details;
|
||||
} else {
|
||||
p = pos - 1;
|
||||
while (!peg$posDetailsCache[p]) {
|
||||
p--;
|
||||
}
|
||||
|
||||
details = peg$posDetailsCache[p];
|
||||
details = {
|
||||
line: details.line,
|
||||
column: details.column
|
||||
};
|
||||
|
||||
while (p < pos) {
|
||||
if (input.charCodeAt(p) === 10) {
|
||||
details.line++;
|
||||
details.column = 1;
|
||||
} else {
|
||||
details.column++;
|
||||
}
|
||||
|
||||
p++;
|
||||
}
|
||||
|
||||
peg$posDetailsCache[pos] = details;
|
||||
return details;
|
||||
}
|
||||
}
|
||||
|
||||
function peg$computeLocation(startPos, endPos) {
|
||||
var startPosDetails = peg$computePosDetails(startPos),
|
||||
endPosDetails = peg$computePosDetails(endPos);
|
||||
|
||||
return {
|
||||
start: {
|
||||
offset: startPos,
|
||||
line: startPosDetails.line,
|
||||
column: startPosDetails.column
|
||||
},
|
||||
end: {
|
||||
offset: endPos,
|
||||
line: endPosDetails.line,
|
||||
column: endPosDetails.column
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function peg$fail(expected) {
|
||||
if (peg$currPos < peg$maxFailPos) { return; }
|
||||
|
||||
if (peg$currPos > peg$maxFailPos) {
|
||||
peg$maxFailPos = peg$currPos;
|
||||
peg$maxFailExpected = [];
|
||||
}
|
||||
|
||||
peg$maxFailExpected.push(expected);
|
||||
}
|
||||
|
||||
function peg$buildSimpleError(message, location) {
|
||||
return new peg$SyntaxError(message, null, null, location);
|
||||
}
|
||||
|
||||
function peg$buildStructuredError(expected, found, location) {
|
||||
return new peg$SyntaxError(
|
||||
peg$SyntaxError.buildMessage(expected, found),
|
||||
expected,
|
||||
found,
|
||||
location
|
||||
);
|
||||
}
|
||||
|
||||
function peg$decode(s) {
|
||||
var bc = new Array(s.length), i;
|
||||
|
||||
for (i = 0; i < s.length; i++) {
|
||||
bc[i] = s.charCodeAt(i) - 32;
|
||||
}
|
||||
|
||||
return bc;
|
||||
}
|
||||
|
||||
function peg$parseRule(index) {
|
||||
var bc = peg$bytecode[index],
|
||||
ip = 0,
|
||||
ips = [],
|
||||
end = bc.length,
|
||||
ends = [],
|
||||
stack = [],
|
||||
params, i;
|
||||
|
||||
while (true) {
|
||||
while (ip < end) {
|
||||
switch (bc[ip]) {
|
||||
case 0:
|
||||
stack.push(peg$consts[bc[ip + 1]]);
|
||||
ip += 2;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
stack.push(void 0);
|
||||
ip++;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
stack.push(null);
|
||||
ip++;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
stack.push(peg$FAILED);
|
||||
ip++;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
stack.push([]);
|
||||
ip++;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
stack.push(peg$currPos);
|
||||
ip++;
|
||||
break;
|
||||
|
||||
case 6:
|
||||
stack.pop();
|
||||
ip++;
|
||||
break;
|
||||
|
||||
case 7:
|
||||
peg$currPos = stack.pop();
|
||||
ip++;
|
||||
break;
|
||||
|
||||
case 8:
|
||||
stack.length -= bc[ip + 1];
|
||||
ip += 2;
|
||||
break;
|
||||
|
||||
case 9:
|
||||
stack.splice(-2, 1);
|
||||
ip++;
|
||||
break;
|
||||
|
||||
case 10:
|
||||
stack[stack.length - 2].push(stack.pop());
|
||||
ip++;
|
||||
break;
|
||||
|
||||
case 11:
|
||||
stack.push(stack.splice(stack.length - bc[ip + 1], bc[ip + 1]));
|
||||
ip += 2;
|
||||
break;
|
||||
|
||||
case 12:
|
||||
stack.push(input.substring(stack.pop(), peg$currPos));
|
||||
ip++;
|
||||
break;
|
||||
|
||||
case 13:
|
||||
ends.push(end);
|
||||
ips.push(ip + 3 + bc[ip + 1] + bc[ip + 2]);
|
||||
|
||||
if (stack[stack.length - 1]) {
|
||||
end = ip + 3 + bc[ip + 1];
|
||||
ip += 3;
|
||||
} else {
|
||||
end = ip + 3 + bc[ip + 1] + bc[ip + 2];
|
||||
ip += 3 + bc[ip + 1];
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 14:
|
||||
ends.push(end);
|
||||
ips.push(ip + 3 + bc[ip + 1] + bc[ip + 2]);
|
||||
|
||||
if (stack[stack.length - 1] === peg$FAILED) {
|
||||
end = ip + 3 + bc[ip + 1];
|
||||
ip += 3;
|
||||
} else {
|
||||
end = ip + 3 + bc[ip + 1] + bc[ip + 2];
|
||||
ip += 3 + bc[ip + 1];
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 15:
|
||||
ends.push(end);
|
||||
ips.push(ip + 3 + bc[ip + 1] + bc[ip + 2]);
|
||||
|
||||
if (stack[stack.length - 1] !== peg$FAILED) {
|
||||
end = ip + 3 + bc[ip + 1];
|
||||
ip += 3;
|
||||
} else {
|
||||
end = ip + 3 + bc[ip + 1] + bc[ip + 2];
|
||||
ip += 3 + bc[ip + 1];
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 16:
|
||||
if (stack[stack.length - 1] !== peg$FAILED) {
|
||||
ends.push(end);
|
||||
ips.push(ip);
|
||||
|
||||
end = ip + 2 + bc[ip + 1];
|
||||
ip += 2;
|
||||
} else {
|
||||
ip += 2 + bc[ip + 1];
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 17:
|
||||
ends.push(end);
|
||||
ips.push(ip + 3 + bc[ip + 1] + bc[ip + 2]);
|
||||
|
||||
if (input.length > peg$currPos) {
|
||||
end = ip + 3 + bc[ip + 1];
|
||||
ip += 3;
|
||||
} else {
|
||||
end = ip + 3 + bc[ip + 1] + bc[ip + 2];
|
||||
ip += 3 + bc[ip + 1];
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 18:
|
||||
ends.push(end);
|
||||
ips.push(ip + 4 + bc[ip + 2] + bc[ip + 3]);
|
||||
|
||||
if (input.substr(peg$currPos, peg$consts[bc[ip + 1]].length) === peg$consts[bc[ip + 1]]) {
|
||||
end = ip + 4 + bc[ip + 2];
|
||||
ip += 4;
|
||||
} else {
|
||||
end = ip + 4 + bc[ip + 2] + bc[ip + 3];
|
||||
ip += 4 + bc[ip + 2];
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 19:
|
||||
ends.push(end);
|
||||
ips.push(ip + 4 + bc[ip + 2] + bc[ip + 3]);
|
||||
|
||||
if (input.substr(peg$currPos, peg$consts[bc[ip + 1]].length).toLowerCase() === peg$consts[bc[ip + 1]]) {
|
||||
end = ip + 4 + bc[ip + 2];
|
||||
ip += 4;
|
||||
} else {
|
||||
end = ip + 4 + bc[ip + 2] + bc[ip + 3];
|
||||
ip += 4 + bc[ip + 2];
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 20:
|
||||
ends.push(end);
|
||||
ips.push(ip + 4 + bc[ip + 2] + bc[ip + 3]);
|
||||
|
||||
if (peg$consts[bc[ip + 1]].test(input.charAt(peg$currPos))) {
|
||||
end = ip + 4 + bc[ip + 2];
|
||||
ip += 4;
|
||||
} else {
|
||||
end = ip + 4 + bc[ip + 2] + bc[ip + 3];
|
||||
ip += 4 + bc[ip + 2];
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 21:
|
||||
stack.push(input.substr(peg$currPos, bc[ip + 1]));
|
||||
peg$currPos += bc[ip + 1];
|
||||
ip += 2;
|
||||
break;
|
||||
|
||||
case 22:
|
||||
stack.push(peg$consts[bc[ip + 1]]);
|
||||
peg$currPos += peg$consts[bc[ip + 1]].length;
|
||||
ip += 2;
|
||||
break;
|
||||
|
||||
case 23:
|
||||
stack.push(peg$FAILED);
|
||||
if (peg$silentFails === 0) {
|
||||
peg$fail(peg$consts[bc[ip + 1]]);
|
||||
}
|
||||
ip += 2;
|
||||
break;
|
||||
|
||||
case 24:
|
||||
peg$savedPos = stack[stack.length - 1 - bc[ip + 1]];
|
||||
ip += 2;
|
||||
break;
|
||||
|
||||
case 25:
|
||||
peg$savedPos = peg$currPos;
|
||||
ip++;
|
||||
break;
|
||||
|
||||
case 26:
|
||||
params = bc.slice(ip + 4, ip + 4 + bc[ip + 3]);
|
||||
for (i = 0; i < bc[ip + 3]; i++) {
|
||||
params[i] = stack[stack.length - 1 - params[i]];
|
||||
}
|
||||
|
||||
stack.splice(
|
||||
stack.length - bc[ip + 2],
|
||||
bc[ip + 2],
|
||||
peg$consts[bc[ip + 1]].apply(null, params)
|
||||
);
|
||||
|
||||
ip += 4 + bc[ip + 3];
|
||||
break;
|
||||
|
||||
case 27:
|
||||
stack.push(peg$parseRule(bc[ip + 1]));
|
||||
ip += 2;
|
||||
break;
|
||||
|
||||
case 28:
|
||||
peg$silentFails++;
|
||||
ip++;
|
||||
break;
|
||||
|
||||
case 29:
|
||||
peg$silentFails--;
|
||||
ip++;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Error("Invalid opcode: " + bc[ip] + ".");
|
||||
}
|
||||
}
|
||||
|
||||
if (ends.length > 0) {
|
||||
end = ends.pop();
|
||||
ip = ips.pop();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return stack[0];
|
||||
}
|
||||
|
||||
|
||||
let lines=[];
|
||||
let isSplit=false;
|
||||
|
||||
|
||||
peg$result = peg$parseRule(peg$startRuleIndex);
|
||||
|
||||
if (peg$result !== peg$FAILED && peg$currPos === input.length) {
|
||||
return peg$result;
|
||||
} else {
|
||||
if (peg$result !== peg$FAILED && peg$currPos < input.length) {
|
||||
peg$fail(peg$endExpectation());
|
||||
}
|
||||
|
||||
throw peg$buildStructuredError(
|
||||
peg$maxFailExpected,
|
||||
peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,
|
||||
peg$maxFailPos < input.length
|
||||
? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)
|
||||
: peg$computeLocation(peg$maxFailPos, peg$maxFailPos)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
SyntaxError: peg$SyntaxError,
|
||||
parse: peg$parse
|
||||
};
|
||||
});
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,74 +0,0 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* AUTOCOMPLETE_MODULES and SYNTAX_MODULES are generated, do not edit manually, see tools/jison/generateParsers.js
|
||||
*/
|
||||
const AUTOCOMPLETE_MODULES = {
|
||||
calcite: require("calcite/calciteAutocompleteParser"),
|
||||
druid: require("druid/druidAutocompleteParser"),
|
||||
elasticsearch: require("elasticsearch/elasticsearchAutocompleteParser"),
|
||||
flink: require("flink/flinkAutocompleteParser"),
|
||||
generic: require("generic/genericAutocompleteParser"),
|
||||
hive: require("hive/hiveAutocompleteParser"),
|
||||
impala: require("impala/impalaAutocompleteParser"),
|
||||
ksql: require("ksql/ksqlAutocompleteParser"),
|
||||
phoenix: require("phoenix/phoenixAutocompleteParser"),
|
||||
presto: require("presto/prestoAutocompleteParser")
|
||||
};
|
||||
const SYNTAX_MODULES = {
|
||||
calcite: require("calcite/calciteSyntaxParser"),
|
||||
druid: require("druid/druidSyntaxParser"),
|
||||
elasticsearch: require("elasticsearch/elasticsearchSyntaxParser"),
|
||||
flink: require("flink/flinkSyntaxParser"),
|
||||
generic: require("generic/genericSyntaxParser"),
|
||||
hive: require("hive/hiveSyntaxParser"),
|
||||
impala: require("impala/impalaSyntaxParser"),
|
||||
ksql: require("ksql/ksqlSyntaxParser"),
|
||||
phoenix: require("phoenix/phoenixSyntaxParser"),
|
||||
presto: require("presto/prestoSyntaxParser")
|
||||
};
|
||||
/* eslint-enable */
|
||||
|
||||
class SqlParserRepository {
|
||||
constructor() {
|
||||
this.modulePromises = {};
|
||||
}
|
||||
|
||||
async getParser(sourceType, parserType) {
|
||||
if (!this.modulePromises[sourceType + parserType]) {
|
||||
const modules = parserType === 'Autocomplete' ? AUTOCOMPLETE_MODULES : SYNTAX_MODULES;
|
||||
this.modulePromises[sourceType + parserType] = new Promise((resolve, reject) => {
|
||||
const targetModule = modules[sourceType] || modules.generic;
|
||||
resolve(targetModule);
|
||||
});
|
||||
}
|
||||
return this.modulePromises[sourceType + parserType];
|
||||
}
|
||||
|
||||
async getAutocompleter(sourceType) {
|
||||
return this.getParser(sourceType, 'Autocomplete');
|
||||
}
|
||||
|
||||
async getSyntaxParser(sourceType) {
|
||||
return this.getParser(sourceType, 'Syntax');
|
||||
}
|
||||
}
|
||||
|
||||
const sqlParserRepository = new SqlParserRepository();
|
||||
|
||||
export default sqlParserRepository;
|
@ -1,77 +0,0 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/**
|
||||
* Calculates the Optimal String Alignment distance between two strings. Returns 0 when the strings are equal and the
|
||||
* distance when not, distances is less than or equal to the length of the longest string.
|
||||
*
|
||||
* @param strA
|
||||
* @param strB
|
||||
* @param [ignoreCase]
|
||||
* @returns {number} The similarity
|
||||
*/
|
||||
const stringDistance = function(strA, strB, ignoreCase) {
|
||||
if (ignoreCase) {
|
||||
strA = strA.toLowerCase();
|
||||
strB = strB.toLowerCase();
|
||||
}
|
||||
|
||||
// TODO: Consider other algorithms for performance
|
||||
const strALength = strA.length;
|
||||
const strBLength = strB.length;
|
||||
if (strALength === 0) {
|
||||
return strBLength;
|
||||
}
|
||||
if (strBLength === 0) {
|
||||
return strALength;
|
||||
}
|
||||
|
||||
const distances = new Array(strALength);
|
||||
|
||||
let cost, deletion, insertion, substitution, transposition;
|
||||
for (let i = 0; i <= strALength; i++) {
|
||||
distances[i] = new Array(strBLength);
|
||||
distances[i][0] = i;
|
||||
for (let j = 1; j <= strBLength; j++) {
|
||||
if (!i) {
|
||||
distances[0][j] = j;
|
||||
} else {
|
||||
cost = strA[i - 1] === strB[j - 1] ? 0 : 1;
|
||||
deletion = distances[i - 1][j] + 1;
|
||||
insertion = distances[i][j - 1] + 1;
|
||||
substitution = distances[i - 1][j - 1] + cost;
|
||||
if (deletion <= insertion && deletion <= substitution) {
|
||||
distances[i][j] = deletion;
|
||||
} else if (insertion <= deletion && insertion <= substitution) {
|
||||
distances[i][j] = insertion;
|
||||
} else {
|
||||
distances[i][j] = substitution;
|
||||
}
|
||||
|
||||
if (i > 1 && j > 1 && strA[i] === strB[j - 1] && strA[i - 1] === strB[j]) {
|
||||
transposition = distances[i - 2][j - 2] + cost;
|
||||
if (transposition < distances[i][j]) {
|
||||
distances[i][j] = transposition;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return distances[strALength][strBLength];
|
||||
};
|
||||
|
||||
export default stringDistance;
|
32
src/core/sqlAutoCompleteParser.d.ts
vendored
32
src/core/sqlAutoCompleteParser.d.ts
vendored
@ -1,32 +0,0 @@
|
||||
interface Location {
|
||||
first_column: number,
|
||||
first_line: number,
|
||||
last_column: number,
|
||||
last_line: number
|
||||
}
|
||||
declare enum sqlType {
|
||||
Hive = 'hive',
|
||||
None = 'sql',
|
||||
Impala = 'impala'
|
||||
}
|
||||
interface Locations {
|
||||
// 语句类型
|
||||
type: string;
|
||||
// 语法是否缺失
|
||||
missing?: Boolean;
|
||||
// 语句位置
|
||||
location: Location;
|
||||
}
|
||||
|
||||
interface SuggestKeyword {
|
||||
value: string;
|
||||
weight: number;
|
||||
}
|
||||
interface CompleteParser {
|
||||
parseSql: (preSql: string, sufSql: string, type: sqlType, d: Boolean) => CompleteResult
|
||||
}
|
||||
export interface CompleteResult {
|
||||
locations: Locations[];
|
||||
suggestKeywords: SuggestKeyword[];
|
||||
}
|
||||
export const parser:CompleteParser;
|
29
src/core/sqlSyntaxParser.d.ts
vendored
29
src/core/sqlSyntaxParser.d.ts
vendored
@ -1,29 +0,0 @@
|
||||
import { Locations, SuggestKeyword } from "./sqlAutoCompleteParser";
|
||||
declare enum sqlType {
|
||||
Hive = 'hive',
|
||||
None = 'sql',
|
||||
Impala = 'impala'
|
||||
}
|
||||
interface SyntaxParser {
|
||||
parseSyntax: (preSql: string, sufSql: string, type: sqlType, d: Boolean) => SyntaxResult | false
|
||||
}
|
||||
|
||||
interface ExpectedWord {
|
||||
text: string;
|
||||
distance: number;
|
||||
}
|
||||
|
||||
interface ErrorLoc {
|
||||
first_column: number;
|
||||
first_line: number;
|
||||
last_column: number;
|
||||
last_line: number;
|
||||
}
|
||||
export interface SyntaxResult {
|
||||
text: string;
|
||||
expected: ExpectedWord[];
|
||||
incompleteStatement: Boolean;
|
||||
loc: ErrorLoc,
|
||||
token: string
|
||||
}
|
||||
export const parser: SyntaxParser;
|
332
src/grammar/flinksql/FlinkSqlLexer.g4
Normal file
332
src/grammar/flinksql/FlinkSqlLexer.g4
Normal file
@ -0,0 +1,332 @@
|
||||
lexer grammar FlinkSqlLexer;
|
||||
|
||||
// SKIP
|
||||
|
||||
SPACE: [ \t\r\n]+ -> channel(HIDDEN);
|
||||
COMMENT_INPUT: '/*' .*? '*/' -> channel(HIDDEN);
|
||||
LINE_COMMENT: (
|
||||
('-- ' | '#') ~[\r\n]* ('\r'? '\n' | EOF)
|
||||
| '--' ('\r'? '\n' | EOF)
|
||||
) -> channel(HIDDEN);
|
||||
|
||||
|
||||
// Common Keywords
|
||||
|
||||
SELECT: 'SELECT';
|
||||
FROM: 'FROM';
|
||||
ADD: 'ADD';
|
||||
AS: 'AS';
|
||||
ALL: 'ALL';
|
||||
ANY: 'ANY';
|
||||
DISTINCT: 'DISTINCT';
|
||||
WHERE: 'WHERE';
|
||||
GROUP: 'GROUP';
|
||||
BY: 'BY';
|
||||
GROUPING: 'GROUPING';
|
||||
SETS: 'SETS';
|
||||
CUBE: 'CUBE';
|
||||
ROLLUP: 'ROLLUP';
|
||||
ORDER: 'ORDER';
|
||||
HAVING: 'HAVING';
|
||||
LIMIT: 'LIMIT';
|
||||
AT: 'AT';
|
||||
OR: 'OR';
|
||||
AND: 'AND';
|
||||
IN: 'IN';
|
||||
NOT: 'NOT';
|
||||
NO: 'NO';
|
||||
EXISTS: 'EXISTS';
|
||||
BETWEEN: 'BETWEEN';
|
||||
LIKE: 'LIKE';
|
||||
RLIKE: 'RLIKE';
|
||||
IS: 'IS';
|
||||
TRUE: 'TRUE';
|
||||
FALSE: 'FALSE';
|
||||
NULLS: 'NULLS';
|
||||
ASC: 'ASC';
|
||||
DESC: 'DESC';
|
||||
FOR: 'FOR';
|
||||
INTERVAL: 'INTERVAL';
|
||||
CASE: 'CASE';
|
||||
WHEN: 'WHEN';
|
||||
THEN: 'THEN';
|
||||
ELSE: 'ELSE';
|
||||
END: 'END';
|
||||
JOIN: 'JOIN';
|
||||
CROSS: 'CROSS';
|
||||
OUTER: 'OUTER';
|
||||
INNER: 'INNER';
|
||||
LEFT: 'LEFT';
|
||||
SEMI: 'SEMI';
|
||||
RIGHT: 'RIGHT';
|
||||
FULL: 'FULL';
|
||||
NATURAL: 'NATURAL';
|
||||
ON: 'ON';
|
||||
PIVOT: 'PIVOT';
|
||||
LATERAL: 'LATERAL';
|
||||
WINDOW: 'WINDOW';
|
||||
OVER: 'OVER';
|
||||
PARTITION: 'PARTITION';
|
||||
RANGE: 'RANGE';
|
||||
ROWS: 'ROWS';
|
||||
UNBOUNDED: 'UNBOUNDED';
|
||||
PRECEDING: 'PRECEDING';
|
||||
FOLLOWING: 'FOLLOWING';
|
||||
CURRENT: 'CURRENT';
|
||||
FIRST: 'FIRST';
|
||||
AFTER: 'AFTER';
|
||||
LAST: 'LAST';
|
||||
WITH: 'WITH';
|
||||
VALUES: 'VALUES';
|
||||
CREATE: 'CREATE';
|
||||
TABLE: 'TABLE';
|
||||
DIRECTORY: 'DIRECTORY';
|
||||
VIEW: 'VIEW';
|
||||
REPLACE: 'REPLACE';
|
||||
INSERT: 'INSERT';
|
||||
DELETE: 'DELETE';
|
||||
INTO: 'INTO';
|
||||
DESCRIBE: 'DESCRIBE';
|
||||
EXPLAIN: 'EXPLAIN';
|
||||
FORMAT: 'FORMAT';
|
||||
LOGICAL: 'LOGICAL';
|
||||
CODEGEN: 'CODEGEN';
|
||||
COST: 'COST';
|
||||
CAST: 'CAST';
|
||||
SHOW: 'SHOW';
|
||||
TABLES: 'TABLES';
|
||||
COLUMNS: 'COLUMNS';
|
||||
COLUMN: 'COLUMN';
|
||||
USE: 'USE';
|
||||
PARTITIONS: 'PARTITIONS';
|
||||
FUNCTIONS: 'FUNCTIONS';
|
||||
DROP: 'DROP';
|
||||
UNION: 'UNION';
|
||||
EXCEPT: 'EXCEPT';
|
||||
SETMINUS: 'SETMINUS';
|
||||
INTERSECT: 'INTERSECT';
|
||||
TO: 'TO';
|
||||
TABLESAMPLE: 'TABLESAMPLE';
|
||||
STRATIFY: 'STRATIFY';
|
||||
ALTER: 'ALTER';
|
||||
RENAME: 'RENAME';
|
||||
STRUCT: 'STRUCT';
|
||||
COMMENT: 'COMMENT';
|
||||
SET: 'SET';
|
||||
RESET: 'RESET';
|
||||
DATA: 'DATA';
|
||||
START: 'START';
|
||||
TRANSACTION: 'TRANSACTION';
|
||||
COMMIT: 'COMMIT';
|
||||
ROLLBACK: 'ROLLBACK';
|
||||
MACRO: 'MACRO';
|
||||
IGNORE: 'IGNORE';
|
||||
BOTH: 'BOTH';
|
||||
LEADING: 'LEADING';
|
||||
TRAILING: 'TRAILING';
|
||||
IF: 'IF';
|
||||
POSITION: 'POSITION';
|
||||
EXTRACT: 'EXTRACT';
|
||||
MINUS: 'MINUS';
|
||||
DIV: 'DIV';
|
||||
PERCENTLIT: 'PERCENTLIT';
|
||||
BUCKET: 'BUCKET';
|
||||
OUT: 'OUT';
|
||||
OF: 'OF';
|
||||
SORT: 'SORT';
|
||||
CLUSTER: 'CLUSTER';
|
||||
DISTRIBUTE: 'DISTRIBUTE';
|
||||
OVERWRITE: 'OVERWRITE';
|
||||
TRANSFORM: 'TRANSFORM';
|
||||
REDUCE: 'REDUCE';
|
||||
USING: 'USING';
|
||||
SERDE: 'SERDE';
|
||||
SERDEPROPERTIES: 'SERDEPROPERTIES';
|
||||
RECORDREADER: 'RECORDREADER';
|
||||
RECORDWRITER: 'RECORDWRITER';
|
||||
DELIMITED: 'DELIMITED';
|
||||
FIELDS: 'FIELDS';
|
||||
TERMINATED: 'TERMINATED';
|
||||
COLLECTION: 'COLLECTION';
|
||||
ITEMS: 'ITEMS';
|
||||
KEYS: 'KEYS';
|
||||
ESCAPED: 'ESCAPED';
|
||||
LINES: 'LINES';
|
||||
SEPARATED: 'SEPARATED';
|
||||
FUNCTION: 'FUNCTION';
|
||||
EXTENDED: 'EXTENDED';
|
||||
REFRESH: 'REFRESH';
|
||||
CLEAR: 'CLEAR';
|
||||
CACHE: 'CACHE';
|
||||
UNCACHE: 'UNCACHE';
|
||||
LAZY: 'LAZY';
|
||||
FORMATTED: 'FORMATTED';
|
||||
GLOBAL: 'GLOBAL';
|
||||
TEMPORARY: 'TEMPORARY';
|
||||
OPTIONS: 'OPTIONS';
|
||||
UNSET: 'UNSET';
|
||||
TBLPROPERTIES: 'TBLPROPERTIES';
|
||||
DBPROPERTIES: 'DBPROPERTIES';
|
||||
BUCKETS: 'BUCKETS';
|
||||
SKEWED: 'SKEWED';
|
||||
STORED: 'STORED';
|
||||
DIRECTORIES: 'DIRECTORIES';
|
||||
LOCATION: 'LOCATION';
|
||||
EXCHANGE: 'EXCHANGE';
|
||||
ARCHIVE: 'ARCHIVE';
|
||||
UNARCHIVE: 'UNARCHIVE';
|
||||
FILEFORMAT: 'FILEFORMAT';
|
||||
TOUCH: 'TOUCH';
|
||||
COMPACT: 'COMPACT';
|
||||
CONCATENATE: 'CONCATENATE';
|
||||
CHANGE: 'CHANGE';
|
||||
CASCADE: 'CASCADE';
|
||||
CONSTRAINT: 'CONSTRAINT';
|
||||
RESTRICT: 'RESTRICT';
|
||||
CLUSTERED: 'CLUSTERED';
|
||||
SORTED: 'SORTED';
|
||||
PURGE: 'PURGE';
|
||||
INPUTFORMAT: 'INPUTFORMAT';
|
||||
OUTPUTFORMAT: 'OUTPUTFORMAT';
|
||||
DATABASE: 'DATABASE';
|
||||
DATABASES: 'DATABASES';
|
||||
DFS: 'DFS';
|
||||
TRUNCATE: 'TRUNCATE';
|
||||
ANALYZE: 'ANALYZE';
|
||||
COMPUTE: 'COMPUTE';
|
||||
LIST: 'LIST';
|
||||
STATISTICS: 'STATISTICS';
|
||||
PARTITIONED: 'PARTITIONED';
|
||||
EXTERNAL: 'EXTERNAL';
|
||||
DEFINED: 'DEFINED';
|
||||
REVOKE: 'REVOKE';
|
||||
GRANT: 'GRANT';
|
||||
LOCK: 'LOCK';
|
||||
UNLOCK: 'UNLOCK';
|
||||
MSCK: 'MSCK';
|
||||
REPAIR: 'REPAIR';
|
||||
RECOVER: 'RECOVER';
|
||||
EXPORT: 'EXPORT';
|
||||
IMPORT: 'IMPORT';
|
||||
LOAD: 'LOAD';
|
||||
ROLE: 'ROLE';
|
||||
ROLES: 'ROLES';
|
||||
COMPACTIONS: 'COMPACTIONS';
|
||||
PRINCIPALS: 'PRINCIPALS';
|
||||
TRANSACTIONS: 'TRANSACTIONS';
|
||||
INDEX: 'INDEX';
|
||||
INDEXES: 'INDEXES';
|
||||
LOCKS: 'LOCKS';
|
||||
OPTION: 'OPTION';
|
||||
ANTI: 'ANTI';
|
||||
LOCAL: 'LOCAL';
|
||||
INPATH: 'INPATH';
|
||||
WATERMARK: 'WATERMARK';
|
||||
UNNEST: 'UNNEST';
|
||||
MATCH: 'MATCH';
|
||||
NEXT: 'NEXT';
|
||||
WITHIN: 'WITHIN';
|
||||
WS: 'WS';
|
||||
SYSTEM: 'SYSTEM';
|
||||
INCLUDING: 'INCLUDING';
|
||||
EXCLUDING: 'EXCLUDING';
|
||||
CONSTRAINTS: 'CONSTRAINTS';
|
||||
GENERATED: 'GENERATED';
|
||||
CATALOG: 'CATALOG';
|
||||
LANGUAGE: 'LANGUAGE';
|
||||
CATALOGS: 'CATALOGS';
|
||||
VIEWS: 'VIEWS';
|
||||
PRIMARY: 'PRIMARY';
|
||||
KEY: 'KEY';
|
||||
PERIOD: 'PERIOD';
|
||||
SYSTEM_TIME: 'SYSTEM_TIME';
|
||||
|
||||
|
||||
// DATA TYPE Keywords
|
||||
|
||||
STRING: 'STRING';
|
||||
ARRAY: 'ARRAY';
|
||||
MAP: 'MAP';
|
||||
CHAR: 'CHAR';
|
||||
VARCHAR: 'VARCHAR';
|
||||
BINARY: 'BINARY';
|
||||
VARBINARY: 'VARBINARY';
|
||||
BYTES: 'BYTES';
|
||||
DECIMAL: 'DECIMAL';
|
||||
TINYINT: 'TINYINT';
|
||||
SMALLINT: 'SMALLINT';
|
||||
INT: 'INT';
|
||||
BIGINT: 'BIGINT';
|
||||
FLOAT: 'FLOAT';
|
||||
DOUBLE: 'DOUBLE';
|
||||
DATE: 'DATE';
|
||||
TIME: 'TIME';
|
||||
TIMESTAMP: 'TIMESTAMP';
|
||||
MULTISET: 'MULTISET';
|
||||
BOOLEAN: 'BOOLEAN';
|
||||
RAW: 'RAW';
|
||||
ROW: 'ROW';
|
||||
NULL: 'NULL';
|
||||
DATETIME: 'DATETIME'; // 数栈自定义类型
|
||||
|
||||
|
||||
|
||||
// Operators. Comparation
|
||||
|
||||
EQUAL_SYMBOL: '=';
|
||||
GREATER_SYMBOL: '>';
|
||||
LESS_SYMBOL: '<';
|
||||
EXCLAMATION_SYMBOL: '!';
|
||||
|
||||
|
||||
// Operators. Bit
|
||||
|
||||
BIT_NOT_OP: '~';
|
||||
BIT_OR_OP: '|';
|
||||
BIT_AND_OP: '&';
|
||||
BIT_XOR_OP: '^';
|
||||
|
||||
|
||||
// Constructors symbols
|
||||
|
||||
DOT: '.';
|
||||
LS_BRACKET: '[';
|
||||
RS_BRACKET: ']';
|
||||
LR_BRACKET: '(';
|
||||
RR_BRACKET: ')';
|
||||
COMMA: ',';
|
||||
SEMICOLON: ';';
|
||||
AT_SIGN: '@';
|
||||
SINGLE_QUOTE_SYMB: '\'';
|
||||
DOUBLE_QUOTE_SYMB: '"';
|
||||
REVERSE_QUOTE_SYMB: '`';
|
||||
COLON_SYMB: ':';
|
||||
ASTERISK_SIGN: '*';
|
||||
UNDERLINE_SIGN: '_';
|
||||
HYPNEN_SIGN: '-';
|
||||
ADD_SIGN: '+';
|
||||
PENCENT_SIGN: '%';
|
||||
DOUBLE_VERTICAL_SIGN: '||';
|
||||
DOUBLE_HYPNEN_SIGN: '--';
|
||||
SLASH_SIGN: '/';
|
||||
DOT_ID: '.' ID_LITERAL_FRAG;
|
||||
PLUS_DOT_ID: (':' | '.') PLUS_ID_LITERAL;
|
||||
STRING_LITERAL: DQUOTA_STRING | SQUOTA_STRING | BQUOTA_STRING;
|
||||
DIG_LITERAL: DEC_DIGIT+;
|
||||
REAL_LITERAL: (DEC_DIGIT+)? '.' DEC_DIGIT+
|
||||
| DEC_DIGIT+ '.' EXPONENT_NUM_PART
|
||||
| (DEC_DIGIT+)? '.' (DEC_DIGIT+ EXPONENT_NUM_PART)
|
||||
| DEC_DIGIT+ EXPONENT_NUM_PART;
|
||||
BIT_STRING: BIT_STRING_L;
|
||||
ID_LITERAL: ID_LITERAL_FRAG;
|
||||
PLUS_ID_LITERAL: PLUS_ID_LITERAL_FRAG;
|
||||
|
||||
fragment EXPONENT_NUM_PART: 'E' [-+]? DEC_DIGIT+;
|
||||
fragment ID_LITERAL_FRAG: [A-Z_0-9a-z]*?[A-Z_a-z]+?[A-Z_0-9a-z]*;
|
||||
fragment PLUS_ID_LITERAL_FRAG: [A-Z_0-9a-z*@#^$%&{}]*?[A-Z_a-z*@#^$%&{}]+?[A-Z_0-9a-z*@#^$%&{}]*;
|
||||
fragment DEC_DIGIT: [0-9];
|
||||
fragment DEC_LETTER: [A-Za-z];
|
||||
fragment DQUOTA_STRING: '"' ( '\\'. | '""' | ~('"'| '\\') )* '"';
|
||||
fragment SQUOTA_STRING: '\'' ('\\'. | '\'\'' | ~('\'' | '\\'))* '\'';
|
||||
fragment BIT_STRING_L: 'B' '\'' [01]+ '\'';
|
||||
fragment BQUOTA_STRING: '`' ( '\\'. | '``' | ~('`'|'\\'))* '`';
|
1044
src/grammar/flinksql/FlinkSqlParser.g4
Normal file
1044
src/grammar/flinksql/FlinkSqlParser.g4
Normal file
File diff suppressed because it is too large
Load Diff
3
src/grammar/generic/README.md
Normal file
3
src/grammar/generic/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# MySQL Grammar
|
||||
|
||||
[MySQL Grammar](https://github.com/mysql/mysql-workbench/tree/8.0/library/parsers/grammars)
|
1245
src/grammar/generic/SqlLexer.g4
Normal file
1245
src/grammar/generic/SqlLexer.g4
Normal file
File diff suppressed because it is too large
Load Diff
2588
src/grammar/generic/SqlParser.g4
Normal file
2588
src/grammar/generic/SqlParser.g4
Normal file
File diff suppressed because it is too large
Load Diff
1546
src/grammar/hive/HiveSql.g4
Normal file
1546
src/grammar/hive/HiveSql.g4
Normal file
File diff suppressed because it is too large
Load Diff
441
src/grammar/hive/HiveSqlLexer.g4
Normal file
441
src/grammar/hive/HiveSqlLexer.g4
Normal file
@ -0,0 +1,441 @@
|
||||
|
||||
lexer grammar HiveSqlLexer;
|
||||
|
||||
// Lexer rules
|
||||
T_ACTION : A C T I O N ;
|
||||
T_ADD2 : A D D ;
|
||||
T_ALL : A L L ;
|
||||
T_ALLOCATE : A L L O C A T E ;
|
||||
T_ALTER : A L T E R ;
|
||||
T_AND : A N D ;
|
||||
T_ANSI_NULLS : A N S I '_' N U L L S ;
|
||||
T_ANSI_PADDING : A N S I '_' P A D D I N G ;
|
||||
T_AS : A S ;
|
||||
T_ASC : A S C ;
|
||||
T_ASSOCIATE : A S S O C I A T E ;
|
||||
T_AT : A T ;
|
||||
T_AUTO_INCREMENT : A U T O '_' I N C R E M E N T ;
|
||||
T_AVG : A V G ;
|
||||
T_BATCHSIZE : B A T C H S I Z E ;
|
||||
T_BEGIN : B E G I N ;
|
||||
T_BETWEEN : B E T W E E N ;
|
||||
T_BIGINT : B I G I N T ;
|
||||
T_BINARY_DOUBLE : B I N A R Y '_' D O U B L E ;
|
||||
T_BINARY_FLOAT : B I N A R Y '_' F L O A T ;
|
||||
T_BINARY_INTEGER : B I N A R Y '_' I N T E G E R ;
|
||||
T_BIT : B I T ;
|
||||
T_BODY : B O D Y ;
|
||||
T_BREAK : B R E A K ;
|
||||
T_BY : B Y ;
|
||||
T_BYTE : B Y T E ;
|
||||
T_CALL : C A L L ;
|
||||
T_CALLER : C A L L E R ;
|
||||
T_CASCADE : C A S C A D E ;
|
||||
T_CASE : C A S E ;
|
||||
T_CASESPECIFIC : C A S E S P E C I F I C ;
|
||||
T_CAST : C A S T ;
|
||||
T_CHAR : C H A R ;
|
||||
T_CHARACTER : C H A R A C T E R ;
|
||||
T_CHARSET : C H A R S E T ;
|
||||
T_CLIENT : C L I E N T ;
|
||||
T_CLOSE : C L O S E ;
|
||||
T_CLUSTERED : C L U S T E R E D;
|
||||
T_CMP : C M P ;
|
||||
T_COLLECT : C O L L E C T ;
|
||||
T_COLLECTION : C O L L E C T I O N ;
|
||||
T_COLUMN : C O L U M N ;
|
||||
T_COMMENT : C O M M E N T;
|
||||
T_CONSTANT : C O N S T A N T ;
|
||||
T_COMMIT : C O M M I T ;
|
||||
T_COMPRESS : C O M P R E S S ;
|
||||
T_CONCAT : C O N C A T;
|
||||
T_CONDITION : C O N D I T I O N ;
|
||||
T_CONSTRAINT : C O N S T R A I N T ;
|
||||
T_CONTINUE : C O N T I N U E ;
|
||||
T_COPY : C O P Y ;
|
||||
T_COUNT : C O U N T ;
|
||||
T_COUNT_BIG : C O U N T '_' B I G;
|
||||
T_CREATE : C R E A T E ;
|
||||
T_CREATION : C R E A T I O N ;
|
||||
T_CREATOR : C R E A T O R ;
|
||||
T_CS : C S;
|
||||
T_CURRENT : C U R R E N T ;
|
||||
T_CURRENT_SCHEMA : C U R R E N T '_' S C H E M A ;
|
||||
T_CURSOR : C U R S O R ;
|
||||
T_DATABASE : D A T A B A S E ;
|
||||
T_DATA : D A T A ;
|
||||
T_DATE : D A T E ;
|
||||
T_DATETIME : D A T E T I M E ;
|
||||
T_DAY : D A Y ;
|
||||
T_DAYS : D A Y S ;
|
||||
T_DEC : D E C ;
|
||||
T_DECIMAL : D E C I M A L ;
|
||||
T_DECLARE : D E C L A R E ;
|
||||
T_DEFAULT : D E F A U L T ;
|
||||
T_DEFERRED : D E F E R R E D ;
|
||||
T_DEFINED : D E F I N E D ;
|
||||
T_DEFINER : D E F I N E R ;
|
||||
T_DEFINITION : D E F I N I T I O N ;
|
||||
T_DELETE : D E L E T E ;
|
||||
T_DELIMITED : D E L I M I T E D ;
|
||||
T_DELIMITER : D E L I M I T E R ;
|
||||
T_DESC : D E S C ;
|
||||
T_DESCRIBE : D E S C R I B E ;
|
||||
T_DIAGNOSTICS : D I A G N O S T I C S ;
|
||||
T_DIR : D I R ;
|
||||
T_DIRECTORY : D I R E C T O R Y ;
|
||||
T_DISTINCT : D I S T I N C T ;
|
||||
T_DISTRIBUTE : D I S T R I B U T E ;
|
||||
T_DO : D O ;
|
||||
T_DOUBLE : D O U B L E ;
|
||||
T_DROP : D R O P ;
|
||||
T_DYNAMIC : D Y N A M I C ;
|
||||
T_ELSE : E L S E ;
|
||||
T_ELSEIF : E L S E I F ;
|
||||
T_ELSIF : E L S I F ;
|
||||
T_ENABLE : E N A B L E ;
|
||||
T_END : E N D ;
|
||||
T_ENGINE : E N G I N E ;
|
||||
T_ESCAPED : E S C A P E D ;
|
||||
T_EXCEPT : E X C E P T ;
|
||||
T_EXEC : E X E C ;
|
||||
T_EXECUTE : E X E C U T E ;
|
||||
T_EXCEPTION : E X C E P T I O N ;
|
||||
T_EXCLUSIVE : E X C L U S I V E ;
|
||||
T_EXISTS : E X I S T S ;
|
||||
T_EXIT : E X I T ;
|
||||
T_FALLBACK : F A L L B A C K ;
|
||||
T_FALSE : F A L S E ;
|
||||
T_FETCH : F E T C H ;
|
||||
T_FIELDS : F I E L D S ;
|
||||
T_FILE : F I L E ;
|
||||
T_FILES : F I L E S ;
|
||||
T_FLOAT : F L O A T ;
|
||||
T_FOR : F O R ;
|
||||
T_FOREIGN : F O R E I G N ;
|
||||
T_FORMAT : F O R M A T ;
|
||||
T_FOUND : F O U N D ;
|
||||
T_FROM : F R O M ;
|
||||
T_FULL : F U L L ;
|
||||
T_FUNCTION : F U N C T I O N ;
|
||||
T_GET : G E T ;
|
||||
T_GLOBAL : G L O B A L ;
|
||||
T_GO : G O ;
|
||||
T_GRANT : G R A N T ;
|
||||
T_GROUP : G R O U P ;
|
||||
T_HANDLER : H A N D L E R ;
|
||||
T_HASH : H A S H ;
|
||||
T_HAVING : H A V I N G ;
|
||||
T_HDFS : H D F S ;
|
||||
T_HIVE : H I V E ;
|
||||
T_HOST : H O S T ;
|
||||
T_IDENTITY : I D E N T I T Y ;
|
||||
T_IF : I F ;
|
||||
T_IGNORE : I G N O R E ;
|
||||
T_IMMEDIATE : I M M E D I A T E ;
|
||||
T_IN : I N ;
|
||||
T_INCLUDE : I N C L U D E ;
|
||||
T_INDEX : I N D E X ;
|
||||
T_INITRANS : I N I T R A N S ;
|
||||
T_INNER : I N N E R ;
|
||||
T_INOUT : I N O U T;
|
||||
T_INSERT : I N S E R T ;
|
||||
T_INT : I N T ;
|
||||
T_INT2 : I N T '2';
|
||||
T_INT4 : I N T '4';
|
||||
T_INT8 : I N T '8';
|
||||
T_INTEGER : I N T E G E R ;
|
||||
T_INTERSECT : I N T E R S E C T ;
|
||||
T_INTERVAL : I N T E R V A L ;
|
||||
T_INTO : I N T O ;
|
||||
T_INVOKER : I N V O K E R ;
|
||||
T_IS : I S ;
|
||||
T_ISOPEN : I S O P E N ;
|
||||
T_ITEMS : I T E M S ;
|
||||
T_JOIN : J O I N ;
|
||||
T_KEEP : K E E P;
|
||||
T_KEY : K E Y ;
|
||||
T_KEYS : K E Y S ;
|
||||
T_LANGUAGE : L A N G U A G E ;
|
||||
T_LEAVE : L E A V E ;
|
||||
T_LEFT : L E F T ;
|
||||
T_LIKE : L I K E ;
|
||||
T_LIMIT : L I M I T ;
|
||||
T_LINES : L I N E S ;
|
||||
T_LOCAL : L O C A L ;
|
||||
T_LOCATION : L O C A T I O N ;
|
||||
T_LOCATOR : L O C A T O R ;
|
||||
T_LOCATORS : L O C A T O R S ;
|
||||
T_LOCKS : L O C K S ;
|
||||
T_LOG : L O G ;
|
||||
T_LOGGED : L O G G E D ;
|
||||
T_LOGGING : L O G G I N G ;
|
||||
T_LOOP : L O O P ;
|
||||
T_MAP : M A P ;
|
||||
T_MATCHED : M A T C H E D ;
|
||||
T_MAX : M A X ;
|
||||
T_MAXTRANS : M A X T R A N S ;
|
||||
T_MERGE : M E R G E ;
|
||||
T_MESSAGE_TEXT : M E S S A G E '_' T E X T ;
|
||||
T_MICROSECOND : M I C R O S E C O N D ;
|
||||
T_MICROSECONDS : M I C R O S E C O N D S;
|
||||
T_MIN : M I N ;
|
||||
T_MULTISET : M U L T I S E T ;
|
||||
T_NCHAR : N C H A R ;
|
||||
T_NEW : N E W ;
|
||||
T_NVARCHAR : N V A R C H A R ;
|
||||
T_NO : N O ;
|
||||
T_NOCOUNT : N O C O U N T ;
|
||||
T_NOCOMPRESS : N O C O M P R E S S ;
|
||||
T_NOLOGGING : N O L O G G I N G ;
|
||||
T_NONE : N O N E ;
|
||||
T_NOT : N O T ;
|
||||
T_NOTFOUND : N O T F O U N D ;
|
||||
T_NULL : N U L L ;
|
||||
T_NUMERIC : N U M E R I C ;
|
||||
T_NUMBER : N U M B E R ;
|
||||
T_OBJECT : O B J E C T ;
|
||||
T_OFF : O F F ;
|
||||
T_ON : O N ;
|
||||
T_ONLY : O N L Y ;
|
||||
T_OPEN : O P E N ;
|
||||
T_OR : O R ;
|
||||
T_ORDER : O R D E R;
|
||||
T_OUT : O U T ;
|
||||
T_OUTER : O U T E R ;
|
||||
T_OVER : O V E R ;
|
||||
T_OVERWRITE : O V E R W R I T E ;
|
||||
T_OWNER : O W N E R ;
|
||||
T_PACKAGE : P A C K A G E ;
|
||||
T_PARTITION : P A R T I T I O N ;
|
||||
T_PCTFREE : P C T F R E E ;
|
||||
T_PCTUSED : P C T U S E D ;
|
||||
T_PLS_INTEGER : P L S '_' I N T E G E R ;
|
||||
T_PRECISION : P R E C I S I O N ;
|
||||
T_PRESERVE : P R E S E R V E ;
|
||||
T_PRIMARY : P R I M A R Y ;
|
||||
T_PRINT : P R I N T ;
|
||||
T_PROC : P R O C ;
|
||||
T_PROCEDURE : P R O C E D U R E ;
|
||||
T_QUALIFY : Q U A L I F Y ;
|
||||
T_QUERY_BAND : Q U E R Y '_' B A N D ;
|
||||
T_QUIT : Q U I T ;
|
||||
T_QUOTED_IDENTIFIER : Q U O T E D '_' I D E N T I F I E R ;
|
||||
T_RAISE : R A I S E ;
|
||||
T_REAL : R E A L ;
|
||||
T_REFERENCES : R E F E R E N C E S ;
|
||||
T_REGEXP : R E G E X P ;
|
||||
T_REPLACE : R E P L A C E ;
|
||||
T_RESIGNAL : R E S I G N A L ;
|
||||
T_RESTRICT : R E S T R I C T ;
|
||||
T_RESULT : R E S U L T ;
|
||||
T_RESULT_SET_LOCATOR : R E S U L T '_' S E T '_' L O C A T O R ;
|
||||
T_RETURN : R E T U R N ;
|
||||
T_RETURNS : R E T U R N S ;
|
||||
T_REVERSE : R E V E R S E ;
|
||||
T_RIGHT : R I G H T ;
|
||||
T_RLIKE : R L I K E ;
|
||||
T_ROLE : R O L E ;
|
||||
T_ROLLBACK : R O L L B A C K ;
|
||||
T_ROW : R O W ;
|
||||
T_ROWS : R O W S ;
|
||||
T_ROWTYPE : R O W T Y P E ;
|
||||
T_ROW_COUNT : R O W '_' C O U N T ;
|
||||
T_RR : R R;
|
||||
T_RS : R S ;
|
||||
T_PWD : P W D ;
|
||||
T_TRIM : T R I M ;
|
||||
T_SCHEMA : S C H E M A ;
|
||||
T_SECOND : S E C O N D ;
|
||||
T_SECONDS : S E C O N D S;
|
||||
T_SECURITY : S E C U R I T Y ;
|
||||
T_SEGMENT : S E G M E N T ;
|
||||
T_SEL : S E L ;
|
||||
T_SELECT : S E L E C T ;
|
||||
T_SET : S E T ;
|
||||
T_SESSION : S E S S I O N ;
|
||||
T_SESSIONS : S E S S I O N S ;
|
||||
T_SETS : S E T S;
|
||||
T_SHARE : S H A R E ;
|
||||
T_SIGNAL : S I G N A L ;
|
||||
T_SIMPLE_DOUBLE : S I M P L E '_' D O U B L E ;
|
||||
T_SIMPLE_FLOAT : S I M P L E '_' F L O A T ;
|
||||
T_SIMPLE_INTEGER : S I M P L E '_' I N T E G E R ;
|
||||
T_SMALLDATETIME : S M A L L D A T E T I M E ;
|
||||
T_SMALLINT : S M A L L I N T ;
|
||||
T_SQL : S Q L ;
|
||||
T_SQLEXCEPTION : S Q L E X C E P T I O N ;
|
||||
T_SQLINSERT : S Q L I N S E R T ;
|
||||
T_SQLSTATE : S Q L S T A T E ;
|
||||
T_SQLWARNING : S Q L W A R N I N G ;
|
||||
T_STATS : S T A T S ;
|
||||
T_STATISTICS : S T A T I S T I C S ;
|
||||
T_STEP : S T E P ;
|
||||
T_STORAGE : S T O R A G E ;
|
||||
T_STORED : S T O R E D ;
|
||||
T_STRING : S T R I N G ;
|
||||
T_SUBDIR : S U B D I R ;
|
||||
T_SUBSTRING : S U B S T R I N G ;
|
||||
T_SUM : S U M ;
|
||||
T_SUMMARY : S U M M A R Y ;
|
||||
T_SYS_REFCURSOR : S Y S '_' R E F C U R S O R ;
|
||||
T_TABLE : T A B L E ;
|
||||
T_TABLESPACE : T A B L E S P A C E ;
|
||||
T_TEMPORARY : T E M P O R A R Y ;
|
||||
T_TERMINATED : T E R M I N A T E D ;
|
||||
T_TEXTIMAGE_ON : T E X T I M A G E '_' O N ;
|
||||
T_THEN : T H E N ;
|
||||
T_TIMESTAMP : T I M E S T A M P ;
|
||||
T_TINYINT : T I N Y I N T ;
|
||||
T_TITLE : T I T L E ;
|
||||
T_TO : T O ;
|
||||
T_TOP : T O P ;
|
||||
T_TRANSACTION : T R A N S A C T I O N ;
|
||||
T_TRUE : T R U E ;
|
||||
T_TRUNCATE : T R U N C A T E;
|
||||
T_TYPE : T Y P E ;
|
||||
T_UNION : U N I O N ;
|
||||
T_UNIQUE : U N I Q U E ;
|
||||
T_UPDATE : U P D A T E ;
|
||||
T_UR : U R ;
|
||||
T_USE : U S E ;
|
||||
T_USING : U S I N G ;
|
||||
T_VALUE : V A L U E ;
|
||||
T_VALUES : V A L U E S ;
|
||||
T_VAR : V A R ;
|
||||
T_VARCHAR : V A R C H A R ;
|
||||
T_VARCHAR2 : V A R C H A R '2' ;
|
||||
T_VARYING : V A R Y I N G ;
|
||||
T_VOLATILE : V O L A T I L E ;
|
||||
T_WHEN : W H E N ;
|
||||
T_WHERE : W H E R E ;
|
||||
T_WHILE : W H I L E ;
|
||||
T_WITH : W I T H ;
|
||||
T_WITHOUT : W I T H O U T ;
|
||||
T_WORK : W O R K ;
|
||||
T_XACT_ABORT : X A C T '_' A B O R T ;
|
||||
T_XML : X M L ;
|
||||
T_YES : Y E S ;
|
||||
|
||||
// Functions with specific syntax
|
||||
T_ACTIVITY_COUNT : A C T I V I T Y '_' C O U N T ;
|
||||
T_CUME_DIST : C U M E '_' D I S T ;
|
||||
T_CURRENT_DATE : C U R R E N T '_' D A T E ;
|
||||
T_CURRENT_TIMESTAMP : C U R R E N T '_' T I M E S T A M P ;
|
||||
T_CURRENT_USER : C U R R E N T '_' U S E R ;
|
||||
T_DENSE_RANK : D E N S E '_' R A N K ;
|
||||
T_FIRST_VALUE : F I R S T '_' V A L U E;
|
||||
T_LAG : L A G ;
|
||||
T_LAST_VALUE : L A S T '_' V A L U E;
|
||||
T_LEAD : L E A D ;
|
||||
T_MAX_PART_STRING : M A X '_' P A R T '_' S T R I N G ;
|
||||
T_MIN_PART_STRING : M I N '_' P A R T '_' S T R I N G ;
|
||||
T_MAX_PART_INT : M A X '_' P A R T '_' I N T ;
|
||||
T_MIN_PART_INT : M I N '_' P A R T '_' I N T ;
|
||||
T_MAX_PART_DATE : M A X '_' P A R T '_' D A T E ;
|
||||
T_MIN_PART_DATE : M I N '_' P A R T '_' D A T E ;
|
||||
T_PART_COUNT : P A R T '_' C O U N T ;
|
||||
T_PART_LOC : P A R T '_' L O C ;
|
||||
T_RANK : R A N K ;
|
||||
T_ROW_NUMBER : R O W '_' N U M B E R;
|
||||
T_STDEV : S T D E V ;
|
||||
T_SYSDATE : S Y S D A T E ;
|
||||
T_VARIANCE : V A R I A N C E ;
|
||||
T_USER : U S E R;
|
||||
|
||||
T_ADD : '+' ;
|
||||
T_COLON : ':' ;
|
||||
T_COMMA : ',' ;
|
||||
T_PIPE : '||' ;
|
||||
T_DIV : '/' ;
|
||||
T_DOT : '.' ;
|
||||
T_DOT2 : '..' ;
|
||||
T_EQUAL : '=' ;
|
||||
T_EQUAL2 : '==' ;
|
||||
T_SHARP : '#' ;
|
||||
T_NOTE : '!' ;
|
||||
T_NOTEQUAL : '<>' ;
|
||||
T_NOTEQUAL2 : '!=' ;
|
||||
T_GREATER : '>' ;
|
||||
T_GREATEREQUAL : '>=' ;
|
||||
T_LESS : '<' ;
|
||||
T_LESSEQUAL : '<=' ;
|
||||
T_MUL : '*' ;
|
||||
T_PRECENT : '%' ;
|
||||
T_CALLS : '@' ;
|
||||
T_OPEN_B : '{' ;
|
||||
T_OPEN_P : '(' ;
|
||||
T_OPEN_SB : '[' ;
|
||||
T_CLOSE_B : '}' ;
|
||||
T_CLOSE_P : ')' ;
|
||||
T_CLOSE_SB : ']' ;
|
||||
T_SEMICOLON : ';' ;
|
||||
T_SUB : '-' ;
|
||||
|
||||
L_ID : L_ID_PART // Identifier
|
||||
;
|
||||
L_S_STRING : '\'' (('\'' '\'') | ('\\' '\'') | ~('\''))* '\'' // Single quoted string literal
|
||||
;
|
||||
L_D_STRING : '"' (L_STR_ESC_D | .)*? '"' // Double quoted string literal
|
||||
;
|
||||
L_INT : L_DIGIT+ ; // Integer
|
||||
L_DEC : L_DIGIT+ '.' ~'.' L_DIGIT* // Decimal number
|
||||
| '.' L_DIGIT+
|
||||
;
|
||||
L_WS : L_BLANK+ -> skip ; // Whitespace
|
||||
L_M_COMMENT : '/*' .*? '*/' -> channel(HIDDEN) ; // Multiline comment
|
||||
L_S_COMMENT : ('--' | '//') .*? '\r'? '\n' -> channel(HIDDEN) ; // Single line comment
|
||||
|
||||
L_FILE : ([a-zA-Z] ':' '\\'?)? L_ID ('\\' L_ID)* // File path (a/b/c Linux path causes conflicts with division operator and handled at parser level)
|
||||
;
|
||||
|
||||
L_LABEL : ([a-zA-Z] | L_DIGIT | '_')* ':'
|
||||
;
|
||||
|
||||
fragment
|
||||
L_ID_PART :
|
||||
[a-zA-Z] ([a-zA-Z] | L_DIGIT | '_')* // Identifier part
|
||||
| '$' '{' .*? '}'
|
||||
| ('_' | '@' | ':' | '#' | '$') ([a-zA-Z] | L_DIGIT | '_' | '@' | ':' | '#' | '$')+ // (at least one char must follow special char)
|
||||
| '"' .*? '"' // Quoted identifiers
|
||||
| '[' .*? ']'
|
||||
| '`' .*? '`'
|
||||
;
|
||||
fragment
|
||||
L_STR_ESC_D : // Double quoted string escape sequence
|
||||
'""' | '\\"'
|
||||
;
|
||||
fragment
|
||||
L_DIGIT : [0-9] // Digit
|
||||
;
|
||||
fragment
|
||||
L_BLANK : (' ' | '\t' | '\r' | '\n')
|
||||
;
|
||||
|
||||
// Support case-insensitive keywords and allowing case-sensitive identifiers
|
||||
fragment A : ('a'|'A') ;
|
||||
fragment B : ('b'|'B') ;
|
||||
fragment C : ('c'|'C') ;
|
||||
fragment D : ('d'|'D') ;
|
||||
fragment E : ('e'|'E') ;
|
||||
fragment F : ('f'|'F') ;
|
||||
fragment G : ('g'|'G') ;
|
||||
fragment H : ('h'|'H') ;
|
||||
fragment I : ('i'|'I') ;
|
||||
fragment J : ('j'|'J') ;
|
||||
fragment K : ('k'|'K') ;
|
||||
fragment L : ('l'|'L') ;
|
||||
fragment M : ('m'|'M') ;
|
||||
fragment N : ('n'|'N') ;
|
||||
fragment O : ('o'|'O') ;
|
||||
fragment P : ('p'|'P') ;
|
||||
fragment Q : ('q'|'Q') ;
|
||||
fragment R : ('r'|'R') ;
|
||||
fragment S : ('s'|'S') ;
|
||||
fragment T : ('t'|'T') ;
|
||||
fragment U : ('u'|'U') ;
|
||||
fragment V : ('v'|'V') ;
|
||||
fragment W : ('w'|'W') ;
|
||||
fragment X : ('x'|'X') ;
|
||||
fragment Y : ('y'|'Y') ;
|
||||
fragment Z : ('z'|'Z') ;
|
3
src/grammar/impala/README.md
Normal file
3
src/grammar/impala/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# Impala SQL Grammar
|
||||
|
||||
SQL-like HiveQL, [Hive Grammar](https://github.com/apache/hive/tree/master/hplsql/src/main/antlr4/org/apache/hive/hplsql)
|
2369
src/grammar/plsql/PlSqlLexer.g4
Normal file
2369
src/grammar/plsql/PlSqlLexer.g4
Normal file
File diff suppressed because it is too large
Load Diff
6763
src/grammar/plsql/PlSqlParser.g4
Normal file
6763
src/grammar/plsql/PlSqlParser.g4
Normal file
File diff suppressed because it is too large
Load Diff
3
src/grammar/spark/README.md
Normal file
3
src/grammar/spark/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# Spark SQL
|
||||
|
||||
Grammar file from: <https://github.com/apache/spark/blob/master/sql/catalyst/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBase.g4>
|
1837
src/grammar/spark/SparkSql.g4
Normal file
1837
src/grammar/spark/SparkSql.g4
Normal file
File diff suppressed because it is too large
Load Diff
11
src/index.ts
11
src/index.ts
@ -1,9 +1,2 @@
|
||||
import * as parser from "./lib/parser";
|
||||
import * as filter from "./lib/filter";
|
||||
import flinksqlParser from './lib/flinkParser';
|
||||
|
||||
export {
|
||||
parser,
|
||||
filter,
|
||||
flinksqlParser
|
||||
};
|
||||
export * from './parser';
|
||||
export * from './utils';
|
||||
|
@ -1,19 +0,0 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
%%
|
||||
|
||||
SqlParseSupport.initSqlParser(parser);
|
@ -1,29 +0,0 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
%left 'AND' 'OR'
|
||||
%left 'BETWEEN'
|
||||
%left 'NOT' '!' '~'
|
||||
%left '=' '<' '>' 'COMPARISON_OPERATOR'
|
||||
%left '-' '*' 'ARITHMETIC_OPERATOR'
|
||||
|
||||
%left ';' ','
|
||||
%nonassoc 'CURSOR' 'PARTIAL_CURSOR'
|
||||
%nonassoc 'IN' 'IS' '<impala>ILIKE' '<impala>IREGEXP' 'LIKE' 'RLIKE' 'REGEXP' 'EXISTS' NEGATION
|
||||
|
||||
%start SqlAutocomplete
|
||||
|
||||
%%
|
@ -1,179 +0,0 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
%lex
|
||||
%x singleQuote doubleQuote
|
||||
%%
|
||||
|
||||
\s+ { return 'WS' }
|
||||
|
||||
'\u2020' { parser.yy.cursorFound = yylloc; return 'CURSOR'; }
|
||||
|
||||
[a-zA-Z]+[:] { return 'FACET' }
|
||||
|
||||
\' { this.begin('singleQuote'); return 'QUOTE'; }
|
||||
|
||||
<singleQuote>(?:\\[']|[^'])+ {
|
||||
if (parser.handleQuotedValueWithCursor(this, yytext, yylloc, '\'')) {
|
||||
return 'PARTIAL_VALUE';
|
||||
}
|
||||
return 'VALUE';
|
||||
}
|
||||
|
||||
<singleQuote>\' { this.popState(); return 'QUOTE'; }
|
||||
|
||||
\" { this.begin('doubleQuote'); return 'QUOTE'; }
|
||||
|
||||
<doubleQuote>(?:\\["]|[^"])+ {
|
||||
if (parser.handleQuotedValueWithCursor(this, yytext, yylloc, '"')) {
|
||||
return 'PARTIAL_VALUE';
|
||||
}
|
||||
return 'VALUE';
|
||||
}
|
||||
|
||||
<doubleQuote>\" { this.popState(); return 'QUOTE'; }
|
||||
|
||||
[^"'\s\u2020]+ { return 'TEXT'; }
|
||||
|
||||
<<EOF>> { return 'EOF'; }
|
||||
|
||||
/lex
|
||||
|
||||
%start GlobalSearchAutocomplete
|
||||
|
||||
%%
|
||||
|
||||
GlobalSearchAutocomplete
|
||||
: OptionalWhitespace SearchParts OptionalWhitespace 'EOF'
|
||||
{
|
||||
return $2;
|
||||
}
|
||||
| OptionalWhitespace SearchParts_EDIT 'EOF'
|
||||
{
|
||||
if (!$2.facets) {
|
||||
$2.facets = {};
|
||||
}
|
||||
if (!$2.text) {
|
||||
$2.text = [];
|
||||
}
|
||||
return $2;
|
||||
}
|
||||
| OptionalWhitespace 'EOF'
|
||||
{
|
||||
return { facets: {}, text: [] };
|
||||
}
|
||||
;
|
||||
|
||||
SearchParts
|
||||
: SearchPart
|
||||
| SearchParts WS SearchPart
|
||||
{
|
||||
parser.mergeFacets($1, $3);
|
||||
parser.mergeText($1, $3);
|
||||
}
|
||||
;
|
||||
|
||||
SearchParts_EDIT
|
||||
: SearchPart_EDIT
|
||||
| SearchParts WS SearchPart_EDIT
|
||||
{
|
||||
parser.mergeFacets($1, $3);
|
||||
parser.mergeText($1, $3);
|
||||
$$ = $3;
|
||||
$$.text = $1.text;
|
||||
$$.facets = $1.facets;
|
||||
}
|
||||
| SearchPart_EDIT WS SearchParts
|
||||
{
|
||||
$$ = $1;
|
||||
parser.mergeFacets($$, $3);
|
||||
parser.mergeText($$, $3);
|
||||
}
|
||||
| SearchParts WS SearchPart_EDIT WS SearchParts
|
||||
{
|
||||
parser.mergeFacets($1, $3);
|
||||
parser.mergeFacets($1, $5);
|
||||
parser.mergeText($1, $3);
|
||||
parser.mergeText($1, $5);
|
||||
$$ = $3;
|
||||
$$.text = $1.text;
|
||||
$$.facets = $1.facets;
|
||||
}
|
||||
;
|
||||
|
||||
SearchPart
|
||||
: Facet --> { text: [], facets: $1.facets }
|
||||
| FreeText --> { text: [$1], facets: {} }
|
||||
;
|
||||
|
||||
SearchPart_EDIT
|
||||
: Facet_EDIT
|
||||
| FreeText_EDIT
|
||||
;
|
||||
|
||||
Facet
|
||||
: 'FACET' OptionalWhitespace FreeText
|
||||
{
|
||||
var facet = {};
|
||||
var facetName = $1.substring(0, $1.length - 1).toLowerCase();
|
||||
facet[facetName] = {};
|
||||
facet[facetName][$3.toLowerCase()] = true;
|
||||
$$ = { facets: facet };
|
||||
}
|
||||
;
|
||||
|
||||
Facet_EDIT
|
||||
: 'FACET' OptionalWhitespace 'CURSOR' --> { suggestFacetValues: $1.substring(0, $1.length - 1).toLowerCase() }
|
||||
| 'FACET' OptionalWhitespace FreeText 'CURSOR'
|
||||
{
|
||||
var facet = {};
|
||||
var facetName = $1.substring(0, $1.length - 1).toLowerCase();
|
||||
facet[facetName] = {};
|
||||
facet[facetName][$3.toLowerCase()] = true;
|
||||
$$ = { suggestFacetValues: facetName, facets: facet }
|
||||
}
|
||||
;
|
||||
|
||||
FreeText
|
||||
: 'TEXT'
|
||||
| QuotedValue
|
||||
;
|
||||
|
||||
FreeText_EDIT
|
||||
: 'CURSOR' --> { suggestFacets: true, suggestResults: true }
|
||||
| 'CURSOR' 'TEXT' --> { suggestFacets: true, suggestResults: true, text: [$2] }
|
||||
| 'TEXT' 'CURSOR' 'TEXT' --> { suggestFacets: true, suggestResults: true, text: [$1+$3] }
|
||||
| 'TEXT' 'CURSOR' --> { suggestFacets: true, suggestResults: true, text: [$1] }
|
||||
| QuotedValue_EDIT
|
||||
;
|
||||
|
||||
QuotedValue
|
||||
: 'QUOTE' 'VALUE' 'QUOTE' --> $2
|
||||
| 'QUOTE' 'QUOTE' --> ''
|
||||
;
|
||||
|
||||
QuotedValue_EDIT
|
||||
: 'QUOTE' 'PARTIAL_VALUE' --> $2
|
||||
;
|
||||
|
||||
OptionalWhitespace
|
||||
:
|
||||
| WS
|
||||
;
|
||||
|
||||
%%
|
||||
|
||||
SqlParseSupport.initGlobalSearchParser(parser);
|
@ -1,265 +0,0 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
%lex
|
||||
%options case-insensitive
|
||||
%%
|
||||
|
||||
\s { /* skip whitespace */ }
|
||||
'--'.* { /* skip comments */ }
|
||||
[/][*][^*]*[*]+([^/*][^*]*[*]+)*[/] { /* skip comments */ }
|
||||
|
||||
'\u2020' { parser.yy.cursorFound = yylloc; return 'CURSOR'; }
|
||||
|
||||
[0-9]+(?:[,.][0-9]+)? { return 'NUMBER'; }
|
||||
|
||||
'-' { return '-'; }
|
||||
'+' { return '+'; }
|
||||
'*' { return '*'; }
|
||||
'/' { return '/'; }
|
||||
|
||||
[a-z]+\s*\( {
|
||||
yy.lexer.unput('(');
|
||||
parser.addFunctionLocation({
|
||||
first_line: yylloc.first_line,
|
||||
first_column: yylloc.first_column,
|
||||
last_line: yylloc.first_line,
|
||||
last_column: yylloc.first_column + yytext.trim().length
|
||||
}, yytext.trim());
|
||||
return 'FUNCTION';
|
||||
}
|
||||
|
||||
',' { return ','; }
|
||||
'(' { return '('; }
|
||||
')' { return ')'; }
|
||||
|
||||
<<EOF>> { return 'EOF'; }
|
||||
|
||||
[^\s\u2020()]+ { parser.addFieldLocation(yylloc, yytext); return 'IDENTIFIER'; }
|
||||
|
||||
/lex
|
||||
|
||||
%left '+' '-'
|
||||
%left '*' '/'
|
||||
|
||||
%start SolrFormulaAutocomplete
|
||||
|
||||
%%
|
||||
|
||||
SolrFormulaAutocomplete
|
||||
: SolrFormula 'EOF'
|
||||
{
|
||||
return {
|
||||
parsedValue: $1
|
||||
};
|
||||
}
|
||||
| SolrFormula_EDIT 'EOF'
|
||||
{
|
||||
return $1
|
||||
}
|
||||
| 'CURSOR' 'EOF'
|
||||
{
|
||||
return { suggestAggregateFunctions: true }
|
||||
}
|
||||
;
|
||||
|
||||
SolrFormula
|
||||
: NonParenthesizedSolrFormula
|
||||
| '(' NonParenthesizedSolrFormula ')' -> $1 + $2 + $3
|
||||
;
|
||||
|
||||
SolrFormula_EDIT
|
||||
: NonParenthesizedSolrFormula_EDIT
|
||||
| '(' NonParenthesizedSolrFormula_EDIT RightParenthesisOrError --> $2
|
||||
;
|
||||
|
||||
NonParenthesizedSolrFormula
|
||||
: 'NUMBER'
|
||||
| 'IDENTIFIER'
|
||||
| 'FUNCTION' '(' ArgumentList ')' -> $1 + $2 + $3 + $4
|
||||
| SolrFormula '+' SolrFormula -> 'sum(' + $1 + ',' + $3 + ')'
|
||||
| SolrFormula '-' SolrFormula -> 'sub(' + $1 + ',' + $3 + ')'
|
||||
| SolrFormula '*' SolrFormula -> 'mul(' + $1 + ',' + $3 + ')'
|
||||
| SolrFormula '/' SolrFormula -> 'div(' + $1 + ',' + $3 + ')'
|
||||
| '-' SolrFormula -> 'sub(0,' + $2 + ')'
|
||||
;
|
||||
|
||||
NonParenthesizedSolrFormula_EDIT
|
||||
: 'NUMBER' 'CURSOR' --> { suggestOperators: true }
|
||||
| 'IDENTIFIER' 'CURSOR' --> { suggestOperators: true }
|
||||
| 'CURSOR' 'NUMBER' --> { suggestAggregateFunctions: true, suggestFunctions: true, suggestFields: true }
|
||||
| 'CURSOR' 'IDENTIFIER' --> { suggestAggregateFunctions: true, suggestFunctions: true, suggestFields: true }
|
||||
;
|
||||
|
||||
NonParenthesizedSolrFormula_EDIT
|
||||
: 'FUNCTION' '(' 'CURSOR' RightParenthesisOrError --> { suggestAggregateFunctions: true, suggestFunctions: true, suggestFields: true }
|
||||
| 'FUNCTION' '(' ArgumentList_EDIT RightParenthesisOrError --> $3
|
||||
| 'FUNCTION' '(' ArgumentList ')' 'CURSOR' --> { suggestOperators: true }
|
||||
;
|
||||
|
||||
NonParenthesizedSolrFormula_EDIT
|
||||
: SolrFormula '+' 'CURSOR' --> { suggestAggregateFunctions: true, suggestFunctions: true, suggestFields: true }
|
||||
| 'CURSOR' '+' SolrFormula --> { suggestAggregateFunctions: true, suggestFunctions: true, suggestFields: true }
|
||||
| SolrFormula_EDIT '+' SolrFormula --> $1
|
||||
| SolrFormula '+' SolrFormula_EDIT --> $3
|
||||
;
|
||||
|
||||
NonParenthesizedSolrFormula_EDIT
|
||||
: SolrFormula '-' 'CURSOR' --> { suggestAggregateFunctions: true, suggestFunctions: true, suggestFields: true }
|
||||
| 'CURSOR' '-' SolrFormula --> { suggestAggregateFunctions: true, suggestFunctions: true, suggestFields: true }
|
||||
| SolrFormula_EDIT '-' SolrFormula --> $1
|
||||
| SolrFormula '-' SolrFormula_EDIT --> $3
|
||||
;
|
||||
|
||||
NonParenthesizedSolrFormula_EDIT
|
||||
: SolrFormula '*' 'CURSOR' --> { suggestAggregateFunctions: true, suggestFunctions: true, suggestFields: true }
|
||||
| 'CURSOR' '*' SolrFormula --> { suggestAggregateFunctions: true, suggestFunctions: true, suggestFields: true }
|
||||
| SolrFormula_EDIT '*' SolrFormula --> $1
|
||||
| SolrFormula '*' SolrFormula_EDIT --> $3
|
||||
;
|
||||
|
||||
NonParenthesizedSolrFormula_EDIT
|
||||
: SolrFormula '/' 'CURSOR' --> { suggestAggregateFunctions: true, suggestFunctions: true, suggestFields: true }
|
||||
| 'CURSOR' '/' SolrFormula --> { suggestAggregateFunctions: true, suggestFunctions: true, suggestFields: true }
|
||||
| SolrFormula_EDIT '/' SolrFormula --> $1
|
||||
| SolrFormula '/' SolrFormula_EDIT --> $3
|
||||
;
|
||||
|
||||
NonParenthesizedSolrFormula_EDIT
|
||||
: '-' 'CURSOR' --> { suggestAggregateFunctions: true, suggestFunctions: true, suggestFields: true }
|
||||
| '-' SolrFormula_EDIT --> $2
|
||||
;
|
||||
|
||||
ArgumentList
|
||||
: SolrFormula
|
||||
| ArgumentList ',' SolrFormula
|
||||
;
|
||||
|
||||
ArgumentList_EDIT
|
||||
: SolrFormula_EDIT
|
||||
| ArgumentList ',' SolrFormula_EDIT --> $3
|
||||
| SolrFormula_EDIT ',' ArgumentList
|
||||
| ArgumentList ',' SolrFormula_EDIT ',' ArgumentList --> $3
|
||||
;
|
||||
|
||||
|
||||
RightParenthesisOrError
|
||||
: ')'
|
||||
| error
|
||||
;
|
||||
|
||||
%%
|
||||
|
||||
parser.yy.parseError = function () { return false; }
|
||||
|
||||
parser.identifyPartials = function (beforeCursor, afterCursor) {
|
||||
var beforeMatch = beforeCursor.match(/[^()-*+/,\s]*$/);
|
||||
var afterMatch = afterCursor.match(/^[^()-*+/,\s]*/);
|
||||
return {left: beforeMatch ? beforeMatch[0].length : 0, right: afterMatch ? afterMatch[0].length : 0};
|
||||
};
|
||||
|
||||
var adjustLocationForCursor = function (location) {
|
||||
// columns are 0-based and lines not, so add 1 to cols
|
||||
var newLocation = {
|
||||
first_line: location.first_line,
|
||||
last_line: location.last_line,
|
||||
first_column: location.first_column + 1,
|
||||
last_column: location.last_column + 1
|
||||
};
|
||||
if (parser.yy.cursorFound) {
|
||||
if (parser.yy.cursorFound.first_line === newLocation.first_line && parser.yy.cursorFound.last_column <= newLocation.first_column) {
|
||||
var additionalSpace = parser.yy.partialLengths.left + parser.yy.partialLengths.right;
|
||||
additionalSpace -= parser.yy.partialCursor ? 1 : 3; // For some reason the normal cursor eats 3 positions.
|
||||
newLocation.first_column = newLocation.first_column + additionalSpace;
|
||||
newLocation.last_column = newLocation.last_column + additionalSpace;
|
||||
}
|
||||
}
|
||||
return newLocation;
|
||||
};
|
||||
|
||||
parser.addFunctionLocation = function (location, name) {
|
||||
parser.yy.locations.push({ type: 'function', name: name, location: adjustLocationForCursor(location) });
|
||||
}
|
||||
|
||||
parser.addFieldLocation = function (location, name) {
|
||||
parser.yy.locations.push({ type: 'field', name: name, location: adjustLocationForCursor(location) });
|
||||
}
|
||||
|
||||
parser.parseSolrFormula = function (formula, debug) {
|
||||
parser.yy.cursorFound = false;
|
||||
parser.yy.locations = [];
|
||||
formula = formula.replace(/\r\n|\n\r/gm, '\n');
|
||||
|
||||
var result;
|
||||
try {
|
||||
result = parser.parse(formula);
|
||||
} catch (err) {
|
||||
if (debug) {
|
||||
console.log(beforeCursor + '\u2020' + afterCursor);
|
||||
console.log(err);
|
||||
console.error(err.stack);
|
||||
}
|
||||
}
|
||||
return result || false;
|
||||
}
|
||||
|
||||
parser.autocompleteSolrFormula = function (beforeCursor, afterCursor, debug) {
|
||||
parser.yy.cursorFound = false;
|
||||
parser.yy.locations = [];
|
||||
|
||||
beforeCursor = beforeCursor.replace(/\r\n|\n\r/gm, '\n');
|
||||
afterCursor = afterCursor.replace(/\r\n|\n\r/gm, '\n');
|
||||
|
||||
parser.yy.partialLengths = parser.identifyPartials(beforeCursor, afterCursor);
|
||||
|
||||
if (parser.yy.partialLengths.left > 0) {
|
||||
beforeCursor = beforeCursor.substring(0, beforeCursor.length - parser.yy.partialLengths.left);
|
||||
}
|
||||
|
||||
if (parser.yy.partialLengths.right > 0) {
|
||||
afterCursor = afterCursor.substring(parser.yy.partialLengths.right);
|
||||
}
|
||||
|
||||
var result;
|
||||
try {
|
||||
result = parser.parse(beforeCursor + '\u2020' + afterCursor);
|
||||
} catch (err) {
|
||||
// Workaround for too many missing parentheses (it's the only error we handle in the parser)
|
||||
if (err && err.toString().indexOf('Parsing halted while starting to recover from another error') !== -1) {
|
||||
var leftCount = (beforeCursor.match(/\(/g) || []).length;
|
||||
var rightCount = (beforeCursor.match(/\)/g) || []).length;
|
||||
var parenthesisPad = '';
|
||||
while (rightCount < leftCount) {
|
||||
parenthesisPad += ')';
|
||||
rightCount++;
|
||||
}
|
||||
try {
|
||||
result = parser.parse(beforeCursor + '\u2020' + parenthesisPad);
|
||||
} catch (err) {
|
||||
return {}
|
||||
}
|
||||
} else {
|
||||
if (debug) {
|
||||
console.log(beforeCursor + '\u2020' + afterCursor);
|
||||
console.log(err);
|
||||
console.error(err.stack);
|
||||
}
|
||||
return {}
|
||||
}
|
||||
}
|
||||
result.locations = parser.yy.locations;
|
||||
return result;
|
||||
};
|
@ -1,292 +0,0 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
%lex
|
||||
%options case-insensitive flex
|
||||
%x squareBracketRange curlyBracketRange doubleQuotedValue singleQuotedValue
|
||||
%%
|
||||
|
||||
\s { /* skip whitespace */ }
|
||||
'--'.* { /* skip comments */ }
|
||||
[/][*][^*]*[*]+([^/*][^*]*[*]+)*[/] { /* skip comments */ }
|
||||
|
||||
'\u2020' { parser.yy.cursorFound = yylloc; return 'CURSOR'; }
|
||||
|
||||
'AND' { return 'AND'; }
|
||||
'&&' { return 'AND'; }
|
||||
'OR' { return 'OR'; }
|
||||
'||' { return 'OR'; }
|
||||
'NOT' { return 'NOT'; }
|
||||
'!' { return 'NOT'; }
|
||||
'+' { return '+'; }
|
||||
'-' { return '-'; }
|
||||
':' { return ':'; }
|
||||
'*' { return '*'; }
|
||||
|
||||
'(' { return '('; }
|
||||
')' { return ')'; }
|
||||
|
||||
[0-9]+(?:[,.][0-9]+)? { return 'NUMBER'; }
|
||||
|
||||
'[' { this.begin('squareBracketRange'); return '['; }
|
||||
<squareBracketRange>(?:\\[\]]|[^\]])+ {
|
||||
if (parser.handleQuotedValueWithCursor(this, yytext, yylloc, ']')) {
|
||||
return 'PARTIAL_VALUE';
|
||||
}
|
||||
return 'VALUE';
|
||||
}
|
||||
<singleQuotedValue>\] { this.popState(); return ']'; }
|
||||
|
||||
'{' { this.begin('curlyBracketRange'); return '{'; }
|
||||
<curlyBracketRange>(?:\\[\}]|[^\}])+ {
|
||||
if (parser.handleQuotedValueWithCursor(this, yytext, yylloc, '}')) {
|
||||
return 'PARTIAL_VALUE';
|
||||
}
|
||||
return 'VALUE';
|
||||
}
|
||||
<curlyBracketRange>\} { this.popState(); return '}'; }
|
||||
|
||||
\' { this.begin('singleQuotedValue'); return 'SINGLE_QUOTE'; }
|
||||
<singleQuotedValue>(?:\\[']|[^'])+ {
|
||||
if (parser.handleQuotedValueWithCursor(this, yytext, yylloc, '\'')) {
|
||||
yytext = yytext.replace(/[\u2020].*/, '');
|
||||
return 'PARTIAL_VALUE';
|
||||
}
|
||||
return 'VALUE';
|
||||
}
|
||||
<singleQuotedValue>\' { this.popState(); return 'SINGLE_QUOTE'; }
|
||||
|
||||
\" { this.begin('doubleQuotedValue'); return 'DOUBLE_QUOTE'; }
|
||||
<doubleQuotedValue>(?:\\["]|[^"])+ {
|
||||
if (parser.handleQuotedValueWithCursor(this, yytext, yylloc, '"')) {
|
||||
yytext = yytext.replace(/[\u2020].*/, '');
|
||||
return 'PARTIAL_VALUE';
|
||||
}
|
||||
return 'VALUE';
|
||||
}
|
||||
<doubleQuotedValue>\" { this.popState(); return 'DOUBLE_QUOTE'; }
|
||||
|
||||
[^\s\u3000!():"'^+\-\[\]{}~*?/\u2020]+ { return 'TERM'; }
|
||||
|
||||
<<EOF>> { return 'EOF'; }
|
||||
|
||||
/lex
|
||||
|
||||
%left 'AND' 'OR' '&&' '||' BooleanOperator
|
||||
%left 'CURSOR' // Cursor precedence needed to not conflict with operators i.e. x 'CURSOR' y vs. x 'AND' y
|
||||
|
||||
%start SolrQueryAutocomplete
|
||||
|
||||
%%
|
||||
|
||||
SolrQueryAutocomplete
|
||||
: SolrQuery 'EOF'
|
||||
{
|
||||
return {}
|
||||
}
|
||||
| SolrQuery_EDIT 'EOF'
|
||||
{
|
||||
return $1;
|
||||
}
|
||||
| 'CURSOR' 'EOF'
|
||||
{
|
||||
return { suggestFields: { appendColon: true } }
|
||||
}
|
||||
;
|
||||
|
||||
SolrQuery
|
||||
: NonParenthesizedSolrQuery
|
||||
| '(' NonParenthesizedSolrQuery ')' --> $2
|
||||
;
|
||||
|
||||
SolrQuery_EDIT
|
||||
: NonParenthesizedSolrQuery_EDIT
|
||||
| '(' NonParenthesizedSolrQuery_EDIT RightParenthesisOrError --> $2
|
||||
;
|
||||
|
||||
NonParenthesizedSolrQuery
|
||||
: 'NUMBER'
|
||||
| 'TERM'
|
||||
| KeywordMatch --> { hasKeywordMatch: true }
|
||||
;
|
||||
|
||||
NonParenthesizedSolrQuery_EDIT
|
||||
: KeywordMatch_EDIT
|
||||
;
|
||||
|
||||
NonParenthesizedSolrQuery
|
||||
: SolrQuery BooleanOperator SolrQuery
|
||||
;
|
||||
|
||||
NonParenthesizedSolrQuery_EDIT
|
||||
: SolrQuery 'CURSOR'
|
||||
{
|
||||
if ($1.hasKeywordMatch) {
|
||||
$$ = { suggestKeywords: ['AND', 'OR'] };
|
||||
} else {
|
||||
$$ = { suggestKeywords: ['AND', 'OR', ':'], suggestValues: { field: $1, prependColon: true } };
|
||||
}
|
||||
}
|
||||
| SolrQuery 'CURSOR' SolrQuery
|
||||
{
|
||||
if ($1.hasKeywordMatch) {
|
||||
$$ = { suggestKeywords: ['AND', 'OR'] };
|
||||
} else {
|
||||
$$ = { suggestKeywords: ['AND', 'OR', ':'], suggestValues: { field: $1, prependColon: true } };
|
||||
}
|
||||
}
|
||||
| 'CURSOR' SolrQuery --> { suggestFields: { appendColon: true } }
|
||||
;
|
||||
|
||||
NonParenthesizedSolrQuery_EDIT
|
||||
: SolrQuery BooleanOperator 'CURSOR' --> { suggestFields: { appendColon: true } }
|
||||
| 'CURSOR' BooleanOperator SolrQuery --> { suggestFields: { appendColon: true } }
|
||||
| SolrQuery BooleanOperator SolrQuery_EDIT --> $3
|
||||
| SolrQuery_EDIT BooleanOperator SolrQuery --> $1
|
||||
;
|
||||
|
||||
KeywordMatch
|
||||
: 'TERM' ':' 'TERM'
|
||||
| 'TERM' ':' QuotedValue
|
||||
;
|
||||
|
||||
KeywordMatch_EDIT
|
||||
: 'TERM' ':' 'CURSOR' --> { suggestValues: { field: $1 } }
|
||||
| 'TERM' ':' QuotedValue_EDIT --> { suggestValues: { field: $1, quotePresent: true, partial: $3 } }
|
||||
;
|
||||
|
||||
// ======= Common constructs =======
|
||||
|
||||
BooleanOperator
|
||||
: 'AND' | 'OR' | '&&' | '||';
|
||||
|
||||
QuotedValue
|
||||
: 'SINGLE_QUOTE' 'VALUE' 'SINGLE_QUOTE' --> $2
|
||||
| 'DOUBLE_QUOTE' 'VALUE' 'DOUBLE_QUOTE' --> $2
|
||||
;
|
||||
|
||||
QuotedValue_EDIT
|
||||
: 'SINGLE_QUOTE' 'PARTIAL_VALUE' --> $2
|
||||
| 'DOUBLE_QUOTE' 'PARTIAL_VALUE' --> $2
|
||||
;
|
||||
|
||||
RightParenthesisOrError: ')' | error;
|
||||
%%
|
||||
|
||||
parser.yy.parseError = function () { return false; }
|
||||
|
||||
parser.addFieldLocation = function (location, name) {
|
||||
parser.yy.locations.push({ type: 'field', name: name, location: adjustLocationForCursor(location) });
|
||||
}
|
||||
|
||||
parser.identifyPartials = function (beforeCursor, afterCursor) {
|
||||
var beforeMatch = beforeCursor.match(/[^()-*+/,:"'\s]*$/);
|
||||
var afterMatch = afterCursor.match(/^[^()-*+/,:"'\s]*/);
|
||||
return { left: beforeMatch ? beforeMatch[0].length : 0, right: afterMatch ? afterMatch[0].length : 0 };
|
||||
};
|
||||
|
||||
parser.handleQuotedValueWithCursor = function (lexer, yytext, yylloc, quoteChar) {
|
||||
if (yytext.indexOf('\u2020') !== -1) {
|
||||
var cursorIndex = yytext.indexOf('\u2020');
|
||||
parser.yy.cursorFound = {
|
||||
first_line: yylloc.first_line,
|
||||
last_line: yylloc.last_line,
|
||||
first_column: yylloc.first_column + cursorIndex,
|
||||
last_column: yylloc.first_column + cursorIndex + 1
|
||||
};
|
||||
var remainder = yytext.substring(cursorIndex + 1);
|
||||
var remainingQuotes = (lexer.upcomingInput().match(new RegExp(quoteChar, 'g')) || []).length;
|
||||
if (remainingQuotes > 0 && remainingQuotes & 1 != 0) {
|
||||
parser.yy.missingEndQuote = false;
|
||||
lexer.input();
|
||||
} else {
|
||||
parser.yy.missingEndQuote = true;
|
||||
lexer.unput(remainder);
|
||||
}
|
||||
lexer.popState();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
var adjustLocationForCursor = function (location) {
|
||||
// columns are 0-based and lines not, so add 1 to cols
|
||||
var newLocation = {
|
||||
first_line: location.first_line,
|
||||
last_line: location.last_line,
|
||||
first_column: location.first_column + 1,
|
||||
last_column: location.last_column + 1
|
||||
};
|
||||
if (parser.yy.cursorFound) {
|
||||
if (parser.yy.cursorFound.first_line === newLocation.first_line && parser.yy.cursorFound.last_column <= newLocation.first_column) {
|
||||
var additionalSpace = parser.yy.partialLengths.left + parser.yy.partialLengths.right;
|
||||
additionalSpace -= parser.yy.partialCursor ? 1 : 3; // For some reason the normal cursor eats 3 positions.
|
||||
newLocation.first_column = newLocation.first_column + additionalSpace;
|
||||
newLocation.last_column = newLocation.last_column + additionalSpace;
|
||||
}
|
||||
}
|
||||
return newLocation;
|
||||
};
|
||||
|
||||
parser.autocompleteSolrQuery = function (beforeCursor, afterCursor, debug) {
|
||||
parser.yy.cursorFound = false;
|
||||
parser.yy.locations = [];
|
||||
|
||||
beforeCursor = beforeCursor.replace(/\r\n|\n\r/gm, '\n');
|
||||
afterCursor = afterCursor.replace(/\r\n|\n\r/gm, '\n');
|
||||
|
||||
parser.yy.partialLengths = parser.identifyPartials(beforeCursor, afterCursor);
|
||||
|
||||
parser.yy.partialCursor = parser.yy.partialLengths.left > 0;
|
||||
|
||||
if (parser.yy.partialLengths.left > 0) {
|
||||
beforeCursor = beforeCursor.substring(0, beforeCursor.length - parser.yy.partialLengths.left);
|
||||
}
|
||||
|
||||
if (parser.yy.partialLengths.right > 0) {
|
||||
afterCursor = afterCursor.substring(parser.yy.partialLengths.right);
|
||||
}
|
||||
|
||||
var result;
|
||||
try {
|
||||
result = parser.parse(beforeCursor + '\u2020' + afterCursor);
|
||||
} catch (err) {
|
||||
// Workaround for too many missing parentheses (it's the only error we handle in the parser)
|
||||
if (err && err.toString().indexOf('Parsing halted while starting to recover from another error') !== -1) {
|
||||
var leftCount = (beforeCursor.match(/\(/g) || []).length;
|
||||
var rightCount = (beforeCursor.match(/\)/g) || []).length;
|
||||
var parenthesisPad = '';
|
||||
while (rightCount < leftCount) {
|
||||
parenthesisPad += ')';
|
||||
rightCount++;
|
||||
}
|
||||
try {
|
||||
result = parser.parse(beforeCursor + '\u2020' + parenthesisPad);
|
||||
} catch (err) {
|
||||
return { locations: parser.yy.locations }
|
||||
}
|
||||
} else {
|
||||
if (debug) {
|
||||
console.log(beforeCursor + '\u2020' + afterCursor);
|
||||
console.log(err);
|
||||
console.error(err.stack);
|
||||
}
|
||||
return { locations: parser.yy.locations }
|
||||
}
|
||||
}
|
||||
result.locations = parser.yy.locations;
|
||||
return result;
|
||||
};
|
@ -1,754 +0,0 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
%options case-insensitive flex
|
||||
%s between hive impala
|
||||
%x hdfs doubleQuotedValue singleQuotedValue backtickedValue
|
||||
%%
|
||||
|
||||
\s { /* skip whitespace */ }
|
||||
'--'.* { /* skip comments */ }
|
||||
[/][*][^*]*[*]+([^/*][^*]*[*]+)*[/] { /* skip comments */ }
|
||||
|
||||
'\u2020' { parser.yy.partialCursor = false; parser.yy.cursorFound = yylloc; return 'CURSOR'; }
|
||||
'\u2021' { parser.yy.partialCursor = true; parser.yy.cursorFound = yylloc; return 'PARTIAL_CURSOR'; }
|
||||
|
||||
// Reserved Keywords
|
||||
<hive>'ALL' { return '<hive>ALL'; }
|
||||
<hive>'ARRAY' { return 'ARRAY'; }
|
||||
<hive>'AS' { return '<hive>AS'; }
|
||||
<hive>'AUTHORIZATION' { return '<hive>AUTHORIZATION'; }
|
||||
<hive>'BINARY' { return '<hive>BINARY'; }
|
||||
<hive>'CACHE' { return '<hive>CACHE'; }
|
||||
<hive>'COLUMN' { return '<hive>COLUMN'; }
|
||||
<hive>'CONF' { return '<hive>CONF'; }
|
||||
<hive>'CONSTRAINT' { return '<hive>CONSTRAINT'; }
|
||||
<hive>'CREATE' { parser.determineCase(yytext); return '<hive>CREATE'; }
|
||||
<hive>'CUBE' { return '<hive>CUBE'; }
|
||||
<hive>'CURRENT' { return '<hive>CURRENT'; }
|
||||
<hive>'DATE' { return '<hive>DATE'; }
|
||||
<hive>'DELETE' { parser.determineCase(yytext); return '<hive>DELETE'; }
|
||||
<hive>'DESCRIBE' { parser.determineCase(yytext); return '<hive>DESCRIBE'; }
|
||||
<hive>'EXTENDED' { return '<hive>EXTENDED'; }
|
||||
<hive>'EXTERNAL' { return '<hive>EXTERNAL'; }
|
||||
<hive>'FOR' { return '<hive>FOR'; }
|
||||
<hive>'FOREIGN' { return '<hive>FOREIGN'; }
|
||||
<hive>'FUNCTION' { return '<hive>FUNCTION'; }
|
||||
<hive>'GRANT' { return '<hive>GRANT'; }
|
||||
<hive>'GROUPING' { return '<hive>GROUPING'; }
|
||||
<hive>'IMPORT' { parser.determineCase(yytext); return '<hive>IMPORT'; }
|
||||
<hive>'INSERT' { parser.determineCase(yytext); return '<hive>INSERT'; }
|
||||
<hive>'LATERAL' { return '<hive>LATERAL'; }
|
||||
<hive>'LOCAL' { return '<hive>LOCAL'; }
|
||||
<hive>'MACRO' { return '<hive>MACRO'; }
|
||||
<hive>'MAP' { return 'MAP'; }
|
||||
<hive>'NONE' { return '<hive>NONE'; }
|
||||
<hive>'OF' { return '<hive>OF'; }
|
||||
<hive>'OUT' { return '<hive>OUT'; }
|
||||
<hive>'PRIMARY' { return '<hive>PRIMARY'; }
|
||||
<hive>'REFERENCES' { return '<hive>REFERENCES'; }
|
||||
<hive>'REVOKE' { return '<hive>REVOKE'; }
|
||||
<hive>'ROLLUP' { return '<hive>ROLLUP'; }
|
||||
<hive>'SYNC' { return '<hive>SYNC'; }
|
||||
<hive>'TABLE' { return '<hive>TABLE'; }
|
||||
<hive>'TIMESTAMP' { return '<hive>TIMESTAMP'; }
|
||||
<hive>'UTC_TIMESTAMP' { return '<hive>UTC_TIMESTAMP'; }
|
||||
<hive>'USER' { return '<hive>USER'; }
|
||||
<hive>'USING' { return '<hive>USING'; }
|
||||
<hive>'VIEWS' { return '<hive>VIEWS'; }
|
||||
|
||||
// Non-reserved Keywords
|
||||
<hive>'ABORT' { parser.determineCase(yytext); return '<hive>ABORT'; }
|
||||
<hive>'ADD' { return '<hive>ADD'; }
|
||||
<hive>'ADMIN' { return '<hive>ADMIN'; }
|
||||
<hive>'AFTER' { return '<hive>AFTER'; }
|
||||
<hive>'ANALYZE' { parser.determineCase(yytext); return '<hive>ANALYZE'; }
|
||||
<hive>'ARCHIVE' { return '<hive>ARCHIVE'; }
|
||||
<hive>'ASC' { return '<hive>ASC'; }
|
||||
<hive>'AVRO' { return '<hive>AVRO'; }
|
||||
<hive>'BUCKET' { return '<hive>BUCKET'; }
|
||||
<hive>'BUCKETS' { return '<hive>BUCKETS'; }
|
||||
<hive>'CASCADE' { return '<hive>CASCADE'; }
|
||||
<hive>'CHANGE' { return '<hive>CHANGE'; }
|
||||
<hive>'CLUSTER' { return '<hive>CLUSTER'; }
|
||||
<hive>'CLUSTERED' { return '<hive>CLUSTERED'; }
|
||||
<hive>'COLLECTION' { return '<hive>COLLECTION'; }
|
||||
<hive>'COLUMNS' { return '<hive>COLUMNS'; }
|
||||
<hive>'COMMENT' { return '<hive>COMMENT'; }
|
||||
<hive>'COMPACT' { return '<hive>COMPACT'; }
|
||||
<hive>'COMPACTIONS' { return '<hive>COMPACTIONS'; }
|
||||
<hive>'COMPUTE' { return '<hive>COMPUTE'; }
|
||||
<hive>'CONCATENATE' { return '<hive>CONCATENATE'; }
|
||||
<hive>'DATA' { return '<hive>DATA'; }
|
||||
<hive>'DATABASES' { return '<hive>DATABASES'; }
|
||||
<hive>'DAY' { return '<hive>DAY'; }
|
||||
<hive>'DAYOFWEEK' { return '<hive>DAYOFWEEK'; }
|
||||
<hive>'DBPROPERTIES' { return '<hive>DBPROPERTIES'; }
|
||||
<hive>'DEFERRED' { return '<hive>DEFERRED'; }
|
||||
<hive>'DEFINED' { return '<hive>DEFINED'; }
|
||||
<hive>'DELIMITED' { return '<hive>DELIMITED'; }
|
||||
<hive>'DEPENDENCY' { return '<hive>DEPENDENCY'; }
|
||||
<hive>'DESC' { return '<hive>DESC'; }
|
||||
<hive>'DIRECTORY' { this.begin('hdfs'); return '<hive>DIRECTORY'; }
|
||||
<hive>'DISABLE' { return '<hive>DISABLE'; }
|
||||
<hive>'DISTRIBUTE' { return '<hive>DISTRIBUTE'; }
|
||||
<hive>DOUBLE\s+PRECISION { return '<hive>DOUBLE_PRECISION'; }
|
||||
<hive>'ESCAPED' { return '<hive>ESCAPED'; }
|
||||
<hive>'ENABLE' { return '<hive>ENABLE'; }
|
||||
<hive>'EXCHANGE' { return '<hive>EXCHANGE'; }
|
||||
<hive>'EXPLAIN' { parser.determineCase(yytext); return '<hive>EXPLAIN'; }
|
||||
<hive>'EXPORT' { parser.determineCase(yytext); return '<hive>EXPORT'; }
|
||||
<hive>'FIELDS' { return '<hive>FIELDS'; }
|
||||
<hive>'FILE' { return '<hive>FILE'; }
|
||||
<hive>'FILEFORMAT' { return '<hive>FILEFORMAT'; }
|
||||
<hive>'FIRST' { return '<hive>FIRST'; }
|
||||
<hive>'FORMAT' { return '<hive>FORMAT'; }
|
||||
<hive>'FORMATTED' { return '<hive>FORMATTED'; }
|
||||
<hive>'FUNCTION' { return '<hive>FUNCTION'; }
|
||||
<hive>'FUNCTIONS' { return '<hive>FUNCTIONS'; }
|
||||
<hive>'HOUR' { return '<hive>HOUR'; }
|
||||
<hive>'IDXPROPERTIES' { return '<hive>IDXPROPERTIES'; }
|
||||
<hive>'INDEX' { return '<hive>INDEX'; }
|
||||
<hive>'INDEXES' { return '<hive>INDEXES'; }
|
||||
<hive>'INPATH' { this.begin('hdfs'); return '<hive>INPATH'; }
|
||||
<hive>'INPUTFORMAT' { return '<hive>INPUTFORMAT'; }
|
||||
<hive>'ITEMS' { return '<hive>ITEMS'; }
|
||||
<hive>'JAR' { return '<hive>JAR'; }
|
||||
<hive>'JSONFILE' { return '<hive>JSONFILE'; }
|
||||
<hive>'KEY' { return '<hive>KEY'; }
|
||||
<hive>'KEYS' { return '<hive>KEYS'; }
|
||||
<hive>'LINES' { return '<hive>LINES'; }
|
||||
<hive>'LOAD' { parser.determineCase(yytext); return '<hive>LOAD'; }
|
||||
<hive>'LOCATION' { this.begin('hdfs'); return '<hive>LOCATION'; }
|
||||
<hive>'LOCK' { return '<hive>LOCK'; }
|
||||
<hive>'LOCKS' { return '<hive>LOCKS'; }
|
||||
<hive>'MATCHED' { return '<hive>MATCHED'; }
|
||||
<hive>'MERGE' { return '<hive>MERGE'; }
|
||||
<hive>'METADATA' { return '<hive>METADATA'; }
|
||||
<hive>'MINUTE' { return '<hive>MINUTE'; }
|
||||
<hive>'MONTH' { return '<hive>MONTH'; }
|
||||
<hive>'MSCK' { return '<hive>MSCK'; }
|
||||
<hive>'NORELY' { return '<hive>NORELY'; }
|
||||
<hive>'NOSCAN' { return '<hive>NOSCAN'; }
|
||||
<hive>'NOVALIDATE' { return '<hive>NOVALIDATE'; }
|
||||
<hive>'NO_DROP' { return '<hive>NO_DROP'; }
|
||||
<hive>'OFFLINE' { return '<hive>OFFLINE'; }
|
||||
<hive>'ORC' { return '<hive>ORC'; }
|
||||
<hive>'OUTPUTFORMAT' { return '<hive>OUTPUTFORMAT'; }
|
||||
<hive>'OVERWRITE' { return '<hive>OVERWRITE'; }
|
||||
<hive>OVERWRITE\s+DIRECTORY { this.begin('hdfs'); return '<hive>OVERWRITE_DIRECTORY'; }
|
||||
<hive>'OWNER' { return '<hive>OWNER'; }
|
||||
<hive>'PARQUET' { return '<hive>PARQUET'; }
|
||||
<hive>'PARTITIONED' { return '<hive>PARTITIONED'; }
|
||||
<hive>'PARTITIONS' { return '<hive>PARTITIONS'; }
|
||||
<hive>'PERCENT' { return '<hive>PERCENT'; }
|
||||
<hive>'PRIVILEGES' { return '<hive>PRIVILEGES'; }
|
||||
<hive>'PURGE' { return '<hive>PURGE'; }
|
||||
<hive>'QUARTER' { return '<hive>QUARTER'; }
|
||||
<hive>'RCFILE' { return '<hive>RCFILE'; }
|
||||
<hive>'REBUILD' { return '<hive>REBUILD'; }
|
||||
<hive>'RELOAD' { parser.determineCase(yytext); return '<hive>RELOAD'; }
|
||||
<hive>'RELY' { return '<hive>RELY'; }
|
||||
<hive>'REPAIR' { return '<hive>REPAIR'; }
|
||||
<hive>'REPLICATION' { return '<hive>REPLICATION'; }
|
||||
<hive>'RECOVER' { return '<hive>RECOVER'; }
|
||||
<hive>'RENAME' { return '<hive>RENAME'; }
|
||||
<hive>'REPLACE' { return '<hive>REPLACE'; }
|
||||
<hive>'RESTRICT' { return '<hive>RESTRICT'; }
|
||||
<hive>'ROLE' { return '<hive>ROLE'; }
|
||||
<hive>'ROLES' { return '<hive>ROLES'; }
|
||||
<hive>'SECOND' { return '<hive>SECOND'; }
|
||||
<hive>'SCHEMA' { return '<hive>SCHEMA'; }
|
||||
<hive>'SCHEMAS' { return '<hive>SCHEMAS'; }
|
||||
<hive>'SEQUENCEFILE' { return '<hive>SEQUENCEFILE'; }
|
||||
<hive>'SERDE' { return '<hive>SERDE'; }
|
||||
<hive>'SERDEPROPERTIES' { return '<hive>SERDEPROPERTIES'; }
|
||||
<hive>'SETS' { return '<hive>SETS'; }
|
||||
<hive>'SHOW' { parser.determineCase(yytext); return '<hive>SHOW'; }
|
||||
<hive>'SHOW_DATABASE' { return '<hive>SHOW_DATABASE'; }
|
||||
<hive>'SKEWED' { return '<hive>SKEWED'; }
|
||||
<hive>'SKEWED LOCATION' { return '<hive>SKEWED_LOCATION'; } // Hack to prevent hdfs lexer state
|
||||
<hive>'SORT' { return '<hive>SORT'; }
|
||||
<hive>'SORTED' { return '<hive>SORTED'; }
|
||||
<hive>'STATISTICS' { return '<hive>STATISTICS'; }
|
||||
<hive>'STORED' { return '<hive>STORED'; }
|
||||
<hive>STORED\s+AS\s+DIRECTORIES { return '<hive>STORED_AS_DIRECTORIES'; }
|
||||
<hive>'STRING' { return '<hive>STRING'; }
|
||||
<hive>'STRUCT' { return 'STRUCT'; }
|
||||
<hive>'TABLES' { return '<hive>TABLES'; }
|
||||
<hive>'TABLESAMPLE' { return '<hive>TABLESAMPLE'; }
|
||||
<hive>'TBLPROPERTIES' { return '<hive>TBLPROPERTIES'; }
|
||||
<hive>'TEMPORARY' { return '<hive>TEMPORARY'; }
|
||||
<hive>'TERMINATED' { return '<hive>TERMINATED'; }
|
||||
<hive>'TEXTFILE' { return '<hive>TEXTFILE'; }
|
||||
<hive>'TINYINT' { return '<hive>TINYINT'; }
|
||||
<hive>'TOUCH' { return '<hive>TOUCH'; }
|
||||
<hive>'TRANSACTIONAL' { return '<hive>TRANSACTIONAL'; }
|
||||
<hive>'TRANSACTIONS' { return '<hive>TRANSACTIONS'; }
|
||||
<hive>'UNARCHIVE' { return '<hive>UNARCHIVE'; }
|
||||
<hive>'UNIONTYPE' { return '<hive>UNIONTYPE'; }
|
||||
<hive>'USE' { parser.determineCase(yytext); return '<hive>USE'; }
|
||||
<hive>'VIEW' { return '<hive>VIEW'; }
|
||||
<hive>'WAIT' { return '<hive>WAIT'; }
|
||||
<hive>'WEEK' { return '<hive>WEEK'; }
|
||||
<hive>'WINDOW' { return '<hive>WINDOW'; }
|
||||
<hive>'WITH' { parser.determineCase(yytext); parser.addStatementTypeLocation('WITH', yylloc); return '<hive>WITH'; }
|
||||
<hive>'YEAR' { return '<hive>YEAR'; }
|
||||
|
||||
<hive>'.' { return '<hive>.'; }
|
||||
<hive>'[' { return '<hive>['; }
|
||||
<hive>']' { return '<hive>]'; }
|
||||
|
||||
// Reserved Keywords
|
||||
<impala>'ADD' { return '<impala>ADD'; }
|
||||
<impala>'AGGREGATE' { return '<impala>AGGREGATE'; }
|
||||
<impala>'ALLOCATE' { return '<impala>ALLOCATE'; }
|
||||
<impala>'ANALYTIC' { return '<impala>ANALYTIC'; }
|
||||
<impala>'ANTI' { return '<impala>ANTI'; }
|
||||
<impala>'ANY' { return '<impala>ANY'; }
|
||||
<impala>'ARE' { return '<impala>ARE'; }
|
||||
<impala>'ARRAY_AGG' { return '<impala>ARRAY_AGG'; }
|
||||
<impala>'ARRAY_MAX_CARDINALITY' { return '<impala>ARRAY_MAX_CARDINALITY'; }
|
||||
<impala>'ASENSITIVE' { return '<impala>ASENSITIVE'; }
|
||||
<impala>'ASYMMETRIC' { return '<impala>ASYMMETRIC'; }
|
||||
<impala>'AT' { return '<impala>AT'; }
|
||||
<impala>'ATOMIC' { return '<impala>ATOMIC'; }
|
||||
<impala>'AUTHORIZATION' { return '<impala>AUTHORIZATION'; }
|
||||
<impala>'AVRO' { return '<impala>AVRO'; }
|
||||
<impala>'BEGIN_FRAME' { return '<impala>BEGIN_FRAME'; }
|
||||
<impala>'BEGIN_PARTITION' { return '<impala>BEGIN_PARTITION'; }
|
||||
<impala>'BLOB' { return '<impala>BLOB'; }
|
||||
<impala>'BLOCK_SIZE' { return '<impala>BLOCK_SIZE'; }
|
||||
<impala>'BOTH' { return '<impala>BOTH'; }
|
||||
<impala>'CACHED' { return '<impala>CACHED'; }
|
||||
<impala>'CALLED' { return '<impala>CALLED'; }
|
||||
<impala>'CARDINALITY' { return '<impala>CARDINALITY'; }
|
||||
<impala>'CASCADE' { return '<impala>CASCADE'; }
|
||||
<impala>'CASCADED' { return '<impala>CASCADED'; }
|
||||
<impala>'CHANGE' { return '<impala>CHANGE'; }
|
||||
<impala>'CHARACTER' { return '<impala>CHARACTER'; }
|
||||
<impala>'CLOB' { return '<impala>CLOB'; }
|
||||
<impala>'CLOSE_FN' { return '<impala>CLOSE_FN'; }
|
||||
<impala>'COLLATE' { return '<impala>COLLATE'; }
|
||||
<impala>'COLLECT' { return '<impala>COLLECT'; }
|
||||
<impala>'COLUMN' { return '<impala>COLUMN'; }
|
||||
<impala>'COLUMNS' { return '<impala>COLUMNS'; }
|
||||
<impala>'COMMENT' { parser.determineCase(yytext); return '<impala>COMMENT'; }
|
||||
<impala>'COMMIT' { return '<impala>COMMIT'; }
|
||||
<impala>'COMPRESSION' { return '<impala>COMPRESSION'; }
|
||||
<impala>'COMPUTE' { parser.determineCase(yytext); return '<impala>COMPUTE'; }
|
||||
<impala>'CONDITION' { return '<impala>CONDITION'; }
|
||||
<impala>'CONNECT' { return '<impala>CONNECT'; }
|
||||
<impala>'CONSTRAINT' { return '<impala>CONSTRAINT'; }
|
||||
<impala>'CONTAINS' { return '<impala>CONTAINS'; }
|
||||
<impala>'CONVERT' { return '<impala>CONVERT'; }
|
||||
<impala>'COPY' { return '<impala>COPY'; }
|
||||
<impala>'CORR' { return '<impala>CORR'; }
|
||||
<impala>'CORRESPONDING' { return '<impala>CORRESPONDING'; }
|
||||
<impala>'COVAR_POP' { return '<impala>COVAR_POP'; }
|
||||
<impala>'COVAR_SAMP' { return '<impala>COVAR_SAMP'; }
|
||||
<impala>'CREATE' { parser.determineCase(yytext); parser.addStatementTypeLocation('CREATE', yylloc, yy.lexer.upcomingInput()); return '<impala>CREATE'; }
|
||||
<impala>'CUBE' { return '<impala>CUBE'; }
|
||||
<impala>'CURRENT' { return '<impala>CURRENT'; }
|
||||
<impala>'CURRENT_DATE' { return '<impala>CURRENT_DATE'; }
|
||||
<impala>'CURRENT_DEFAULT_TRANSFORM_GROUP' { return '<impala>CURRENT_DEFAULT_TRANSFORM_GROUP'; }
|
||||
<impala>'CURRENT_PATH' { return '<impala>CURRENT_PATH'; }
|
||||
<impala>'CURRENT_ROLE' { return '<impala>CURRENT_ROLE'; }
|
||||
<impala>'CURRENT_ROW' { return '<impala>CURRENT_ROW'; }
|
||||
<impala>'CURRENT_SCHEMA' { return '<impala>CURRENT_SCHEMA'; }
|
||||
<impala>'CURRENT_TIME' { return '<impala>CURRENT_TIME'; }
|
||||
<impala>'CURRENT_TRANSFORM_GROUP_FOR_TYPE' { return '<impala>CURRENT_TRANSFORM_GROUP_FOR_TYPE'; }
|
||||
<impala>'CURSOR' { return '<impala>CURSOR'; }
|
||||
<impala>'CYCLE' { return '<impala>CYCLE'; }
|
||||
<impala>'DATA' { return '<impala>DATA'; }
|
||||
<impala>'DATABASES' { return '<impala>DATABASES'; }
|
||||
<impala>'DEALLOCATE' { return '<impala>DEALLOCATE'; }
|
||||
<impala>'DEC' { return '<impala>DEC'; }
|
||||
<impala>'DECFLOAT' { return '<impala>DECFLOAT'; }
|
||||
<impala>'DECLARE' { return '<impala>DECLARE'; }
|
||||
<impala>'DEFINE' { return '<impala>DEFINE'; }
|
||||
<impala>'DELETE' { return '<impala>DELETE'; }
|
||||
<impala>'DELIMITED' { return '<impala>DELIMITED'; }
|
||||
<impala>'DEREF' { return '<impala>DEREF'; }
|
||||
<impala>'DESCRIBE' { parser.determineCase(yytext); parser.addStatementTypeLocation('DESCRIBE', yylloc); return '<impala>DESCRIBE'; }
|
||||
<impala>'DETERMINISTIC' { return '<impala>DETERMINISTIC'; }
|
||||
<impala>'DISCONNECT' { return '<impala>DISCONNECT'; }
|
||||
<impala>'DYNAMIC' { return '<impala>DYNAMIC'; }
|
||||
<impala>'EACH' { return '<impala>EACH'; }
|
||||
<impala>'ELEMENT' { return '<impala>ELEMENT'; }
|
||||
<impala>'EMPTY' { return '<impala>EMPTY'; }
|
||||
<impala>'ENCODING' { return '<impala>ENCODING'; }
|
||||
<impala>'END_FRAME' { return '<impala>END_FRAME'; }
|
||||
<impala>'END_PARTITION' { return '<impala>END_PARTITION'; }
|
||||
<impala>'EQUALS' { return '<impala>EQUALS'; }
|
||||
<impala>'ESCAPE' { return '<impala>ESCAPE'; }
|
||||
<impala>'ESCAPED' { return '<impala>ESCAPED'; }
|
||||
<impala>'EVERY' { return '<impala>EVERY'; }
|
||||
<impala>'EXCEPT' { return '<impala>EXCEPT'; }
|
||||
<impala>'EXEC' { return '<impala>EXEC'; }
|
||||
<impala>'EXECUTE' { return '<impala>EXECUTE'; }
|
||||
<impala>'EXPLAIN' { parser.determineCase(yytext); parser.addStatementTypeLocation('EXPLAIN', yylloc); return '<impala>EXPLAIN'; }
|
||||
<impala>'EXTENDED' { return '<impala>EXTENDED'; }
|
||||
<impala>'EXTERNAL' { return '<impala>EXTERNAL'; }
|
||||
<impala>'FETCH' { return '<impala>FETCH'; }
|
||||
<impala>'FIELDS' { return '<impala>FIELDS'; }
|
||||
<impala>'FILEFORMAT' { return '<impala>FILEFORMAT'; }
|
||||
<impala>'FILES' { return '<impala>FILES'; }
|
||||
<impala>'FILTER' { return '<impala>FILTER'; }
|
||||
<impala>'FINALIZE_FN' { return '<impala>FINALIZE_FN'; }
|
||||
<impala>'FIRST' { return '<impala>FIRST'; }
|
||||
<impala>'FOR' { return '<impala>FOR'; }
|
||||
<impala>'FOREIGN' { return '<impala>FOREIGN'; }
|
||||
<impala>'FORMAT' { return '<impala>FORMAT'; }
|
||||
<impala>'FORMATTED' { return '<impala>FORMATTED'; }
|
||||
<impala>'FRAME_ROW' { return '<impala>FRAME_ROW'; }
|
||||
<impala>'FREE' { return '<impala>FREE'; }
|
||||
<impala>'FUNCTION' { return '<impala>FUNCTION'; }
|
||||
<impala>'FUNCTIONS' { return '<impala>FUNCTIONS'; }
|
||||
<impala>'FUSION' { return '<impala>FUSION'; }
|
||||
<impala>'GET' { return '<impala>GET'; }
|
||||
<impala>'GLOBAL' { return '<impala>GLOBAL'; }
|
||||
<impala>'GRANT' { parser.determineCase(yytext); parser.addStatementTypeLocation('GRANT', yylloc); return '<impala>GRANT'; }
|
||||
<impala>'GROUP' { return '<impala>GROUP'; }
|
||||
<impala>'GROUPING' { return '<impala>GROUPING'; }
|
||||
<impala>'GROUPS' { return '<impala>GROUPS'; }
|
||||
<impala>'HASH' { return '<impala>HASH'; }
|
||||
<impala>'HOLD' { return '<impala>HOLD'; }
|
||||
<impala>'IGNORE' { return '<impala>IGNORE'; }
|
||||
<impala>'ILIKE' { return '<impala>ILIKE'; }
|
||||
<impala>'INCREMENTAL' { return '<impala>INCREMENTAL'; }
|
||||
<impala>'INDICATOR' { return '<impala>INDICATOR'; }
|
||||
<impala>'INIT_FN' { return '<impala>INIT_FN'; }
|
||||
<impala>'INITIAL' { return '<impala>INITIAL'; }
|
||||
<impala>'INOUT' { return '<impala>INOUT'; }
|
||||
<impala>'INPATH' { this.begin('hdfs'); return '<impala>INPATH'; }
|
||||
<impala>'INSENSITIVE' { return '<impala>INSENSITIVE'; }
|
||||
<impala>'INSERT' { parser.determineCase(yytext); parser.addStatementTypeLocation('INSERT', yylloc); return '<impala>INSERT'; }
|
||||
<impala>'INTERMEDIATE' { return '<impala>INTERMEDIATE'; }
|
||||
<impala>'INTERSECT' { return '<impala>INTERSECT'; }
|
||||
<impala>'INTERSECTION' { return '<impala>INTERSECTION'; }
|
||||
<impala>'INTERVAL' { return '<impala>INTERVAL'; }
|
||||
<impala>'INVALIDATE' { parser.determineCase(yytext); parser.addStatementTypeLocation('INVALIDATE', yylloc, yy.lexer.upcomingInput()); return '<impala>INVALIDATE'; }
|
||||
<impala>'IREGEXP' { return '<impala>IREGEXP'; }
|
||||
<impala>'JSON_ARRAY' { return '<impala>JSON_ARRAY'; }
|
||||
<impala>'JSON_ARRAYAGG' { return '<impala>JSON_ARRAYAGG'; }
|
||||
<impala>'JSON_EXISTS' { return '<impala>JSON_EXISTS'; }
|
||||
<impala>'JSON_OBJECT' { return '<impala>JSON_OBJECT'; }
|
||||
<impala>'JSON_OBJECTAGG' { return '<impala>JSON_OBJECTAGG'; }
|
||||
<impala>'JSON_QUERY' { return '<impala>JSON_QUERY'; }
|
||||
<impala>'JSON_TABLE' { return '<impala>JSON_TABLE'; }
|
||||
<impala>'JSON_TABLE_PRIMITIVE' { return '<impala>JSON_TABLE_PRIMITIVE'; }
|
||||
<impala>'JSON_VALUE' { return '<impala>JSON_VALUE'; }
|
||||
<impala>'KEY' { return '<impala>KEY'; }
|
||||
<impala>'KUDU' { return '<impala>KUDU'; }
|
||||
<impala>'LARGE' { return '<impala>LARGE'; }
|
||||
<impala>'LAST' { return '<impala>LAST'; }
|
||||
<impala>'LATERAL' { return '<impala>LATERAL'; }
|
||||
<impala>'LEADING' { return '<impala>LEADING'; }
|
||||
<impala>LIKE\s+PARQUET { this.begin('hdfs'); return '<impala>LIKE_PARQUET'; }
|
||||
<impala>'LIKE_REGEX' { return '<impala>LIKE_REGEX'; }
|
||||
<impala>'LIMIT' { return '<impala>LIMIT'; }
|
||||
<impala>'LINES' { return '<impala>LINES'; }
|
||||
<impala>'LISTAGG' { return '<impala>LISTAGG'; }
|
||||
<impala>'LOAD' { parser.determineCase(yytext); parser.addStatementTypeLocation('LOAD', yylloc, yy.lexer.upcomingInput()); return '<impala>LOAD'; }
|
||||
<impala>'LOCAL' { return '<impala>LOCAL'; }
|
||||
<impala>'LOCALTIMESTAMP' { return '<impala>LOCALTIMESTAMP'; }
|
||||
<impala>'LOCATION' { this.begin('hdfs'); return '<impala>LOCATION'; }
|
||||
<impala>'MATCH' { return '<impala>MATCH'; }
|
||||
<impala>'MATCH_NUMBER' { return '<impala>MATCH_NUMBER'; }
|
||||
<impala>'MATCH_RECOGNIZE' { return '<impala>MATCH_RECOGNIZE'; }
|
||||
<impala>'MATCHES' { return '<impala>MATCHES'; }
|
||||
<impala>'MERGE' { return '<impala>MERGE'; }
|
||||
<impala>'MERGE_FN' { return '<impala>MERGE_FN'; }
|
||||
<impala>'METADATA' { return '<impala>METADATA'; }
|
||||
<impala>'METHOD' { return '<impala>METHOD'; }
|
||||
<impala>'MODIFIES' { return '<impala>MODIFIES'; }
|
||||
<impala>'MULTISET' { return '<impala>MULTISET'; }
|
||||
<impala>'NATIONAL' { return '<impala>NATIONAL'; }
|
||||
<impala>'NATURAL' { return '<impala>NATURAL'; }
|
||||
<impala>'NCHAR' { return '<impala>NCHAR'; }
|
||||
<impala>'NCLOB' { return '<impala>NCLOB'; }
|
||||
<impala>'NO' { return '<impala>NO'; }
|
||||
<impala>'NONE' { return '<impala>NONE'; }
|
||||
<impala>'NORMALIZE' { return '<impala>NORMALIZE'; }
|
||||
<impala>'NTH_VALUE' { return '<impala>NTH_VALUE'; }
|
||||
<impala>'NULLS' { return '<impala>NULLS'; }
|
||||
<impala>'NUMERIC' { return '<impala>NUMERIC'; }
|
||||
<impala>'OCCURRENCES_REGEX' { return '<impala>OCCURRENCES_REGEX'; }
|
||||
<impala>'OCTET_LENGTH' { return '<impala>OCTET_LENGTH'; }
|
||||
<impala>'OF' { return '<impala>OF'; }
|
||||
<impala>'OFFSET' { return '<impala>OFFSET'; }
|
||||
<impala>'OMIT' { return '<impala>OMIT'; }
|
||||
<impala>'ONE' { return '<impala>ONE'; }
|
||||
<impala>'ONLY' { return '<impala>ONLY'; }
|
||||
<impala>'ORC' { return '<impala>ORC'; }
|
||||
<impala>'OUT' { return '<impala>OUT'; }
|
||||
<impala>'OVER' { return '<impala>OVER'; }
|
||||
<impala>'OVERLAPS' { return '<impala>OVERLAPS'; }
|
||||
<impala>'OVERLAY' { return '<impala>OVERLAY'; }
|
||||
<impala>'OVERWRITE' { return '<impala>OVERWRITE'; }
|
||||
<impala>'PARQUET' { return '<impala>PARQUET'; }
|
||||
<impala>PARTITION\s+VALUE\s { return '<impala>PARTITION_VALUE'; }
|
||||
<impala>'PARTITIONED' { return '<impala>PARTITIONED'; }
|
||||
<impala>'PARTITIONS' { return '<impala>PARTITIONS'; }
|
||||
<impala>'PATTERN' { return '<impala>PATTERN'; }
|
||||
<impala>'PER' { return '<impala>PER'; }
|
||||
<impala>'PERCENT' { return '<impala>PERCENT'; }
|
||||
<impala>'PERCENTILE_CONT' { return '<impala>PERCENTILE_CONT'; }
|
||||
<impala>'PERCENTILE_DISC' { return '<impala>PERCENTILE_DISC'; }
|
||||
<impala>'PORTION' { return '<impala>PORTION'; }
|
||||
<impala>'POSITION' { return '<impala>POSITION'; }
|
||||
<impala>'POSITION_REGEX' { return '<impala>POSITION_REGEX'; }
|
||||
<impala>'PRECEDES' { return '<impala>PRECEDES'; }
|
||||
<impala>'PREPARE' { return '<impala>PREPARE'; }
|
||||
<impala>'PREPARE_FN' { return '<impala>PREPARE_FN'; }
|
||||
<impala>'PRIMARY' { return '<impala>PRIMARY'; }
|
||||
<impala>'PROCEDURE' { return '<impala>PROCEDURE'; }
|
||||
<impala>'PTF' { return '<impala>PTF'; }
|
||||
<impala>'RANGE' { return '<impala>RANGE'; }
|
||||
<impala>'RCFILE' { return '<impala>RCFILE'; }
|
||||
<impala>'READS' { return '<impala>READS'; }
|
||||
<impala>'REAL' { return '<impala>REAL'; }
|
||||
<impala>'RECOVER' { return '<impala>RECOVER'; }
|
||||
<impala>'RECURSIVE' { return '<impala>RECURSIVE'; }
|
||||
<impala>'REF' { return '<impala>REF'; }
|
||||
<impala>'REFERENCES' { return '<impala>REFERENCES'; }
|
||||
<impala>'REFERENCING' { return '<impala>REFERENCING'; }
|
||||
<impala>'REFRESH' { parser.determineCase(yytext); parser.addStatementTypeLocation('REFRESH', yylloc); return '<impala>REFRESH'; }
|
||||
<impala>'REGR_AVGX' { return '<impala>REGR_AVGX'; }
|
||||
<impala>'REGR_AVGY' { return '<impala>REGR_AVGY'; }
|
||||
<impala>'REGR_COUNT' { return '<impala>REGR_COUNT'; }
|
||||
<impala>'REGR_INTERCEPT' { return '<impala>REGR_INTERCEPT'; }
|
||||
<impala>'REGR_R2REGR_SLOPE' { return '<impala>REGR_R2REGR_SLOPE'; }
|
||||
<impala>'REGR_SXX' { return '<impala>REGR_SXX'; }
|
||||
<impala>'REGR_SXY' { return '<impala>REGR_SXY'; }
|
||||
<impala>'REGR_SYY' { return '<impala>REGR_SYY'; }
|
||||
<impala>'RELEASE' { return '<impala>RELEASE'; }
|
||||
<impala>'RENAME' { return '<impala>RENAME'; }
|
||||
<impala>'REPEATABLE' { return '<impala>REPEATABLE'; }
|
||||
<impala>'REPLACE' { return '<impala>REPLACE'; }
|
||||
<impala>'REPLICATION' { return '<impala>REPLICATION'; }
|
||||
<impala>'RESTRICT' { return '<impala>RESTRICT'; }
|
||||
<impala>'RETURNS' { return '<impala>RETURNS'; }
|
||||
<impala>'REVOKE' { parser.determineCase(yytext); parser.addStatementTypeLocation('REVOKE', yylloc); return '<impala>REVOKE'; }
|
||||
<impala>'ROLE' { return '<impala>ROLE'; }
|
||||
<impala>'ROLES' { return '<impala>ROLES'; }
|
||||
<impala>'ROLLBACK' { return '<impala>ROLLBACK'; }
|
||||
<impala>'ROLLUP' { return '<impala>ROLLUP'; }
|
||||
<impala>'RUNNING' { return '<impala>RUNNING'; }
|
||||
<impala>'SAVEPOINT' { return '<impala>SAVEPOINT'; }
|
||||
<impala>'SCHEMAS' { return '<impala>SCHEMAS'; }
|
||||
<impala>'SCOPE' { return '<impala>SCOPE'; }
|
||||
<impala>'SCROLL' { return '<impala>SCROLL'; }
|
||||
<impala>'SEARCH' { return '<impala>SEARCH'; }
|
||||
<impala>'SEEK' { return '<impala>SEEK'; }
|
||||
<impala>'SENSITIVE' { return '<impala>SENSITIVE'; }
|
||||
<impala>'SEQUENCEFILE' { return '<impala>SEQUENCEFILE'; }
|
||||
<impala>'SERDEPROPERTIES' { return '<impala>SERDEPROPERTIES'; }
|
||||
<impala>'SERIALIZE_FN' { return '<impala>SERIALIZE_FN'; }
|
||||
<impala>'SERVER' { return '<impala>SERVER'; }
|
||||
<impala>'SIMILAR' { return '<impala>SIMILAR'; }
|
||||
<impala>'SKIP' { return '<impala>SKIP'; }
|
||||
<impala>'SOME' { return '<impala>SOME'; }
|
||||
<impala>'SORT' { return '<impala>SORT'; }
|
||||
<impala>'SPECIFIC' { return '<impala>SPECIFIC'; }
|
||||
<impala>'SPECIFICTYPE' { return '<impala>SPECIFICTYPE'; }
|
||||
<impala>'SQLEXCEPTION' { return '<impala>SQLEXCEPTION'; }
|
||||
<impala>'SQLSTATE' { return '<impala>SQLSTATE'; }
|
||||
<impala>'SQLWARNING' { return '<impala>SQLWARNING'; }
|
||||
<impala>'STATIC' { return '<impala>STATIC'; }
|
||||
<impala>'STATS' { return '<impala>STATS'; }
|
||||
<impala>'STORED' { return '<impala>STORED'; }
|
||||
<impala>'STRAIGHT_JOIN' { return '<impala>STRAIGHT_JOIN'; }
|
||||
<impala>'SUBMULTISET' { return '<impala>SUBMULTISET'; }
|
||||
<impala>'SUBSET' { return '<impala>SUBSET'; }
|
||||
<impala>'SUBSTRING_REGEX' { return '<impala>SUBSTRING_REGEX'; }
|
||||
<impala>'SUCCEEDS' { return '<impala>SUCCEEDS'; }
|
||||
<impala>'SYMBOL' { return '<impala>SYMBOL'; }
|
||||
<impala>'SYMMETRIC' { return '<impala>SYMMETRIC'; }
|
||||
<impala>'SYSTEM_TIME' { return '<impala>SYSTEM_TIME'; }
|
||||
<impala>'SYSTEM_USER' { return '<impala>SYSTEM_USER'; }
|
||||
<impala>'TABLE' { return '<impala>TABLE'; }
|
||||
<impala>'TABLES' { return '<impala>TABLES'; }
|
||||
<impala>'TABLESAMPLE' { return '<impala>TABLESAMPLE'; }
|
||||
<impala>'TBLPROPERTIES' { return '<impala>TBLPROPERTIES'; }
|
||||
<impala>'TERMINATED' { return '<impala>TERMINATED'; }
|
||||
<impala>'TEXTFILE' { return '<impala>TEXTFILE'; }
|
||||
<impala>'TIMEZONE_HOUR' { return '<impala>TIMEZONE_HOUR'; }
|
||||
<impala>'TIMEZONE_MINUTE' { return '<impala>TIMEZONE_MINUTE'; }
|
||||
<impala>'TRAILING' { return '<impala>TRAILING'; }
|
||||
<impala>'TRANSLATE_REGEX' { return '<impala>TRANSLATE_REGEX'; }
|
||||
<impala>'TRANSLATION' { return '<impala>TRANSLATION'; }
|
||||
<impala>'TREAT' { return '<impala>TREAT'; }
|
||||
<impala>'TRIGGER' { return '<impala>TRIGGER'; }
|
||||
<impala>'TRIM_ARRAY' { return '<impala>TRIM_ARRAY'; }
|
||||
<impala>'UESCAPE' { return '<impala>UESCAPE'; }
|
||||
<impala>'UNCACHED' { return '<impala>UNCACHED'; }
|
||||
<impala>'UNIQUE' { return '<impala>UNIQUE'; }
|
||||
<impala>'UNKNOWN' { return '<impala>UNKNOWN'; }
|
||||
<impala>'UNNEST' { return '<impala>UNNEST'; }
|
||||
<impala>'UPDATE_FN' { return '<impala>UPDATE_FN'; }
|
||||
<impala>'UPSERT' { parser.determineCase(yytext); parser.addStatementTypeLocation('UPSERT', yylloc); return '<impala>UPSERT'; }
|
||||
<impala>'URI' { return '<impala>URI'; }
|
||||
<impala>'USER' { return '<impala>USER'; }
|
||||
<impala>'USING' { return '<impala>USING'; }
|
||||
<impala>'VALUE_OF' { return '<impala>VALUE_OF'; }
|
||||
<impala>'VARBINARY' { return '<impala>VARBINARY'; }
|
||||
<impala>'VARCHAR' { return '<impala>VARCHAR'; }
|
||||
<impala>'VARYING' { return '<impala>VARYING'; }
|
||||
<impala>'VERSIONING' { return '<impala>VERSIONING'; }
|
||||
<impala>'WHENEVER' { return '<impala>WHENEVER'; }
|
||||
<impala>'WIDTH_BUCKET' { return '<impala>WIDTH_BUCKET'; }
|
||||
<impala>'WINDOW' { return '<impala>WINDOW'; }
|
||||
<impala>'WITH' { parser.determineCase(yytext); parser.addStatementTypeLocation('WITH', yylloc); return '<impala>WITH'; }
|
||||
<impala>'WITHIN' { return '<impala>WITHIN'; }
|
||||
<impala>'WITHOUT' { return '<impala>WITHOUT'; }
|
||||
|
||||
// Non-reserved Keywords
|
||||
<impala>'ARRAY' { return 'ARRAY'; }
|
||||
<impala>'DEFAULT' { return '<impala>DEFAULT'; }
|
||||
<impala>'MAP' { return 'MAP'; }
|
||||
<impala>'OWNER' { return '<impala>OWNER'; }
|
||||
<impala>'STRUCT' { return 'STRUCT'; }
|
||||
<impala>\[BROADCAST\] { return '<impala>BROADCAST'; }
|
||||
<impala>\[NOSHUFFLE\] { return '<impala>NOSHUFFLE'; }
|
||||
<impala>\[SHUFFLE\] { return '<impala>SHUFFLE'; }
|
||||
|
||||
<impala>'...' { return '<impala>...'; }
|
||||
<impala>'.' { return '<impala>.'; }
|
||||
<impala>'[' { return '<impala>['; }
|
||||
<impala>']' { return '<impala>]'; }
|
||||
|
||||
<between>'AND' { this.popState(); return 'BETWEEN_AND'; }
|
||||
|
||||
// Reserved Keywords
|
||||
'ALL' { return 'ALL'; }
|
||||
'ALTER' { parser.determineCase(yytext); parser.addStatementTypeLocation('ALTER', yylloc, yy.lexer.upcomingInput()); return 'ALTER'; }
|
||||
'AND' { return 'AND'; }
|
||||
'AS' { return 'AS'; }
|
||||
'ASC' { return 'ASC'; }
|
||||
'BETWEEN' { this.begin('between'); return 'BETWEEN'; }
|
||||
'BIGINT' { return 'BIGINT'; }
|
||||
'BOOLEAN' { return 'BOOLEAN'; }
|
||||
'BY' { return 'BY'; }
|
||||
'CASE' { return 'CASE'; }
|
||||
'CHAR' { return 'CHAR'; }
|
||||
'CREATE' { parser.determineCase(yytext); return 'CREATE'; }
|
||||
'CROSS' { return 'CROSS'; }
|
||||
'CURRENT' { return 'CURRENT'; }
|
||||
'DATABASE' { return 'DATABASE'; }
|
||||
'DECIMAL' { return 'DECIMAL'; }
|
||||
'DISTINCT' { return 'DISTINCT'; }
|
||||
'DIV' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'DOUBLE' { return 'DOUBLE'; }
|
||||
'DESC' { return 'DESC'; }
|
||||
'DROP' { parser.determineCase(yytext); parser.addStatementTypeLocation('DROP', yylloc, yy.lexer.upcomingInput()); return 'DROP'; }
|
||||
'ELSE' { return 'ELSE'; }
|
||||
'END' { return 'END'; }
|
||||
'EXISTS' { parser.yy.correlatedSubQuery = true; return 'EXISTS'; }
|
||||
'FALSE' { return 'FALSE'; }
|
||||
'FLOAT' { return 'FLOAT'; }
|
||||
'FOLLOWING' { return 'FOLLOWING'; }
|
||||
'FROM' { parser.determineCase(yytext); return 'FROM'; }
|
||||
'FULL' { return 'FULL'; }
|
||||
'GROUP' { return 'GROUP'; }
|
||||
'HAVING' { return 'HAVING'; }
|
||||
'IF' { return 'IF'; }
|
||||
'IN' { return 'IN'; }
|
||||
'INNER' { return 'INNER'; }
|
||||
'INSERT' { return 'INSERT'; }
|
||||
'INT' { return 'INT'; }
|
||||
'INTO' { return 'INTO'; }
|
||||
'IS' { return 'IS'; }
|
||||
'JOIN' { return 'JOIN'; }
|
||||
'LEFT' { return 'LEFT'; }
|
||||
'LIKE' { return 'LIKE'; }
|
||||
'LIMIT' { return 'LIMIT'; }
|
||||
'NOT' { return 'NOT'; }
|
||||
'NULL' { return 'NULL'; }
|
||||
'ON' { return 'ON'; }
|
||||
'OPTION' { return 'OPTION'; }
|
||||
'OR' { return 'OR'; }
|
||||
'ORDER' { return 'ORDER'; }
|
||||
'OUTER' { return 'OUTER'; }
|
||||
'PARTITION' { return 'PARTITION'; }
|
||||
'PRECEDING' { return 'PRECEDING'; }
|
||||
'PURGE' { return 'PURGE'; }
|
||||
'RANGE' { return 'RANGE'; }
|
||||
'REGEXP' { return 'REGEXP'; }
|
||||
'RIGHT' { return 'RIGHT'; }
|
||||
'RLIKE' { return 'RLIKE'; }
|
||||
'ROW' { return 'ROW'; }
|
||||
'ROWS' { return 'ROWS'; }
|
||||
'SCHEMA' { return 'SCHEMA'; }
|
||||
'SELECT' { parser.determineCase(yytext); parser.addStatementTypeLocation('SELECT', yylloc); return 'SELECT'; }
|
||||
'SEMI' { return 'SEMI'; }
|
||||
'SET' { parser.determineCase(yytext); parser.addStatementTypeLocation('SET', yylloc); return 'SET'; }
|
||||
'SHOW' { parser.determineCase(yytext); parser.addStatementTypeLocation('SHOW', yylloc); return 'SHOW'; }
|
||||
'SMALLINT' { return 'SMALLINT'; }
|
||||
'STRING' { return 'STRING'; }
|
||||
'TABLE' { return 'TABLE'; }
|
||||
'THEN' { return 'THEN'; }
|
||||
'TIMESTAMP' { return 'TIMESTAMP'; }
|
||||
'TINYINT' { return 'TINYINT'; }
|
||||
'TO' { return 'TO'; }
|
||||
'TRUE' { return 'TRUE'; }
|
||||
'TRUNCATE' { parser.determineCase(yytext); parser.addStatementTypeLocation('TRUNCATE', yylloc, yy.lexer.upcomingInput()); return 'TRUNCATE'; }
|
||||
'UNBOUNDED' { return 'UNBOUNDED'; }
|
||||
'UPDATE' { parser.determineCase(yytext); return 'UPDATE'; }
|
||||
'USE' { parser.determineCase(yytext); parser.addStatementTypeLocation('USE', yylloc); return 'USE'; }
|
||||
'UNION' { return 'UNION'; }
|
||||
'VIEW' { return 'VIEW'; }
|
||||
'VARCHAR' { return 'VARCHAR'; } // Not in Impala
|
||||
'VALUES' { return 'VALUES'; }
|
||||
'WHEN' { return 'WHEN'; }
|
||||
'WHERE' { return 'WHERE'; }
|
||||
'WITH' { parser.determineCase(yytext); parser.addStatementTypeLocation('WITH', yylloc); return 'WITH'; }
|
||||
|
||||
// Non-reserved Keywords
|
||||
'OVER' { return 'OVER'; }
|
||||
'ROLE' { return 'ROLE'; }
|
||||
|
||||
// --- UDFs ---
|
||||
AVG\s*\( { yy.lexer.unput('('); yytext = 'avg'; parser.addFunctionLocation(yylloc, yytext); return 'AVG'; }
|
||||
CAST\s*\( { yy.lexer.unput('('); yytext = 'cast'; parser.addFunctionLocation(yylloc, yytext); return 'CAST'; }
|
||||
COUNT\s*\( { yy.lexer.unput('('); yytext = 'count'; parser.addFunctionLocation(yylloc, yytext); return 'COUNT'; }
|
||||
MAX\s*\( { yy.lexer.unput('('); yytext = 'max'; parser.addFunctionLocation(yylloc, yytext); return 'MAX'; }
|
||||
MIN\s*\( { yy.lexer.unput('('); yytext = 'min'; parser.addFunctionLocation(yylloc, yytext); return 'MIN'; }
|
||||
STDDEV_POP\s*\( { yy.lexer.unput('('); yytext = 'stddev_pop'; parser.addFunctionLocation(yylloc, yytext); return 'STDDEV_POP'; }
|
||||
STDDEV_SAMP\s*\( { yy.lexer.unput('('); yytext = 'stddev_samp'; parser.addFunctionLocation(yylloc, yytext); return 'STDDEV_SAMP'; }
|
||||
SUM\s*\( { yy.lexer.unput('('); yytext = 'sum'; parser.addFunctionLocation(yylloc, yytext); return 'SUM'; }
|
||||
VARIANCE\s*\( { yy.lexer.unput('('); yytext = 'variance'; parser.addFunctionLocation(yylloc, yytext); return 'VARIANCE'; }
|
||||
VAR_POP\s*\( { yy.lexer.unput('('); yytext = 'var_pop'; parser.addFunctionLocation(yylloc, yytext); return 'VAR_POP'; }
|
||||
VAR_SAMP\s*\( { yy.lexer.unput('('); yytext = 'var_samp'; parser.addFunctionLocation(yylloc, yytext); return 'VAR_SAMP'; }
|
||||
<hive>COLLECT_SET\s*\( { yy.lexer.unput('('); yytext = 'collect_set'; parser.addFunctionLocation(yylloc, yytext); return '<hive>COLLECT_SET'; }
|
||||
<hive>COLLECT_LIST\s*\( { yy.lexer.unput('('); yytext = 'collect_list'; parser.addFunctionLocation(yylloc, yytext); return '<hive>COLLECT_LIST'; }
|
||||
<hive>CORR\s*\( { yy.lexer.unput('('); yytext = 'corr'; parser.addFunctionLocation(yylloc, yytext); return '<hive>CORR'; }
|
||||
<hive>COVAR_POP\s*\( { yy.lexer.unput('('); yytext = 'covar_pop'; parser.addFunctionLocation(yylloc, yytext); return '<hive>COVAR_POP'; }
|
||||
<hive>COVAR_SAMP\s*\( { yy.lexer.unput('('); yytext = 'covar_samp'; parser.addFunctionLocation(yylloc, yytext); return '<hive>COVAR_SAMP'; }
|
||||
<hive>EXTRACT\s*\( { yy.lexer.unput('('); yytext = 'extract'; parser.addFunctionLocation(yylloc, yytext); return '<hive>EXTRACT'; }
|
||||
<hive>HISTOGRAM_NUMERIC\s*\( { yy.lexer.unput('('); yytext = 'histogram_numeric'; parser.addFunctionLocation(yylloc, yytext); return '<hive>HISTOGRAM_NUMERIC'; }
|
||||
<hive>NTILE\s*\( { yy.lexer.unput('('); yytext = 'ntile'; parser.addFunctionLocation(yylloc, yytext); return '<hive>NTILE'; }
|
||||
<hive>PERCENTILE\s*\( { yy.lexer.unput('('); yytext = 'percentile'; parser.addFunctionLocation(yylloc, yytext); return '<hive>PERCENTILE'; }
|
||||
<hive>PERCENTILE_APPROX\s*\( { yy.lexer.unput('('); yytext = 'percentile_approx'; parser.addFunctionLocation(yylloc, yytext); return '<hive>PERCENTILE_APPROX'; }
|
||||
<impala>APPX_MEDIAN\s*\( { yy.lexer.unput('('); yytext = 'appx_median'; parser.addFunctionLocation(yylloc, yytext); return '<impala>APPX_MEDIAN'; }
|
||||
<impala>EXTRACT\s*\( { yy.lexer.unput('('); yytext = 'extract'; parser.addFunctionLocation(yylloc, yytext); return '<impala>EXTRACT'; }
|
||||
<impala>GROUP_CONCAT\s*\( { yy.lexer.unput('('); yytext = 'group_concat'; parser.addFunctionLocation(yylloc, yytext); return '<impala>GROUP_CONCAT'; }
|
||||
<impala>NDV\s*\( { yy.lexer.unput('('); yytext = 'ndv'; parser.addFunctionLocation(yylloc, yytext); return '<impala>NDV'; }
|
||||
<impala>STDDEV\s*\( { yy.lexer.unput('('); yytext = 'stddev'; parser.addFunctionLocation(yylloc, yytext); return '<impala>STDDEV'; }
|
||||
<impala>VARIANCE_POP\s*\( { yy.lexer.unput('('); yytext = 'variance_pop'; parser.addFunctionLocation(yylloc, yytext); return '<impala>VARIANCE_POP'; }
|
||||
<impala>VARIANCE_SAMP\s*\( { yy.lexer.unput('('); yytext = 'variance_samp'; parser.addFunctionLocation(yylloc, yytext); return '<impala>VARIANCE_SAMP'; }
|
||||
|
||||
// Analytical functions
|
||||
CUME_DIST\s*\( { yy.lexer.unput('('); yytext = 'cume_dist'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
DENSE_RANK\s*\( { yy.lexer.unput('('); yytext = 'dense_rank'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
FIRST_VALUE\s*\( { yy.lexer.unput('('); yytext = 'first_value'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
LAG\s*\( { yy.lexer.unput('('); yytext = 'lag'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
LAST_VALUE\s*\( { yy.lexer.unput('('); yytext = 'last_value'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
LEAD\s*\( { yy.lexer.unput('('); yytext = 'lead'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
RANK\s*\( { yy.lexer.unput('('); yytext = 'rank'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
ROW_NUMBER\s*\( { yy.lexer.unput('('); yytext = 'row_number'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
<hive>CUME_DIST\s*\( { yy.lexer.unput('('); yytext = 'cume_dist'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
<hive>PERCENT_RANK\s*\( { yy.lexer.unput('('); yytext = 'percent_rank'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
<impala>NTILE\s*\( { yy.lexer.unput('('); yytext = 'ntile'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
<impala>PERCENT_RANK\s*\( { yy.lexer.unput('('); yytext = 'percent_rank'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
|
||||
<impala>SYSTEM\s*\( { yy.lexer.unput('('); yytext = 'system'; return '<impala>SYSTEM'; }
|
||||
|
||||
[0-9]+ { return 'UNSIGNED_INTEGER'; }
|
||||
[0-9]+(?:[YSL]|BD)? { return 'UNSIGNED_INTEGER'; }
|
||||
[0-9]+E { return 'UNSIGNED_INTEGER_E'; }
|
||||
[A-Za-z0-9_]+ { return 'REGULAR_IDENTIFIER'; }
|
||||
|
||||
<hdfs>'\u2020' { parser.yy.cursorFound = true; return 'CURSOR'; }
|
||||
<hdfs>'\u2021' { parser.yy.cursorFound = true; return 'PARTIAL_CURSOR'; }
|
||||
<hdfs>\s+['] { return 'HDFS_START_QUOTE'; }
|
||||
<hdfs>[^'\u2020\u2021]+ { parser.addFileLocation(yylloc, yytext); return 'HDFS_PATH'; }
|
||||
<hdfs>['] { this.popState(); return 'HDFS_END_QUOTE'; }
|
||||
<hdfs><<EOF>> { return 'EOF'; }
|
||||
|
||||
'&&' { return 'AND'; }
|
||||
'||' { return 'OR'; }
|
||||
|
||||
'=' { return '='; }
|
||||
'<' { return '<'; }
|
||||
'>' { return '>'; }
|
||||
'!=' { return 'COMPARISON_OPERATOR'; }
|
||||
'<=' { return 'COMPARISON_OPERATOR'; }
|
||||
'>=' { return 'COMPARISON_OPERATOR'; }
|
||||
'<>' { return 'COMPARISON_OPERATOR'; }
|
||||
'<=>' { return 'COMPARISON_OPERATOR'; }
|
||||
|
||||
'-' { return '-'; }
|
||||
'*' { return '*'; }
|
||||
'+' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'/' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'%' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'|' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'^' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'&' { return 'ARITHMETIC_OPERATOR'; }
|
||||
|
||||
',' { return ','; }
|
||||
'.' { return '.'; }
|
||||
':' { return ':'; }
|
||||
';' { return ';'; }
|
||||
'~' { return '~'; }
|
||||
'!' { return '!'; }
|
||||
|
||||
'(' { return '('; }
|
||||
')' { return ')'; }
|
||||
'[' { return '['; }
|
||||
']' { return ']'; }
|
||||
|
||||
\$\{[^}]*\} { return 'VARIABLE_REFERENCE'; }
|
||||
|
||||
\` { this.begin('backtickedValue'); return 'BACKTICK'; }
|
||||
<backtickedValue>[^`]+ {
|
||||
if (parser.handleQuotedValueWithCursor(this, yytext, yylloc, '`')) {
|
||||
return 'PARTIAL_VALUE';
|
||||
}
|
||||
return 'VALUE';
|
||||
}
|
||||
<backtickedValue>\` { this.popState(); return 'BACKTICK'; }
|
||||
|
||||
\' { this.begin('singleQuotedValue'); return 'SINGLE_QUOTE'; }
|
||||
<singleQuotedValue>(?:\\\\|\\[']|[^'])+ {
|
||||
if (parser.handleQuotedValueWithCursor(this, yytext, yylloc, '\'')) {
|
||||
return 'PARTIAL_VALUE';
|
||||
}
|
||||
return 'VALUE';
|
||||
}
|
||||
<singleQuotedValue>\' { this.popState(); return 'SINGLE_QUOTE'; }
|
||||
|
||||
\" { this.begin('doubleQuotedValue'); return 'DOUBLE_QUOTE'; }
|
||||
<doubleQuotedValue>(?:\\\\|\\["]|[^"])+ {
|
||||
if (parser.handleQuotedValueWithCursor(this, yytext, yylloc, '"')) {
|
||||
return 'PARTIAL_VALUE';
|
||||
}
|
||||
return 'VALUE';
|
||||
}
|
||||
<doubleQuotedValue>\" { this.popState(); return 'DOUBLE_QUOTE'; }
|
||||
|
||||
<<EOF>> { return 'EOF'; }
|
||||
|
||||
. { /* To prevent console logging of unknown chars */ }
|
||||
<between>. { }
|
||||
<hive>. { }
|
||||
<impala>. { }
|
||||
<hdfs>. { }
|
||||
<backtickedValue>. { }
|
||||
<singleQuotedValue>. { }
|
||||
<doubleQuotedValue>. { }
|
@ -1,19 +0,0 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
%%
|
||||
|
||||
SqlParseSupport.initSqlParser(parser);
|
@ -1,29 +0,0 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
%left 'AND' 'OR'
|
||||
%left 'BETWEEN'
|
||||
%left 'NOT' '!' '~'
|
||||
%left '=' '<' '>' 'COMPARISON_OPERATOR'
|
||||
%left '-' '*' 'ARITHMETIC_OPERATOR'
|
||||
|
||||
%left ';' ','
|
||||
%nonassoc 'CURSOR' 'PARTIAL_CURSOR'
|
||||
%nonassoc 'IN' 'IS' 'LIKE' 'RLIKE' 'REGEXP' 'EXISTS' NEGATION
|
||||
|
||||
%start SqlAutocomplete
|
||||
|
||||
%%
|
@ -1,226 +0,0 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
%options case-insensitive flex
|
||||
%s between
|
||||
%x hdfs doubleQuotedValue singleQuotedValue backtickedValue
|
||||
%%
|
||||
|
||||
\s { /* skip whitespace */ }
|
||||
'--'.* { /* skip comments */ }
|
||||
[/][*][^*]*[*]+([^/*][^*]*[*]+)*[/] { /* skip comments */ }
|
||||
|
||||
'\u2020' { parser.yy.partialCursor = false; parser.yy.cursorFound = yylloc; return 'CURSOR'; }
|
||||
'\u2021' { parser.yy.partialCursor = true; parser.yy.cursorFound = yylloc; return 'PARTIAL_CURSOR'; }
|
||||
|
||||
<between>'AND' { this.popState(); return 'BETWEEN_AND'; }
|
||||
|
||||
// Reserved Keywords
|
||||
'ALL' { return 'ALL'; }
|
||||
'ALTER' { parser.determineCase(yytext); parser.addStatementTypeLocation('ALTER', yylloc, yy.lexer.upcomingInput()); return 'ALTER'; }
|
||||
'AND' { return 'AND'; }
|
||||
'AS' { return 'AS'; }
|
||||
'ASC' { return 'ASC'; }
|
||||
'BETWEEN' { this.begin('between'); return 'BETWEEN'; }
|
||||
'BIGINT' { return 'BIGINT'; }
|
||||
'BOOLEAN' { return 'BOOLEAN'; }
|
||||
'BY' { return 'BY'; }
|
||||
'CASCADE' { return 'CASCADE'; }
|
||||
'CASE' { return 'CASE'; }
|
||||
'CHAR' { return 'CHAR'; }
|
||||
'COMMENT' { return 'COMMENT'; }
|
||||
'CREATE' { parser.determineCase(yytext); return 'CREATE'; }
|
||||
'CROSS' { return 'CROSS'; }
|
||||
'CURRENT' { return 'CURRENT'; }
|
||||
'DATABASE' { return 'DATABASE'; }
|
||||
'DECIMAL' { return 'DECIMAL'; }
|
||||
'DESC' { return 'DESC'; }
|
||||
'DISTINCT' { return 'DISTINCT'; }
|
||||
'DIV' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'DOUBLE' { return 'DOUBLE'; }
|
||||
'DROP' { parser.determineCase(yytext); parser.addStatementTypeLocation('DROP', yylloc, yy.lexer.upcomingInput()); return 'DROP'; }
|
||||
'ELSE' { return 'ELSE'; }
|
||||
'END' { return 'END'; }
|
||||
'EXISTS' { parser.yy.correlatedSubQuery = true; return 'EXISTS'; }
|
||||
'FALSE' { return 'FALSE'; }
|
||||
'FLOAT' { return 'FLOAT'; }
|
||||
'FOLLOWING' { return 'FOLLOWING'; }
|
||||
'FROM' { parser.determineCase(yytext); return 'FROM'; }
|
||||
'FULL' { return 'FULL'; }
|
||||
'GROUP' { return 'GROUP'; }
|
||||
'HAVING' { return 'HAVING'; }
|
||||
'IF' { return 'IF'; }
|
||||
'IN' { return 'IN'; }
|
||||
'INNER' { return 'INNER'; }
|
||||
'INSERT' { return 'INSERT'; }
|
||||
'INT' { return 'INT'; }
|
||||
'INTO' { return 'INTO'; }
|
||||
'IS' { return 'IS'; }
|
||||
'JOIN' { return 'JOIN'; }
|
||||
'LEFT' { return 'LEFT'; }
|
||||
'LIKE' { return 'LIKE'; }
|
||||
'LIMIT' { return 'LIMIT'; }
|
||||
'NOT' { return 'NOT'; }
|
||||
'NULL' { return 'NULL'; }
|
||||
'ON' { return 'ON'; }
|
||||
'OPTION' { return 'OPTION'; }
|
||||
'OR' { return 'OR'; }
|
||||
'ORDER' { return 'ORDER'; }
|
||||
'OUTER' { return 'OUTER'; }
|
||||
'PARTITION' { return 'PARTITION'; }
|
||||
'PRECEDING' { return 'PRECEDING'; }
|
||||
'PURGE' { return 'PURGE'; }
|
||||
'RANGE' { return 'RANGE'; }
|
||||
'REGEXP' { return 'REGEXP'; }
|
||||
'RIGHT' { return 'RIGHT'; }
|
||||
'RLIKE' { return 'RLIKE'; }
|
||||
'ROW' { return 'ROW'; }
|
||||
'ROLE' { return 'ROLE'; }
|
||||
'ROWS' { return 'ROWS'; }
|
||||
'SCHEMA' { return 'SCHEMA'; }
|
||||
'SELECT' { parser.determineCase(yytext); parser.addStatementTypeLocation('SELECT', yylloc); return 'SELECT'; }
|
||||
'SEMI' { return 'SEMI'; }
|
||||
'SET' { parser.determineCase(yytext); parser.addStatementTypeLocation('SET', yylloc); return 'SET'; }
|
||||
'SHOW' { parser.determineCase(yytext); parser.addStatementTypeLocation('SHOW', yylloc); return 'SHOW'; }
|
||||
'SMALLINT' { return 'SMALLINT'; }
|
||||
'STRING' { return 'STRING'; }
|
||||
'TABLE' { return 'TABLE'; }
|
||||
'THEN' { return 'THEN'; }
|
||||
'TIMESTAMP' { return 'TIMESTAMP'; }
|
||||
'TINYINT' { return 'TINYINT'; }
|
||||
'TO' { return 'TO'; }
|
||||
'TRUE' { return 'TRUE'; }
|
||||
'TRUNCATE' { parser.determineCase(yytext); parser.addStatementTypeLocation('TRUNCATE', yylloc, yy.lexer.upcomingInput()); return 'TRUNCATE'; }
|
||||
'UNBOUNDED' { return 'UNBOUNDED'; }
|
||||
'UNION' { return 'UNION'; }
|
||||
'UPDATE' { parser.determineCase(yytext); return 'UPDATE'; }
|
||||
'USE' { parser.determineCase(yytext); parser.addStatementTypeLocation('USE', yylloc); return 'USE'; }
|
||||
'VALUES' { return 'VALUES'; }
|
||||
'VARCHAR' { return 'VARCHAR'; }
|
||||
'VIEW' { return 'VIEW'; }
|
||||
'WHEN' { return 'WHEN'; }
|
||||
'WHERE' { return 'WHERE'; }
|
||||
'WITH' { parser.determineCase(yytext); parser.addStatementTypeLocation('WITH', yylloc); return 'WITH'; }
|
||||
|
||||
// Non-reserved Keywords
|
||||
'OVER' { return 'OVER'; }
|
||||
'ROLE' { return 'ROLE'; }
|
||||
|
||||
// --- UDFs ---
|
||||
AVG\s*\( { yy.lexer.unput('('); yytext = 'avg'; parser.addFunctionLocation(yylloc, yytext); return 'AVG'; }
|
||||
CAST\s*\( { yy.lexer.unput('('); yytext = 'cast'; parser.addFunctionLocation(yylloc, yytext); return 'CAST'; }
|
||||
COUNT\s*\( { yy.lexer.unput('('); yytext = 'count'; parser.addFunctionLocation(yylloc, yytext); return 'COUNT'; }
|
||||
MAX\s*\( { yy.lexer.unput('('); yytext = 'max'; parser.addFunctionLocation(yylloc, yytext); return 'MAX'; }
|
||||
MIN\s*\( { yy.lexer.unput('('); yytext = 'min'; parser.addFunctionLocation(yylloc, yytext); return 'MIN'; }
|
||||
STDDEV_POP\s*\( { yy.lexer.unput('('); yytext = 'stddev_pop'; parser.addFunctionLocation(yylloc, yytext); return 'STDDEV_POP'; }
|
||||
STDDEV_SAMP\s*\( { yy.lexer.unput('('); yytext = 'stddev_samp'; parser.addFunctionLocation(yylloc, yytext); return 'STDDEV_SAMP'; }
|
||||
SUM\s*\( { yy.lexer.unput('('); yytext = 'sum'; parser.addFunctionLocation(yylloc, yytext); return 'SUM'; }
|
||||
VAR_POP\s*\( { yy.lexer.unput('('); yytext = 'var_pop'; parser.addFunctionLocation(yylloc, yytext); return 'VAR_POP'; }
|
||||
VAR_SAMP\s*\( { yy.lexer.unput('('); yytext = 'var_samp'; parser.addFunctionLocation(yylloc, yytext); return 'VAR_SAMP'; }
|
||||
VARIANCE\s*\( { yy.lexer.unput('('); yytext = 'variance'; parser.addFunctionLocation(yylloc, yytext); return 'VARIANCE'; }
|
||||
|
||||
// Analytical functions
|
||||
CUME_DIST\s*\( { yy.lexer.unput('('); yytext = 'cume_dist'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
DENSE_RANK\s*\( { yy.lexer.unput('('); yytext = 'dense_rank'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
FIRST_VALUE\s*\( { yy.lexer.unput('('); yytext = 'first_value'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
LAG\s*\( { yy.lexer.unput('('); yytext = 'lag'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
LAST_VALUE\s*\( { yy.lexer.unput('('); yytext = 'last_value'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
LEAD\s*\( { yy.lexer.unput('('); yytext = 'lead'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
RANK\s*\( { yy.lexer.unput('('); yytext = 'rank'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
ROW_NUMBER\s*\( { yy.lexer.unput('('); yytext = 'row_number'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
|
||||
[0-9]+ { return 'UNSIGNED_INTEGER'; }
|
||||
[0-9]+(?:[YSL]|BD)? { return 'UNSIGNED_INTEGER'; }
|
||||
[0-9]+E { return 'UNSIGNED_INTEGER_E'; }
|
||||
[A-Za-z0-9_]+ { return 'REGULAR_IDENTIFIER'; }
|
||||
|
||||
<hdfs>'\u2020' { parser.yy.cursorFound = true; return 'CURSOR'; }
|
||||
<hdfs>'\u2021' { parser.yy.cursorFound = true; return 'PARTIAL_CURSOR'; }
|
||||
<hdfs>\s+['"] { return 'HDFS_START_QUOTE'; }
|
||||
<hdfs>[^'"\u2020\u2021]+ { parser.addFileLocation(yylloc, yytext); return 'HDFS_PATH'; }
|
||||
<hdfs>['"] { this.popState(); return 'HDFS_END_QUOTE'; }
|
||||
<hdfs><<EOF>> { return 'EOF'; }
|
||||
|
||||
'&&' { return 'AND'; }
|
||||
'||' { return 'OR'; }
|
||||
|
||||
'=' { return '='; }
|
||||
'<' { return '<'; }
|
||||
'>' { return '>'; }
|
||||
'!=' { return 'COMPARISON_OPERATOR'; }
|
||||
'<=' { return 'COMPARISON_OPERATOR'; }
|
||||
'>=' { return 'COMPARISON_OPERATOR'; }
|
||||
'<>' { return 'COMPARISON_OPERATOR'; }
|
||||
'<=>' { return 'COMPARISON_OPERATOR'; }
|
||||
|
||||
'-' { return '-'; }
|
||||
'*' { return '*'; }
|
||||
'+' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'/' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'%' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'|' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'^' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'&' { return 'ARITHMETIC_OPERATOR'; }
|
||||
|
||||
',' { return ','; }
|
||||
'.' { return '.'; }
|
||||
':' { return ':'; }
|
||||
';' { return ';'; }
|
||||
'~' { return '~'; }
|
||||
'!' { return '!'; }
|
||||
|
||||
'(' { return '('; }
|
||||
')' { return ')'; }
|
||||
'[' { return '['; }
|
||||
']' { return ']'; }
|
||||
|
||||
\$\{[^}]*\} { return 'VARIABLE_REFERENCE'; }
|
||||
|
||||
\` { this.begin('backtickedValue'); return 'BACKTICK'; }
|
||||
<backtickedValue>[^`]+ {
|
||||
if (parser.handleQuotedValueWithCursor(this, yytext, yylloc, '`')) {
|
||||
return 'PARTIAL_VALUE';
|
||||
}
|
||||
return 'VALUE';
|
||||
}
|
||||
<backtickedValue>\` { this.popState(); return 'BACKTICK'; }
|
||||
|
||||
\' { this.begin('singleQuotedValue'); return 'SINGLE_QUOTE'; }
|
||||
<singleQuotedValue>(?:\\\\|\\[']|[^'])+ {
|
||||
if (parser.handleQuotedValueWithCursor(this, yytext, yylloc, '\'')) {
|
||||
return 'PARTIAL_VALUE';
|
||||
}
|
||||
return 'VALUE';
|
||||
}
|
||||
<singleQuotedValue>\' { this.popState(); return 'SINGLE_QUOTE'; }
|
||||
|
||||
\" { this.begin('doubleQuotedValue'); return 'DOUBLE_QUOTE'; }
|
||||
<doubleQuotedValue>(?:\\\\|\\["]|[^"])+ {
|
||||
if (parser.handleQuotedValueWithCursor(this, yytext, yylloc, '"')) {
|
||||
return 'PARTIAL_VALUE';
|
||||
}
|
||||
return 'VALUE';
|
||||
}
|
||||
<doubleQuotedValue>\" { this.popState(); return 'DOUBLE_QUOTE'; }
|
||||
|
||||
<<EOF>> { return 'EOF'; }
|
||||
|
||||
. { /* To prevent console logging of unknown chars */ }
|
||||
<between>. { }
|
||||
<hdfs>. { }
|
||||
<backtickedValue>. { }
|
||||
<singleQuotedValue>. { }
|
||||
<doubleQuotedValue>. { }
|
@ -1,109 +0,0 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataDefinition
|
||||
: AlterStatement
|
||||
;
|
||||
|
||||
DataDefinition_EDIT
|
||||
: AlterStatement_EDIT
|
||||
;
|
||||
|
||||
AlterStatement
|
||||
: AlterTable
|
||||
| AlterView
|
||||
;
|
||||
|
||||
AlterStatement_EDIT
|
||||
: AlterTable_EDIT
|
||||
| AlterView_EDIT
|
||||
| 'ALTER' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['TABLE', 'VIEW']);
|
||||
}
|
||||
;
|
||||
|
||||
AlterTable
|
||||
: AlterTableLeftSide PartitionSpec
|
||||
;
|
||||
|
||||
AlterTable_EDIT
|
||||
: AlterTableLeftSide_EDIT
|
||||
| AlterTableLeftSide_EDIT PartitionSpec
|
||||
| AlterTableLeftSide 'CURSOR'
|
||||
| AlterTableLeftSide PartitionSpec 'CURSOR'
|
||||
;
|
||||
|
||||
AlterTableLeftSide
|
||||
: 'ALTER' 'TABLE' SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
}
|
||||
;
|
||||
|
||||
AlterTableLeftSide_EDIT
|
||||
: 'ALTER' 'TABLE' SchemaQualifiedTableIdentifier_EDIT
|
||||
{
|
||||
if (parser.yy.result.suggestTables) {
|
||||
parser.yy.result.suggestTables.onlyTables = true;
|
||||
}
|
||||
}
|
||||
| 'ALTER' 'TABLE' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables({ onlyTables: true });
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
;
|
||||
|
||||
AlterView
|
||||
: AlterViewLeftSide 'AS' QuerySpecification
|
||||
;
|
||||
|
||||
AlterView_EDIT
|
||||
: AlterViewLeftSide_EDIT
|
||||
| AlterViewLeftSide 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['AS']);
|
||||
}
|
||||
| AlterViewLeftSide 'SET' 'CURSOR'
|
||||
| AlterViewLeftSide 'AS' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['SELECT']);
|
||||
}
|
||||
| AlterViewLeftSide 'AS' QuerySpecification_EDIT
|
||||
;
|
||||
|
||||
|
||||
AlterViewLeftSide
|
||||
: 'ALTER' 'VIEW' SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
}
|
||||
;
|
||||
|
||||
AlterViewLeftSide_EDIT
|
||||
: 'ALTER' 'VIEW' SchemaQualifiedTableIdentifier_EDIT
|
||||
{
|
||||
if (parser.yy.result.suggestTables) {
|
||||
parser.yy.result.suggestTables.onlyViews = true;
|
||||
}
|
||||
}
|
||||
| 'ALTER' 'VIEW' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables({ onlyViews: true });
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
;
|
@ -1,615 +0,0 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataDefinition
|
||||
: CreateStatement
|
||||
;
|
||||
|
||||
DataDefinition_EDIT
|
||||
: CreateStatement_EDIT
|
||||
;
|
||||
|
||||
CreateStatement
|
||||
: DatabaseDefinition
|
||||
| TableDefinition
|
||||
| ViewDefinition
|
||||
| RoleDefinition
|
||||
;
|
||||
|
||||
CreateStatement_EDIT
|
||||
: DatabaseDefinition_EDIT
|
||||
| TableDefinition_EDIT
|
||||
| ViewDefinition_EDIT
|
||||
| 'CREATE' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['DATABASE', 'ROLE', 'SCHEMA', 'TABLE', 'VIEW']);
|
||||
}
|
||||
;
|
||||
|
||||
DatabaseDefinition
|
||||
: 'CREATE' DatabaseOrSchema OptionalIfNotExists
|
||||
| 'CREATE' DatabaseOrSchema OptionalIfNotExists RegularIdentifier DatabaseDefinitionOptionals
|
||||
{
|
||||
parser.addNewDatabaseLocation(@4, [{ name: $4 }]);
|
||||
}
|
||||
;
|
||||
|
||||
DatabaseDefinition_EDIT
|
||||
: 'CREATE' DatabaseOrSchema OptionalIfNotExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF NOT EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'CREATE' DatabaseOrSchema OptionalIfNotExists_EDIT
|
||||
| 'CREATE' DatabaseOrSchema OptionalIfNotExists 'CURSOR' RegularIdentifier
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF NOT EXISTS']);
|
||||
}
|
||||
parser.addNewDatabaseLocation(@5, [{ name: $5 }]);
|
||||
}
|
||||
| 'CREATE' DatabaseOrSchema OptionalIfNotExists_EDIT RegularIdentifier
|
||||
{
|
||||
parser.addNewDatabaseLocation(@4, [{ name: $4 }]);
|
||||
}
|
||||
| 'CREATE' DatabaseOrSchema OptionalIfNotExists RegularIdentifier DatabaseDefinitionOptionals 'CURSOR'
|
||||
{
|
||||
parser.addNewDatabaseLocation(@4, [{ name: $4 }]);
|
||||
}
|
||||
;
|
||||
|
||||
DatabaseDefinitionOptionals
|
||||
: OptionalComment
|
||||
{
|
||||
if (!$1) {
|
||||
parser.suggestKeywords(['COMMENT']);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
DatabaseDefinitionOptionals_EDIT
|
||||
: OptionalComment_INVALID
|
||||
;
|
||||
|
||||
OptionalComment
|
||||
:
|
||||
| Comment
|
||||
;
|
||||
|
||||
Comment
|
||||
: 'COMMENT' QuotedValue
|
||||
;
|
||||
|
||||
OptionalComment_INVALID
|
||||
: Comment_INVALID
|
||||
;
|
||||
|
||||
Comment_INVALID
|
||||
: 'COMMENT' SINGLE_QUOTE
|
||||
| 'COMMENT' DOUBLE_QUOTE
|
||||
| 'COMMENT' SINGLE_QUOTE VALUE
|
||||
| 'COMMENT' DOUBLE_QUOTE VALUE
|
||||
;
|
||||
|
||||
TableDefinition
|
||||
: 'CREATE' 'TABLE' OptionalIfNotExists TableDefinitionRightPart
|
||||
;
|
||||
|
||||
TableDefinition_EDIT
|
||||
: 'CREATE' 'TABLE' OptionalIfNotExists TableDefinitionRightPart_EDIT
|
||||
| 'CREATE' 'TABLE' OptionalIfNotExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF NOT EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'CREATE' 'TABLE' OptionalIfNotExists_EDIT
|
||||
;
|
||||
|
||||
TableDefinitionRightPart
|
||||
: TableIdentifierAndOptionalColumnSpecification OptionalPartitionedBy OptionalAsSelectStatement
|
||||
;
|
||||
|
||||
TableDefinitionRightPart_EDIT
|
||||
: TableIdentifierAndOptionalColumnSpecification_EDIT OptionalPartitionedBy OptionalAsSelectStatement
|
||||
| TableIdentifierAndOptionalColumnSpecification PartitionedBy_EDIT OptionalAsSelectStatement
|
||||
| TableIdentifierAndOptionalColumnSpecification OptionalPartitionedBy OptionalAsSelectStatement_EDIT
|
||||
| TableIdentifierAndOptionalColumnSpecification OptionalPartitionedBy 'CURSOR'
|
||||
{
|
||||
var keywords = [];
|
||||
if (!$1 && !$2) {
|
||||
keywords.push({ value: 'LIKE', weight: 1 });
|
||||
} else {
|
||||
if (!$2) {
|
||||
keywords.push({ value: 'PARTITIONED BY', weight: 12 });
|
||||
}
|
||||
keywords.push({ value: 'AS', weight: 1 });
|
||||
}
|
||||
|
||||
if (keywords.length > 0) {
|
||||
parser.suggestKeywords(keywords);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
TableIdentifierAndOptionalColumnSpecification
|
||||
: SchemaQualifiedIdentifier OptionalColumnSpecificationsOrLike
|
||||
{
|
||||
parser.addNewTableLocation(@1, $1, $2);
|
||||
$$ = $2;
|
||||
}
|
||||
;
|
||||
|
||||
TableIdentifierAndOptionalColumnSpecification_EDIT
|
||||
: SchemaQualifiedIdentifier OptionalColumnSpecificationsOrLike_EDIT
|
||||
| SchemaQualifiedIdentifier_EDIT OptionalColumnSpecificationsOrLike
|
||||
;
|
||||
|
||||
OptionalColumnSpecificationsOrLike
|
||||
:
|
||||
| ParenthesizedColumnSpecificationList
|
||||
| 'LIKE' SchemaQualifiedTableIdentifier -> []
|
||||
;
|
||||
|
||||
OptionalColumnSpecificationsOrLike_EDIT
|
||||
: ParenthesizedColumnSpecificationList_EDIT
|
||||
| 'LIKE' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'LIKE' SchemaQualifiedTableIdentifier_EDIT
|
||||
;
|
||||
|
||||
ParenthesizedColumnSpecificationList
|
||||
: '(' ColumnSpecificationList ')' -> $2
|
||||
;
|
||||
|
||||
ParenthesizedColumnSpecificationList_EDIT
|
||||
: '(' ColumnSpecificationList_EDIT RightParenthesisOrError
|
||||
;
|
||||
|
||||
ColumnSpecificationList
|
||||
: ColumnSpecification -> [$1]
|
||||
| ColumnSpecificationList ',' ColumnSpecification -> $1.concat($3)
|
||||
;
|
||||
|
||||
ColumnSpecificationList_EDIT
|
||||
: ColumnSpecification_EDIT
|
||||
| ColumnSpecification_EDIT ',' ColumnSpecificationList
|
||||
| ColumnSpecificationList ',' ColumnSpecification_EDIT
|
||||
| ColumnSpecificationList ',' ColumnSpecification_EDIT ',' ColumnSpecificationList
|
||||
| ColumnSpecification 'CURSOR'
|
||||
{
|
||||
parser.checkForKeywords($1);
|
||||
}
|
||||
| ColumnSpecification 'CURSOR' ',' ColumnSpecificationList
|
||||
{
|
||||
parser.checkForKeywords($1);
|
||||
}
|
||||
| ColumnSpecificationList ',' ColumnSpecification 'CURSOR'
|
||||
{
|
||||
parser.checkForKeywords($3);
|
||||
}
|
||||
| ColumnSpecificationList ',' ColumnSpecification 'CURSOR' ',' ColumnSpecificationList
|
||||
{
|
||||
parser.checkForKeywords($3);
|
||||
}
|
||||
;
|
||||
|
||||
ColumnSpecification
|
||||
: ColumnIdentifier ColumnDataType OptionalColumnOptions
|
||||
{
|
||||
$$ = $1;
|
||||
$$.type = $2;
|
||||
var keywords = [];
|
||||
if (!$3['comment']) {
|
||||
keywords.push('COMMENT');
|
||||
}
|
||||
if (keywords.length > 0) {
|
||||
$$.suggestKeywords = keywords;
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
ColumnSpecification_EDIT
|
||||
: ColumnIdentifier 'CURSOR' OptionalColumnOptions
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| ColumnIdentifier ColumnDataType_EDIT OptionalColumnOptions
|
||||
| ColumnIdentifier ColumnDataType ColumnOptions_EDIT
|
||||
;
|
||||
|
||||
OptionalColumnOptions
|
||||
: -> {}
|
||||
| ColumnOptions
|
||||
;
|
||||
|
||||
ColumnOptions
|
||||
: ColumnOption
|
||||
{
|
||||
$$ = {};
|
||||
$$[$1] = true;
|
||||
}
|
||||
| ColumnOptions ColumnOption
|
||||
{
|
||||
$1[$2] = true;
|
||||
}
|
||||
;
|
||||
|
||||
ColumnOptions_EDIT
|
||||
: ColumnOption_EDIT
|
||||
| ColumnOption_EDIT ColumnOptions
|
||||
| ColumnOptions ColumnOption_EDIT
|
||||
| ColumnOptions ColumnOption_EDIT ColumnOptions
|
||||
;
|
||||
|
||||
ColumnOption
|
||||
: 'NOT' 'NULL' -> 'null'
|
||||
| 'NULL' -> 'null'
|
||||
| Comment -> 'comment'
|
||||
;
|
||||
|
||||
ColumnOption_EDIT
|
||||
: 'NOT' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['NULL']);
|
||||
}
|
||||
;
|
||||
|
||||
ColumnDataType
|
||||
: PrimitiveType
|
||||
| ArrayType
|
||||
| MapType
|
||||
| StructType
|
||||
| ArrayType_INVALID
|
||||
| MapType_INVALID
|
||||
| StructType_INVALID
|
||||
;
|
||||
|
||||
ColumnDataType_EDIT
|
||||
: ArrayType_EDIT
|
||||
| MapType_EDIT
|
||||
| StructType_EDIT
|
||||
;
|
||||
|
||||
ArrayType
|
||||
: 'ARRAY' '<' ColumnDataType '>'
|
||||
;
|
||||
|
||||
ArrayType_INVALID
|
||||
: 'ARRAY' '<' '>'
|
||||
;
|
||||
|
||||
ArrayType_EDIT
|
||||
: 'ARRAY' '<' AnyCursor GreaterThanOrError
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| 'ARRAY' '<' ColumnDataType_EDIT GreaterThanOrError
|
||||
;
|
||||
|
||||
MapType
|
||||
: 'MAP' '<' PrimitiveType ',' ColumnDataType '>'
|
||||
;
|
||||
|
||||
MapType_INVALID
|
||||
: 'MAP' '<' '>'
|
||||
;
|
||||
|
||||
MapType_EDIT
|
||||
: 'MAP' '<' PrimitiveType ',' ColumnDataType_EDIT GreaterThanOrError
|
||||
| 'MAP' '<' AnyCursor GreaterThanOrError
|
||||
{
|
||||
parser.suggestKeywords(parser.getTypeKeywords());
|
||||
}
|
||||
| 'MAP' '<' PrimitiveType ',' AnyCursor GreaterThanOrError
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| 'MAP' '<' ',' AnyCursor GreaterThanOrError
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
;
|
||||
|
||||
StructType
|
||||
: 'STRUCT' '<' StructDefinitionList '>'
|
||||
;
|
||||
|
||||
StructType_INVALID
|
||||
: 'STRUCT' '<' '>'
|
||||
;
|
||||
|
||||
StructType_EDIT
|
||||
: 'STRUCT' '<' StructDefinitionList_EDIT GreaterThanOrError
|
||||
;
|
||||
|
||||
StructDefinitionList
|
||||
: StructDefinition
|
||||
| StructDefinitionList ',' StructDefinition
|
||||
;
|
||||
|
||||
StructDefinitionList_EDIT
|
||||
: StructDefinition_EDIT
|
||||
| StructDefinition_EDIT Commas
|
||||
| StructDefinition_EDIT Commas StructDefinitionList
|
||||
| StructDefinitionList ',' StructDefinition_EDIT
|
||||
| StructDefinitionList ',' StructDefinition_EDIT Commas StructDefinitionList
|
||||
;
|
||||
|
||||
StructDefinition
|
||||
: RegularOrBacktickedIdentifier ':' ColumnDataType OptionalComment
|
||||
;
|
||||
|
||||
StructDefinition_EDIT
|
||||
: Commas RegularOrBacktickedIdentifier ':' ColumnDataType 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['COMMENT']);
|
||||
}
|
||||
| Commas RegularOrBacktickedIdentifier ':' AnyCursor
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| Commas RegularOrBacktickedIdentifier ':' ColumnDataType_EDIT
|
||||
| RegularOrBacktickedIdentifier ':' ColumnDataType 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['COMMENT']);
|
||||
}
|
||||
| RegularOrBacktickedIdentifier ':' AnyCursor
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| RegularOrBacktickedIdentifier ':' ColumnDataType_EDIT
|
||||
;
|
||||
|
||||
ColumnDataTypeList
|
||||
: ColumnDataType
|
||||
| ColumnDataTypeList ',' ColumnDataType
|
||||
;
|
||||
|
||||
ColumnDataTypeList_EDIT
|
||||
: ColumnDataTypeListInner_EDIT
|
||||
| ColumnDataTypeListInner_EDIT Commas
|
||||
| ColumnDataTypeList ',' ColumnDataTypeListInner_EDIT
|
||||
| ColumnDataTypeListInner_EDIT Commas ColumnDataTypeList
|
||||
| ColumnDataTypeList ',' ColumnDataTypeListInner_EDIT Commas ColumnDataTypeList
|
||||
;
|
||||
|
||||
ColumnDataTypeListInner_EDIT
|
||||
: Commas AnyCursor
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| Commas ColumnDataType_EDIT
|
||||
| AnyCursor
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| ColumnDataType_EDIT
|
||||
;
|
||||
|
||||
GreaterThanOrError
|
||||
: '>'
|
||||
| error
|
||||
;
|
||||
|
||||
OptionalPartitionedBy
|
||||
:
|
||||
| PartitionedBy
|
||||
;
|
||||
|
||||
PartitionedBy
|
||||
: 'PARTITION' 'BY' RangeClause
|
||||
;
|
||||
|
||||
PartitionedBy_EDIT
|
||||
: 'PARTITION' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['BY']);
|
||||
}
|
||||
| 'PARTITION' 'BY' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['RANGE']);
|
||||
}
|
||||
| 'PARTITION' 'BY' RangeClause_EDIT
|
||||
;
|
||||
|
||||
RangeClause
|
||||
: 'RANGE' ParenthesizedColumnList ParenthesizedPartitionValuesList
|
||||
;
|
||||
|
||||
RangeClause_EDIT
|
||||
: 'RANGE' 'CURSOR'
|
||||
| 'RANGE' ParenthesizedColumnList_EDIT
|
||||
| 'RANGE' ParenthesizedColumnList 'CURSOR'
|
||||
| 'RANGE' ParenthesizedColumnList ParenthesizedPartitionValuesList_EDIT
|
||||
| 'RANGE' ParenthesizedColumnList_EDIT ParenthesizedPartitionValuesList
|
||||
;
|
||||
|
||||
ParenthesizedPartitionValuesList
|
||||
: '(' PartitionValueList ')'
|
||||
;
|
||||
|
||||
ParenthesizedPartitionValuesList_EDIT
|
||||
: '(' 'CURSOR' RightParenthesisOrError
|
||||
{
|
||||
parser.suggestKeywords(['PARTITION']);
|
||||
}
|
||||
|'(' PartitionValueList_EDIT RightParenthesisOrError
|
||||
;
|
||||
|
||||
PartitionValueList
|
||||
: PartitionValue
|
||||
| PartitionValueList ',' PartitionValue
|
||||
;
|
||||
|
||||
PartitionValueList_EDIT
|
||||
: PartitionValue_EDIT
|
||||
| PartitionValueList ',' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['PARTITION']);
|
||||
}
|
||||
| PartitionValueList ',' 'CURSOR' ',' PartitionValueList
|
||||
{
|
||||
parser.suggestKeywords(['PARTITION']);
|
||||
}
|
||||
| PartitionValueList ',' PartitionValue_EDIT
|
||||
| PartitionValueList ',' PartitionValue_EDIT ',' PartitionValueList
|
||||
;
|
||||
|
||||
PartitionValue
|
||||
: 'PARTITION' ValueExpression LessThanOrEqualTo 'VALUES' LessThanOrEqualTo ValueExpression
|
||||
| 'PARTITION' 'VALUES' LessThanOrEqualTo ValueExpression
|
||||
| 'PARTITION' ValueExpression LessThanOrEqualTo 'VALUES'
|
||||
;
|
||||
|
||||
PartitionValue_EDIT
|
||||
: 'PARTITION' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['VALUE', 'VALUES']);
|
||||
}
|
||||
| 'PARTITION' ValueExpression_EDIT
|
||||
{
|
||||
if ($2.endsWithLessThanOrEqual) {
|
||||
parser.suggestKeywords(['VALUES']);
|
||||
}
|
||||
}
|
||||
| 'PARTITION' ValueExpression 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['<', '<=']);
|
||||
}
|
||||
| 'PARTITION' ValueExpression LessThanOrEqualTo 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['VALUES']);
|
||||
}
|
||||
| 'PARTITION' ValueExpression_EDIT LessThanOrEqualTo 'VALUES'
|
||||
| 'PARTITION' ValueExpression LessThanOrEqualTo 'VALUES' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['<', '<=']);
|
||||
}
|
||||
| 'PARTITION' ValueExpression LessThanOrEqualTo 'VALUES' LessThanOrEqualTo 'CURSOR'
|
||||
{
|
||||
parser.suggestFunctions();
|
||||
}
|
||||
| 'PARTITION' ValueExpression LessThanOrEqualTo 'VALUES' LessThanOrEqualTo ValueExpression_EDIT
|
||||
| 'PARTITION' 'VALUES' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['<', '<=']);
|
||||
}
|
||||
| 'PARTITION' 'VALUES' LessThanOrEqualTo 'CURSOR'
|
||||
{
|
||||
parser.suggestFunctions();
|
||||
}
|
||||
| 'PARTITION' 'VALUES' LessThanOrEqualTo ValueExpression_EDIT
|
||||
;
|
||||
|
||||
LessThanOrEqualTo
|
||||
: '<'
|
||||
| 'COMPARISON_OPERATOR' // This is fine for autocompletion
|
||||
;
|
||||
|
||||
OptionalAsSelectStatement
|
||||
:
|
||||
| 'AS' CommitLocations QuerySpecification
|
||||
;
|
||||
|
||||
OptionalAsSelectStatement_EDIT
|
||||
: 'AS' CommitLocations 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['SELECT']);
|
||||
}
|
||||
| 'AS' CommitLocations QuerySpecification_EDIT
|
||||
;
|
||||
|
||||
CommitLocations
|
||||
: /* empty */
|
||||
{
|
||||
parser.commitLocations();
|
||||
}
|
||||
;
|
||||
|
||||
ViewDefinition
|
||||
: 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment 'AS' QuerySpecification
|
||||
;
|
||||
|
||||
ViewDefinition_EDIT
|
||||
: 'CREATE' 'VIEW' OptionalIfNotExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF NOT EXISTS']);
|
||||
}
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists 'CURSOR' SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment 'AS' QuerySpecification
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF NOT EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists_EDIT
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedViewColumnList_EDIT OptionalComment
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment 'CURSOR'
|
||||
{
|
||||
var keywords = [{value: 'AS', weight: 1 }];
|
||||
if (!$6) {
|
||||
keywords.push({ value: 'COMMENT', weight: 3 });
|
||||
}
|
||||
parser.suggestKeywords(keywords);
|
||||
}
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment 'AS' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['SELECT']);
|
||||
}
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment 'AS' QuerySpecification_EDIT
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier_EDIT OptionalParenthesizedViewColumnList OptionalComment 'AS' QuerySpecification
|
||||
;
|
||||
|
||||
OptionalParenthesizedViewColumnList
|
||||
:
|
||||
| ParenthesizedViewColumnList
|
||||
;
|
||||
|
||||
ParenthesizedViewColumnList
|
||||
: '(' ViewColumnList ')'
|
||||
;
|
||||
|
||||
ParenthesizedViewColumnList_EDIT
|
||||
: '(' ViewColumnList_EDIT RightParenthesisOrError
|
||||
{
|
||||
if (!$2) {
|
||||
parser.suggestKeywords(['COMMENT']);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
ViewColumnList
|
||||
: ColumnReference OptionalComment
|
||||
| ViewColumnList ',' ColumnReference OptionalComment
|
||||
;
|
||||
|
||||
ViewColumnList_EDIT
|
||||
: ColumnReference OptionalComment 'CURSOR' -> $2
|
||||
| ColumnReference OptionalComment 'CURSOR' ',' ViewColumnList -> $2
|
||||
| ViewColumnList ',' ColumnReference OptionalComment 'CURSOR' -> $4
|
||||
| ViewColumnList ',' ColumnReference OptionalComment 'CURSOR' ',' ViewColumnList -> $4
|
||||
;
|
||||
|
||||
RoleDefinition
|
||||
: 'CREATE' 'ROLE' RegularIdentifier
|
||||
;
|
@ -1,184 +0,0 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataDefinition
|
||||
: DropStatement
|
||||
;
|
||||
|
||||
DataDefinition_EDIT
|
||||
: DropStatement_EDIT
|
||||
;
|
||||
|
||||
DropStatement
|
||||
: DropDatabaseStatement
|
||||
| DropRoleStatement
|
||||
| DropTableStatement
|
||||
| DropViewStatement
|
||||
| TruncateTableStatement
|
||||
;
|
||||
|
||||
DropStatement_EDIT
|
||||
: DropDatabaseStatement_EDIT
|
||||
| DropTableStatement_EDIT
|
||||
| DropViewStatement_EDIT
|
||||
| TruncateTableStatement_EDIT
|
||||
| 'DROP' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['DATABASE', 'ROLE', 'SCHEMA', 'TABLE', 'VIEW']);
|
||||
}
|
||||
;
|
||||
|
||||
DropDatabaseStatement
|
||||
: 'DROP' DatabaseOrSchema OptionalIfExists RegularOrBacktickedIdentifier OptionalCascade
|
||||
;
|
||||
|
||||
DropDatabaseStatement_EDIT
|
||||
: 'DROP' DatabaseOrSchema OptionalIfExists
|
||||
| 'DROP' DatabaseOrSchema OptionalIfExists_EDIT
|
||||
| 'DROP' DatabaseOrSchema OptionalIfExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
parser.suggestDatabases();
|
||||
}
|
||||
| 'DROP' DatabaseOrSchema OptionalIfExists RegularOrBacktickedIdentifier 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['CASCADE']);
|
||||
}
|
||||
| 'DROP' DatabaseOrSchema OptionalIfExists_EDIT RegularOrBacktickedIdentifier OptionalCascade
|
||||
| 'DROP' DatabaseOrSchema OptionalIfExists 'CURSOR' RegularOrBacktickedIdentifier OptionalCascade
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
}
|
||||
;
|
||||
DropRoleStatement
|
||||
: 'DROP' 'ROLE' RegularIdentifier
|
||||
;
|
||||
|
||||
DropTableStatement
|
||||
: 'DROP' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier OptionalPurge
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
;
|
||||
|
||||
DropTableStatement_EDIT
|
||||
: 'DROP' 'TABLE' OptionalIfExists_EDIT
|
||||
| 'DROP' 'TABLE' OptionalIfExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
parser.suggestTables({ onlyTables: true });
|
||||
parser.suggestDatabases({
|
||||
appendDot: true
|
||||
});
|
||||
}
|
||||
| 'DROP' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier_EDIT OptionalPurge
|
||||
{
|
||||
if (parser.yy.result.suggestTables) {
|
||||
parser.yy.result.suggestTables.onlyTables = true;
|
||||
}
|
||||
}
|
||||
| 'DROP' 'TABLE' OptionalIfExists_EDIT SchemaQualifiedTableIdentifier OptionalPurge
|
||||
| 'DROP' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier OptionalPurge 'CURSOR'
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
if (!$5) {
|
||||
parser.suggestKeywords(['PURGE']);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
OptionalPurge
|
||||
:
|
||||
| 'PURGE'
|
||||
;
|
||||
|
||||
DropViewStatement
|
||||
: 'DROP' 'VIEW' OptionalIfExists SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
;
|
||||
|
||||
DropViewStatement_EDIT
|
||||
: 'DROP' 'VIEW' OptionalIfExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
parser.suggestTables({ onlyViews: true });
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'DROP' 'VIEW' OptionalIfExists 'CURSOR' SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($5);
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'DROP' 'VIEW' OptionalIfExists_EDIT
|
||||
| 'DROP' 'VIEW' OptionalIfExists_EDIT SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
| 'DROP' 'VIEW' OptionalIfExists SchemaQualifiedTableIdentifier_EDIT
|
||||
{
|
||||
if (parser.yy.result.suggestTables) {
|
||||
parser.yy.result.suggestTables.onlyViews = true;
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
TruncateTableStatement
|
||||
: 'TRUNCATE' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
;
|
||||
|
||||
TruncateTableStatement_EDIT
|
||||
: 'TRUNCATE' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['TABLE']);
|
||||
}
|
||||
| 'TRUNCATE' 'TABLE' OptionalIfExists 'CURSOR'
|
||||
{
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'TRUNCATE' 'TABLE' OptionalIfExists_EDIT
|
||||
| 'TRUNCATE' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier_EDIT
|
||||
| 'TRUNCATE' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier 'CURSOR'
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
| 'TRUNCATE' 'TABLE' OptionalIfExists 'CURSOR' SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'TRUNCATE' 'TABLE' OptionalIfExists_EDIT SchemaQualifiedTableIdentifier OptionalPartitionSpec
|
||||
;
|
@ -1,132 +0,0 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
SqlStatements
|
||||
: error
|
||||
| NonStartingToken error // Having just ': error' does not work for some reason, jison bug?
|
||||
;
|
||||
|
||||
SqlStatement_EDIT
|
||||
: AnyCursor error
|
||||
{
|
||||
parser.suggestDdlAndDmlKeywords();
|
||||
}
|
||||
;
|
||||
|
||||
SelectStatement
|
||||
: 'SELECT' OptionalAllOrDistinct SelectList_ERROR TableExpression
|
||||
| 'SELECT' OptionalAllOrDistinct SelectList TableExpression_ERROR
|
||||
;
|
||||
|
||||
SelectStatement_EDIT
|
||||
: 'SELECT' OptionalAllOrDistinct SelectList_ERROR_EDIT TableExpression
|
||||
{
|
||||
parser.selectListNoTableSuggest($3, $2);
|
||||
}
|
||||
| 'SELECT' OptionalAllOrDistinct SelectList_ERROR TableExpression_EDIT
|
||||
;
|
||||
|
||||
SelectList_ERROR
|
||||
: ErrorList
|
||||
| SelectList ',' ErrorList
|
||||
| ErrorList ',' SelectList ',' ErrorList
|
||||
| ErrorList ',' SelectList
|
||||
| SelectList ',' ErrorList ',' SelectList
|
||||
;
|
||||
|
||||
SelectList_ERROR_EDIT
|
||||
: ErrorList ',' SelectList_EDIT -> $3
|
||||
| SelectList ',' ErrorList ',' SelectList_EDIT -> $5
|
||||
| ErrorList ',' SelectList ',' ErrorList ',' SelectList_EDIT -> $7
|
||||
| ErrorList ',' AnyCursor
|
||||
{
|
||||
$$ = { cursorAtStart : false, suggestFunctions: true, suggestColumns: true, suggestAggregateFunctions: true };
|
||||
}
|
||||
| SelectList ',' ErrorList ',' AnyCursor
|
||||
{
|
||||
$$ = { cursorAtStart : false, suggestFunctions: true, suggestColumns: true, suggestAggregateFunctions: true };
|
||||
}
|
||||
| ErrorList ',' SelectList ',' Errors ',' AnyCursor
|
||||
{
|
||||
$$ = { cursorAtStart : true, suggestFunctions: true, suggestColumns: true, suggestAggregateFunctions: true };
|
||||
}
|
||||
;
|
||||
|
||||
SetSpecification
|
||||
: 'SET' SetOption '=' error
|
||||
;
|
||||
|
||||
ErrorList
|
||||
: error
|
||||
| Errors ',' error
|
||||
;
|
||||
|
||||
JoinType_EDIT
|
||||
: 'FULL' 'CURSOR' error
|
||||
{
|
||||
parser.suggestKeywords(['JOIN', 'OUTER JOIN']);
|
||||
}
|
||||
| 'LEFT' 'CURSOR' error
|
||||
{
|
||||
parser.suggestKeywords(['JOIN', 'OUTER JOIN']);
|
||||
}
|
||||
| 'RIGHT' 'CURSOR' error
|
||||
{
|
||||
parser.suggestKeywords(['JOIN', 'OUTER JOIN']);
|
||||
}
|
||||
;
|
||||
|
||||
OptionalSelectConditions_EDIT
|
||||
: WhereClause error 'CURSOR' OptionalGroupByClause OptionalHavingClause OptionalOrderByClause OptionalLimitClause
|
||||
{
|
||||
$$ = {
|
||||
suggestKeywords: parser.getKeywordsForOptionalsLR([$4, $5, $6, $7], [{ value: 'GROUP BY', weight: 8 }, { value: 'HAVING', weight: 7 }, { value: 'ORDER BY', weight: 5 }, { value: 'LIMIT', weight: 3 }], [true, true, true, true]),
|
||||
cursorAtEnd: !$4 && !$5 && !$6 && !$7
|
||||
};
|
||||
}
|
||||
| OptionalWhereClause OptionalGroupByClause HavingClause error 'CURSOR' OptionalOrderByClause OptionalLimitClause
|
||||
{
|
||||
$$ = {
|
||||
suggestKeywords: parser.getKeywordsForOptionalsLR([$6, $7], [{ value: 'ORDER BY', weight: 5 }, { value: 'LIMIT', weight: 3 }], [true, true]),
|
||||
cursorAtEnd: !$6 && !$7
|
||||
}
|
||||
}
|
||||
| OptionalWhereClause OptionalGroupByClause OptionalHavingClause OrderByClause error 'CURSOR' OptionalLimitClause
|
||||
{
|
||||
$$ = {
|
||||
suggestKeywords: parser.getKeywordsForOptionalsLR([$7], [{ value: 'LIMIT', weight: 3 }], [true]),
|
||||
cursorAtEnd: !$7
|
||||
}
|
||||
}
|
||||
| OptionalWhereClause OptionalGroupByClause OptionalHavingClause OptionalOrderByClause LimitClause error 'CURSOR'
|
||||
;
|
||||
|
||||
OptionalSelectConditions_EDIT
|
||||
: WhereClause error GroupByClause_EDIT OptionalHavingClause OptionalOrderByClause OptionalLimitClause
|
||||
| WhereClause error OptionalGroupByClause HavingClause_EDIT OptionalOrderByClause OptionalLimitClause
|
||||
| WhereClause error OptionalGroupByClause OptionalHavingClause OrderByClause_EDIT OptionalLimitClause
|
||||
| WhereClause error OptionalGroupByClause OptionalHavingClause OptionalOrderByClause LimitClause_EDIT
|
||||
| OptionalWhereClause GroupByClause error HavingClause_EDIT OptionalOrderByClause OptionalLimitClause
|
||||
| OptionalWhereClause GroupByClause error OptionalHavingClause OrderByClause_EDIT OptionalLimitClause
|
||||
| OptionalWhereClause GroupByClause error OptionalHavingClause OptionalOrderByClause LimitClause_EDIT
|
||||
| OptionalWhereClause OptionalGroupByClause HavingClause error OrderByClause_EDIT OptionalLimitClause
|
||||
| OptionalWhereClause OptionalGroupByClause HavingClause error OptionalOrderByClause LimitClause_EDIT
|
||||
| OptionalWhereClause OptionalGroupByClause OptionalHavingClause OrderByClause error LimitClause_EDIT
|
||||
;
|
||||
|
||||
DatabaseDefinition_EDIT
|
||||
: 'CREATE' DatabaseOrSchema OptionalIfNotExists RegularIdentifier DatabaseDefinitionOptionals_EDIT error
|
||||
;
|
@ -1,72 +0,0 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataManipulation
|
||||
: InsertStatement
|
||||
;
|
||||
|
||||
InsertStatement
|
||||
: InsertValuesStatement
|
||||
;
|
||||
|
||||
DataManipulation_EDIT
|
||||
: InsertValuesStatement_EDIT
|
||||
;
|
||||
|
||||
InsertValuesStatement
|
||||
: 'INSERT' 'INTO' OptionalTable SchemaQualifiedTableIdentifier 'VALUES' InsertValuesList
|
||||
{
|
||||
$4.owner = 'insert';
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
;
|
||||
|
||||
InsertValuesStatement_EDIT
|
||||
: 'INSERT' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['INTO']);
|
||||
}
|
||||
| 'INSERT' 'INTO' OptionalTable 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['TABLE']);
|
||||
}
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'INSERT' 'INTO' OptionalTable SchemaQualifiedTableIdentifier_EDIT
|
||||
| 'INSERT' 'INTO' OptionalTable SchemaQualifiedTableIdentifier 'CURSOR'
|
||||
{
|
||||
$4.owner = 'insert';
|
||||
parser.addTablePrimary($4);
|
||||
parser.suggestKeywords(['VALUES']);
|
||||
}
|
||||
| 'INSERT' 'INTO' OptionalTable SchemaQualifiedTableIdentifier_EDIT 'VALUES' InsertValuesList
|
||||
;
|
||||
|
||||
InsertValuesList
|
||||
: ParenthesizedRowValuesList
|
||||
| RowValuesList ',' ParenthesizedRowValuesList
|
||||
;
|
||||
|
||||
ParenthesizedRowValuesList
|
||||
: '(' InValueList ')'
|
||||
;
|
||||
|
||||
OptionalTable
|
||||
:
|
||||
| 'TABLE'
|
||||
;
|
File diff suppressed because it is too large
Load Diff
@ -1,46 +0,0 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataDefinition
|
||||
: SetSpecification
|
||||
;
|
||||
|
||||
DataDefinition_EDIT
|
||||
: 'SET' 'CURSOR'
|
||||
{
|
||||
parser.suggestSetOptions();
|
||||
}
|
||||
;
|
||||
|
||||
SetSpecification
|
||||
: 'SET' SetOption '=' SetValue
|
||||
| 'SET' 'ALL'
|
||||
;
|
||||
|
||||
SetOption
|
||||
: RegularIdentifier
|
||||
| SetOption '.' RegularIdentifier
|
||||
;
|
||||
|
||||
SetValue
|
||||
: RegularIdentifier
|
||||
| SignedInteger
|
||||
| SignedInteger RegularIdentifier
|
||||
| QuotedValue
|
||||
| 'TRUE'
|
||||
| 'FALSE'
|
||||
| 'NULL'
|
||||
;
|
@ -1,122 +0,0 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataManipulation
|
||||
: UpdateStatement
|
||||
;
|
||||
|
||||
DataManipulation_EDIT
|
||||
: UpdateStatement_EDIT
|
||||
;
|
||||
|
||||
UpdateStatement
|
||||
: 'UPDATE' TargetTable 'SET' SetClauseList OptionalFromJoinedTable OptionalWhereClause
|
||||
;
|
||||
|
||||
UpdateStatement_EDIT
|
||||
: 'UPDATE' TargetTable_EDIT 'SET' SetClauseList OptionalFromJoinedTable OptionalWhereClause
|
||||
| 'UPDATE' TargetTable 'SET' SetClauseList_EDIT OptionalFromJoinedTable OptionalWhereClause
|
||||
| 'UPDATE' TargetTable 'SET' SetClauseList FromJoinedTable_EDIT OptionalWhereClause
|
||||
| 'UPDATE' TargetTable 'SET' SetClauseList OptionalFromJoinedTable WhereClause_EDIT
|
||||
| 'UPDATE' TargetTable 'SET' SetClauseList OptionalFromJoinedTable OptionalWhereClause 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords([ 'WHERE' ]);
|
||||
}
|
||||
| 'UPDATE' TargetTable 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords([ 'SET' ]);
|
||||
}
|
||||
| 'UPDATE' TargetTable_EDIT
|
||||
| 'UPDATE' TargetTable
|
||||
| 'UPDATE' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
;
|
||||
|
||||
TargetTable
|
||||
: TableName
|
||||
;
|
||||
|
||||
TargetTable_EDIT
|
||||
: TableName_EDIT
|
||||
;
|
||||
|
||||
TableName
|
||||
: LocalOrSchemaQualifiedName
|
||||
{
|
||||
parser.addTablePrimary($1);
|
||||
}
|
||||
;
|
||||
|
||||
TableName_EDIT
|
||||
: LocalOrSchemaQualifiedName_EDIT
|
||||
;
|
||||
|
||||
SetClauseList
|
||||
: SetClause
|
||||
| SetClauseList ',' SetClause
|
||||
;
|
||||
|
||||
SetClauseList_EDIT
|
||||
: SetClause_EDIT
|
||||
| SetClauseList ',' SetClause_EDIT
|
||||
| SetClause_EDIT ',' SetClauseList
|
||||
| SetClauseList ',' SetClause_EDIT ',' SetClauseList
|
||||
;
|
||||
|
||||
SetClause
|
||||
: SetTarget '=' UpdateSource
|
||||
;
|
||||
|
||||
SetClause_EDIT
|
||||
: SetTarget '=' UpdateSource_EDIT
|
||||
| SetTarget 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords([ '=' ]);
|
||||
}
|
||||
| 'CURSOR'
|
||||
{
|
||||
parser.suggestColumns();
|
||||
}
|
||||
;
|
||||
|
||||
SetTarget
|
||||
: ColumnReference
|
||||
;
|
||||
|
||||
UpdateSource
|
||||
: ValueExpression
|
||||
;
|
||||
|
||||
UpdateSource_EDIT
|
||||
: ValueExpression_EDIT
|
||||
;
|
||||
|
||||
OptionalFromJoinedTable
|
||||
:
|
||||
| 'FROM' TableReference -> $2
|
||||
;
|
||||
|
||||
FromJoinedTable_EDIT
|
||||
: 'FROM' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'FROM' TableReference_EDIT
|
||||
;
|
@ -1,39 +0,0 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataDefinition
|
||||
: UseStatement
|
||||
;
|
||||
|
||||
DataDefinition_EDIT
|
||||
: UseStatement_EDIT
|
||||
;
|
||||
|
||||
UseStatement
|
||||
: 'USE' RegularIdentifier
|
||||
{
|
||||
if (! parser.yy.cursorFound) {
|
||||
parser.yy.result.useDatabase = $2;
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
UseStatement_EDIT
|
||||
: 'USE' 'CURSOR'
|
||||
{
|
||||
parser.suggestDatabases();
|
||||
}
|
||||
;
|
@ -1,839 +0,0 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
ValueExpression
|
||||
: 'NOT' ValueExpression
|
||||
{
|
||||
// verifyType($2, 'BOOLEAN');
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| '!' ValueExpression
|
||||
{
|
||||
// verifyType($2, 'BOOLEAN');
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| '~' ValueExpression -> $2
|
||||
| '-' ValueExpression %prec NEGATION
|
||||
{
|
||||
// verifyType($2, 'NUMBER');
|
||||
$$ = $2;
|
||||
$2.types = ['NUMBER'];
|
||||
}
|
||||
| ValueExpression 'IS' OptionalNot 'NULL' -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'IS' OptionalNot 'TRUE' -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'IS' OptionalNot 'FALSE' -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'IS' OptionalNot 'DISTINCT' 'FROM' ValueExpression -> { types: [ 'BOOLEAN' ] }
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: 'NOT' ValueExpression_EDIT -> { types: [ 'BOOLEAN' ], suggestFilters: $2.suggestFilters }
|
||||
| 'NOT' 'CURSOR'
|
||||
{
|
||||
parser.suggestFunctions();
|
||||
parser.suggestColumns();
|
||||
parser.suggestKeywords(['EXISTS']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| '!' ValueExpression_EDIT -> { types: [ 'BOOLEAN' ], suggestFilters: $2.suggestFilters }
|
||||
| '!' AnyCursor
|
||||
{
|
||||
parser.suggestFunctions({ types: [ 'BOOLEAN' ] });
|
||||
parser.suggestColumns({ types: [ 'BOOLEAN' ] });
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| '~' ValueExpression_EDIT -> { types: [ 'T' ], suggestFilters: $2.suggestFilters }
|
||||
| '~' 'PARTIAL_CURSOR'
|
||||
{
|
||||
parser.suggestFunctions();
|
||||
parser.suggestColumns();
|
||||
$$ = { types: [ 'T' ] };
|
||||
}
|
||||
| '-' ValueExpression_EDIT %prec NEGATION
|
||||
{
|
||||
if (!$2.typeSet) {
|
||||
parser.applyTypeToSuggestions('NUMBER');
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $2.suggestFilters };
|
||||
}
|
||||
| '-' 'PARTIAL_CURSOR' %prec NEGATION
|
||||
{
|
||||
parser.suggestFunctions({ types: [ 'NUMBER' ] });
|
||||
parser.suggestColumns({ types: [ 'NUMBER' ] });
|
||||
$$ = { types: [ 'NUMBER' ] };
|
||||
}
|
||||
| ValueExpression 'IS' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['FALSE', 'NOT NULL', 'NOT TRUE', 'NOT FALSE', 'NULL', 'TRUE']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' 'NOT' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['FALSE', 'NULL', 'TRUE']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' OptionalNot 'DISTINCT' 'CURSOR'
|
||||
{
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' 'CURSOR' 'NULL'
|
||||
{
|
||||
parser.suggestKeywords(['NOT']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' 'CURSOR' 'FALSE'
|
||||
{
|
||||
parser.suggestKeywords(['NOT']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' 'CURSOR' 'TRUE'
|
||||
{
|
||||
parser.suggestKeywords(['NOT']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' OptionalNot 'DISTINCT' 'FROM' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $3 ? 'IS NOT DISTINCT FROM' : 'IS DISTINCT FROM');
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'IS' OptionalNot 'DISTINCT' 'FROM' ValueExpression_EDIT
|
||||
{
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $6.suggestFilters }
|
||||
}
|
||||
;
|
||||
|
||||
// ------------------ EXISTS and parenthesized ------------------
|
||||
ValueExpression
|
||||
: 'EXISTS' TableSubQuery
|
||||
{
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
// clear correlated flag after completed sub-query (set by lexer)
|
||||
parser.yy.correlatedSubQuery = false;
|
||||
}
|
||||
| '(' ValueExpression ')' -> $2
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: 'EXISTS' TableSubQuery_EDIT -> { types: [ 'BOOLEAN' ] }
|
||||
| '(' ValueExpression_EDIT RightParenthesisOrError
|
||||
{
|
||||
$$ = $2;
|
||||
}
|
||||
| '(' 'CURSOR' RightParenthesisOrError
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { types: ['T'], typeSet: true };
|
||||
}
|
||||
;
|
||||
|
||||
// ------------------ COMPARISON ------------------
|
||||
|
||||
ValueExpression
|
||||
: ValueExpression '=' ValueExpression
|
||||
{
|
||||
parser.addColRefToVariableIfExists($1, $3);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression '<' ValueExpression
|
||||
{
|
||||
parser.addColRefToVariableIfExists($1, $3);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression '>' ValueExpression
|
||||
{
|
||||
parser.addColRefToVariableIfExists($1, $3);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'COMPARISON_OPERATOR' ValueExpression
|
||||
{
|
||||
parser.addColRefToVariableIfExists($1, $3);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: 'CURSOR' '=' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest($3, $2);
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| 'CURSOR' '<' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest($3, $2);
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| 'CURSOR' '>' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest($3, $2);
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| 'CURSOR' 'COMPARISON_OPERATOR' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest($3, $2);
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression_EDIT '=' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression_EDIT '<' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression_EDIT '>' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression_EDIT 'COMPARISON_OPERATOR' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions($3.types);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression '=' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $2);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression '<' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $2);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
$$ = { types: [ 'BOOLEAN' ] , typeSet: true, endsWithLessThanOrEqual: true };
|
||||
}
|
||||
| ValueExpression '>' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $2);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression 'COMPARISON_OPERATOR' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $2);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true, endsWithLessThanOrEqual: $2 === '<=' };
|
||||
}
|
||||
| ValueExpression '=' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters }
|
||||
}
|
||||
| ValueExpression '<' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters }
|
||||
}
|
||||
| ValueExpression '>' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters }
|
||||
}
|
||||
| ValueExpression 'COMPARISON_OPERATOR' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters }
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
// ------------------ IN ------------------
|
||||
|
||||
ValueExpression
|
||||
: ValueExpression 'NOT' 'IN' '(' TableSubQueryInner ')' -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'NOT' 'IN' '(' ValueExpressionList ')' -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'IN' '(' TableSubQueryInner ')' -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'IN' '(' ValueExpressionList ')' -> { types: [ 'BOOLEAN' ] }
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: ValueExpression 'NOT' 'IN' ValueExpressionInSecondPart_EDIT
|
||||
{
|
||||
if ($4.inValueEdit) {
|
||||
parser.valueExpressionSuggest($1, $2 + ' ' + $3);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
}
|
||||
if ($4.cursorAtStart) {
|
||||
parser.suggestKeywords(['SELECT']);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression 'IN' ValueExpressionInSecondPart_EDIT
|
||||
{
|
||||
if ($3.inValueEdit) {
|
||||
parser.valueExpressionSuggest($1, $2);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
}
|
||||
if ($3.cursorAtStart) {
|
||||
parser.suggestKeywords(['SELECT']);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression_EDIT 'NOT' 'IN' '(' ValueExpressionList RightParenthesisOrError -> { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
| ValueExpression_EDIT 'NOT' 'IN' '(' TableSubQueryInner RightParenthesisOrError -> { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
| ValueExpression_EDIT 'IN' '(' ValueExpressionList RightParenthesisOrError -> { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
| ValueExpression_EDIT 'IN' '(' TableSubQueryInner RightParenthesisOrError -> { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
;
|
||||
|
||||
ValueExpressionInSecondPart_EDIT
|
||||
: '(' TableSubQueryInner_EDIT RightParenthesisOrError
|
||||
| '(' ValueExpressionList_EDIT RightParenthesisOrError -> { inValueEdit: true }
|
||||
| '(' AnyCursor RightParenthesisOrError -> { inValueEdit: true, cursorAtStart: true }
|
||||
;
|
||||
|
||||
// ------------------ BETWEEN ------------------
|
||||
|
||||
ValueExpression
|
||||
: ValueExpression 'NOT' 'BETWEEN' ValueExpression 'BETWEEN_AND' ValueExpression -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'BETWEEN' ValueExpression 'BETWEEN_AND' ValueExpression -> { types: [ 'BOOLEAN' ] }
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: ValueExpression_EDIT 'NOT' 'BETWEEN' ValueExpression 'BETWEEN_AND' ValueExpression
|
||||
{
|
||||
if ($4.types[0] === $6.types[0] && !$1.typeSet) {
|
||||
parser.applyTypeToSuggestions($4.types);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'NOT' 'BETWEEN' ValueExpression_EDIT 'BETWEEN_AND' ValueExpression
|
||||
{
|
||||
if ($1.types[0] === $6.types[0] && !$4.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $4.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'NOT' 'BETWEEN' ValueExpression 'BETWEEN_AND' ValueExpression_EDIT
|
||||
{
|
||||
if ($1.types[0] === $4.types[0] && !$6.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $6.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'NOT' 'BETWEEN' ValueExpression 'BETWEEN_AND' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $5);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression 'NOT' 'BETWEEN' ValueExpression 'CURSOR'
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($4, ['AND']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'NOT' 'BETWEEN' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $2 + ' ' + $3);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression_EDIT 'BETWEEN' ValueExpression 'BETWEEN_AND' ValueExpression
|
||||
{
|
||||
if ($1.types[0] === $3.types[0] && !$1.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types)
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'BETWEEN' ValueExpression_EDIT 'BETWEEN_AND' ValueExpression
|
||||
{
|
||||
if ($1.types[0] === $3.types[0] && !$3.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types)
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'BETWEEN' ValueExpression 'BETWEEN_AND' ValueExpression_EDIT
|
||||
{
|
||||
if ($1.types[0] === $3.types[0] && !$5.typeSet) {
|
||||
parser.applyTypeToSuggestions($1.types)
|
||||
}
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $5.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'BETWEEN' ValueExpression 'BETWEEN_AND' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $4);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression 'BETWEEN' ValueExpression 'CURSOR'
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($3, ['AND']);
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'BETWEEN' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest($1, $2);
|
||||
parser.applyTypeToSuggestions($1.types);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
;
|
||||
|
||||
// ------------------ BOOLEAN ------------------
|
||||
|
||||
ValueExpression
|
||||
: ValueExpression 'OR' ValueExpression
|
||||
{
|
||||
// verifyType($1, 'BOOLEAN');
|
||||
// verifyType($3, 'BOOLEAN');
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
| ValueExpression 'AND' ValueExpression
|
||||
{
|
||||
// verifyType($1, 'BOOLEAN');
|
||||
// verifyType($3, 'BOOLEAN');
|
||||
$$ = { types: [ 'BOOLEAN' ] };
|
||||
}
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: 'CURSOR' 'OR' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true, suggestFilters: true };
|
||||
}
|
||||
| ValueExpression_EDIT 'OR' ValueExpression
|
||||
{
|
||||
parser.addColRefIfExists($3);
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression 'OR' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true, suggestFilters: true };
|
||||
}
|
||||
| ValueExpression 'OR' ValueExpression_EDIT
|
||||
{
|
||||
parser.addColRefIfExists($1);
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters }
|
||||
}
|
||||
| 'CURSOR' 'AND' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true, suggestFilters: true };
|
||||
}
|
||||
| ValueExpression_EDIT 'AND' ValueExpression
|
||||
{
|
||||
parser.addColRefIfExists($3);
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression 'AND' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true, suggestFilters: true };
|
||||
}
|
||||
| ValueExpression 'AND' ValueExpression_EDIT
|
||||
{
|
||||
parser.addColRefIfExists($1);
|
||||
$$ = { types: [ 'BOOLEAN' ], suggestFilters: $3.suggestFilters }
|
||||
}
|
||||
;
|
||||
|
||||
// ------------------ ARITHMETIC ------------------
|
||||
|
||||
ValueExpression
|
||||
: ValueExpression '-' ValueExpression
|
||||
{
|
||||
// verifyType($1, 'NUMBER');
|
||||
// verifyType($3, 'NUMBER');
|
||||
$$ = { types: [ 'NUMBER' ] };
|
||||
}
|
||||
| ValueExpression '*' ValueExpression
|
||||
{
|
||||
// verifyType($1, 'NUMBER');
|
||||
// verifyType($3, 'NUMBER');
|
||||
$$ = { types: [ 'NUMBER' ] };
|
||||
}
|
||||
| ValueExpression 'ARITHMETIC_OPERATOR' ValueExpression
|
||||
{
|
||||
// verifyType($1, 'NUMBER');
|
||||
// verifyType($3, 'NUMBER');
|
||||
$$ = { types: [ 'NUMBER' ] };
|
||||
}
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: 'CURSOR' '*' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
parser.applyTypeToSuggestions([ 'NUMBER' ]);
|
||||
$$ = { types: [ 'NUMBER' ], typeSet: true };
|
||||
}
|
||||
| 'CURSOR' 'ARITHMETIC_OPERATOR' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
parser.applyTypeToSuggestions([ 'NUMBER' ]);
|
||||
$$ = { types: [ 'NUMBER' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression_EDIT '-' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression_EDIT '*' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression_EDIT 'ARITHMETIC_OPERATOR' ValueExpression
|
||||
{
|
||||
if (!$1.typeSet) {
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
parser.addColRefIfExists($3);
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $1.suggestFilters }
|
||||
}
|
||||
| ValueExpression '-' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
$$ = { types: [ 'NUMBER' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression '*' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
$$ = { types: [ 'NUMBER' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression 'ARITHMETIC_OPERATOR' PartialBacktickedOrAnyCursor
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
$$ = { types: [ 'NUMBER' ], typeSet: true };
|
||||
}
|
||||
| ValueExpression '-' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $3.suggestFilters };
|
||||
}
|
||||
| ValueExpression '*' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $3.suggestFilters };
|
||||
}
|
||||
| ValueExpression 'ARITHMETIC_OPERATOR' ValueExpression_EDIT
|
||||
{
|
||||
if (!$3.typeSet) {
|
||||
parser.applyTypeToSuggestions(['NUMBER']);
|
||||
parser.addColRefIfExists($1);
|
||||
}
|
||||
$$ = { types: [ 'NUMBER' ], suggestFilters: $3.suggestFilters };
|
||||
}
|
||||
;
|
||||
|
||||
// ------------------ LIKE, RLIKE and REGEXP ------------------
|
||||
|
||||
ValueExpression
|
||||
: ValueExpression LikeRightPart -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'NOT' LikeRightPart -> { types: [ 'BOOLEAN' ] }
|
||||
;
|
||||
|
||||
LikeRightPart
|
||||
: 'LIKE' ValueExpression -> { suggestKeywords: ['NOT'] }
|
||||
| 'RLIKE' ValueExpression -> { suggestKeywords: ['NOT'] }
|
||||
| 'REGEXP' ValueExpression -> { suggestKeywords: ['NOT'] }
|
||||
;
|
||||
|
||||
LikeRightPart_EDIT
|
||||
: 'LIKE' ValueExpression_EDIT
|
||||
| 'RLIKE' ValueExpression_EDIT
|
||||
| 'REGEXP' ValueExpression_EDIT
|
||||
| 'LIKE' PartialBacktickedOrCursor
|
||||
{
|
||||
parser.suggestFunctions({ types: [ 'STRING' ] });
|
||||
parser.suggestColumns({ types: [ 'STRING' ] });
|
||||
$$ = { types: ['BOOLEAN'] }
|
||||
}
|
||||
| 'RLIKE' PartialBacktickedOrCursor
|
||||
{
|
||||
parser.suggestFunctions({ types: [ 'STRING' ] });
|
||||
parser.suggestColumns({ types: [ 'STRING' ] });
|
||||
$$ = { types: ['BOOLEAN'] }
|
||||
}
|
||||
| 'REGEXP' PartialBacktickedOrCursor
|
||||
{
|
||||
parser.suggestFunctions({ types: [ 'STRING' ] });
|
||||
parser.suggestColumns({ types: [ 'STRING' ] });
|
||||
$$ = { types: ['BOOLEAN'] }
|
||||
}
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: ValueExpression_EDIT LikeRightPart -> { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
| ValueExpression_EDIT 'NOT' LikeRightPart -> { types: [ 'BOOLEAN' ], suggestFilters: $1.suggestFilters }
|
||||
| ValueExpression LikeRightPart_EDIT -> { types: [ 'BOOLEAN' ] }
|
||||
| ValueExpression 'NOT' LikeRightPart_EDIT -> { types: [ 'BOOLEAN' ] }
|
||||
| 'CURSOR' LikeRightPart
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2);
|
||||
parser.applyTypeToSuggestions([ 'STRING' ]);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
| 'CURSOR' 'NOT' LikeRightPart
|
||||
{
|
||||
parser.valueExpressionSuggest(undefined, $2 + ' ' + $3);
|
||||
parser.applyTypeToSuggestions([ 'STRING' ]);
|
||||
$$ = { types: [ 'BOOLEAN' ], typeSet: true };
|
||||
}
|
||||
;
|
||||
|
||||
// ------------------ CASE, WHEN, THEN ------------------
|
||||
|
||||
ValueExpression
|
||||
: 'CASE' CaseRightPart -> $2
|
||||
| 'CASE' ValueExpression CaseRightPart -> $3
|
||||
;
|
||||
|
||||
ValueExpression_EDIT
|
||||
: 'CASE' CaseRightPart_EDIT -> $2
|
||||
| 'CASE' 'CURSOR' EndOrError
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = { types: [ 'T' ], typeSet: true };
|
||||
}
|
||||
| 'CASE' ValueExpression CaseRightPart_EDIT -> $3
|
||||
| 'CASE' ValueExpression 'CURSOR' EndOrError
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($2, ['WHEN']);
|
||||
$$ = { types: [ 'T' ], typeSet: true };
|
||||
}
|
||||
| 'CASE' ValueExpression_EDIT CaseRightPart
|
||||
{
|
||||
$$ = $3;
|
||||
$$.suggestFilters = $2.suggestFilters;
|
||||
}
|
||||
| 'CASE' ValueExpression_EDIT EndOrError -> { types: [ 'T' ], suggestFilters: $2.suggestFilters }
|
||||
| 'CASE' 'CURSOR' CaseRightPart -> { types: [ 'T' ] }
|
||||
;
|
||||
|
||||
CaseRightPart
|
||||
: CaseWhenThenList 'END' -> parser.findCaseType($1)
|
||||
| CaseWhenThenList 'ELSE' ValueExpression 'END'
|
||||
{
|
||||
$1.caseTypes.push($3);
|
||||
$$ = parser.findCaseType($1);
|
||||
}
|
||||
;
|
||||
|
||||
CaseRightPart_EDIT
|
||||
: CaseWhenThenList_EDIT EndOrError -> parser.findCaseType($1)
|
||||
| CaseWhenThenList 'ELSE' ValueExpression 'CURSOR'
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($3, ['END']);
|
||||
$1.caseTypes.push($3);
|
||||
$$ = parser.findCaseType($1);
|
||||
}
|
||||
| CaseWhenThenList_EDIT 'ELSE' ValueExpression EndOrError
|
||||
{
|
||||
$1.caseTypes.push($3);
|
||||
$$ = parser.findCaseType($1);
|
||||
}
|
||||
| CaseWhenThenList_EDIT 'ELSE' EndOrError -> parser.findCaseType($1)
|
||||
| CaseWhenThenList 'CURSOR' ValueExpression EndOrError
|
||||
{
|
||||
if ($4.toLowerCase() !== 'end') {
|
||||
parser.suggestValueExpressionKeywords($1, [{ value: 'END', weight: 3 }, { value: 'ELSE', weight: 2 }, { value: 'WHEN', weight: 1 }]);
|
||||
} else {
|
||||
parser.suggestValueExpressionKeywords($1, [{ value: 'ELSE', weight: 2 }, { value: 'WHEN', weight: 1 }]);
|
||||
}
|
||||
$$ = parser.findCaseType($1);
|
||||
}
|
||||
| CaseWhenThenList 'CURSOR' EndOrError
|
||||
{
|
||||
if ($3.toLowerCase() !== 'end') {
|
||||
parser.suggestValueExpressionKeywords($1, [{ value: 'END', weight: 3 }, { value: 'ELSE', weight: 2 }, { value: 'WHEN', weight: 1 }]);
|
||||
} else {
|
||||
parser.suggestValueExpressionKeywords($1, [{ value: 'ELSE', weight: 2 }, { value: 'WHEN', weight: 1 }]);
|
||||
}
|
||||
$$ = parser.findCaseType($1);
|
||||
}
|
||||
| CaseWhenThenList 'ELSE' ValueExpression_EDIT EndOrError
|
||||
{
|
||||
$1.caseTypes.push($3);
|
||||
$$ = parser.findCaseType($1);
|
||||
$$.suggestFilters = $3.suggestFilters
|
||||
}
|
||||
| CaseWhenThenList 'ELSE' 'CURSOR' EndOrError
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = parser.findCaseType($1);
|
||||
}
|
||||
| 'ELSE' 'CURSOR' EndOrError
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { types: [ 'T' ], typeSet: true };
|
||||
}
|
||||
| 'CURSOR' 'ELSE' ValueExpression EndOrError
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = $3;
|
||||
}
|
||||
| 'CURSOR' 'ELSE' EndOrError
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = { types: [ 'T' ] };
|
||||
}
|
||||
;
|
||||
|
||||
EndOrError
|
||||
: 'END'
|
||||
| error
|
||||
;
|
||||
|
||||
CaseWhenThenList
|
||||
: CaseWhenThenListPartTwo -> { caseTypes: [ $1 ], lastType: $1 }
|
||||
| CaseWhenThenList CaseWhenThenListPartTwo
|
||||
{
|
||||
$1.caseTypes.push($2);
|
||||
$$ = { caseTypes: $1.caseTypes, lastType: $2 };
|
||||
}
|
||||
;
|
||||
|
||||
CaseWhenThenList_EDIT
|
||||
: CaseWhenThenListPartTwo_EDIT
|
||||
| CaseWhenThenList CaseWhenThenListPartTwo_EDIT
|
||||
| CaseWhenThenList CaseWhenThenListPartTwo_EDIT CaseWhenThenList
|
||||
| CaseWhenThenList 'CURSOR' CaseWhenThenList
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($1, ['WHEN']);
|
||||
}
|
||||
| CaseWhenThenListPartTwo_EDIT CaseWhenThenList -> $2
|
||||
;
|
||||
|
||||
CaseWhenThenListPartTwo
|
||||
: 'WHEN' ValueExpression 'THEN' ValueExpression -> $4
|
||||
;
|
||||
|
||||
CaseWhenThenListPartTwo_EDIT
|
||||
: 'WHEN' ValueExpression_EDIT -> { caseTypes: [{ types: ['T'] }], suggestFilters: $2.suggestFilters }
|
||||
| 'WHEN' ValueExpression_EDIT 'THEN' -> { caseTypes: [{ types: ['T'] }], suggestFilters: $2.suggestFilters }
|
||||
| 'WHEN' ValueExpression_EDIT 'THEN' ValueExpression -> { caseTypes: [$4], suggestFilters: $2.suggestFilters }
|
||||
| 'WHEN' ValueExpression 'THEN' ValueExpression_EDIT -> { caseTypes: [$4], suggestFilters: $4.suggestFilters }
|
||||
| 'WHEN' 'THEN' ValueExpression_EDIT -> { caseTypes: [$3], suggestFilters: $3.suggestFilters }
|
||||
| 'CURSOR' ValueExpression 'THEN'
|
||||
{
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'CURSOR' ValueExpression 'THEN' ValueExpression
|
||||
{
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = { caseTypes: [$4] };
|
||||
}
|
||||
| 'CURSOR' 'THEN'
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'CURSOR' 'THEN' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
parser.suggestKeywords(['WHEN']);
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'WHEN' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [{ types: ['T'] }], suggestFilters: true };
|
||||
}
|
||||
| 'WHEN' 'CURSOR' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
parser.suggestKeywords(['THEN']);
|
||||
$$ = { caseTypes: [{ types: ['T'] }], suggestFilters: true };
|
||||
}
|
||||
| 'WHEN' 'CURSOR' 'THEN'
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [{ types: ['T'] }], suggestFilters: true };
|
||||
}
|
||||
| 'WHEN' 'CURSOR' 'THEN' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [$4], suggestFilters: true };
|
||||
}
|
||||
| 'WHEN' ValueExpression 'CURSOR'
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($2, ['THEN']);
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'WHEN' ValueExpression 'CURSOR' ValueExpression
|
||||
{
|
||||
parser.suggestValueExpressionKeywords($2, ['THEN']);
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'WHEN' ValueExpression 'THEN' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'WHEN' ValueExpression 'THEN' 'CURSOR' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'WHEN' 'THEN' 'CURSOR' ValueExpression
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
| 'WHEN' 'THEN' 'CURSOR'
|
||||
{
|
||||
parser.valueExpressionSuggest();
|
||||
$$ = { caseTypes: [{ types: ['T'] }] };
|
||||
}
|
||||
;
|
@ -1,19 +0,0 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
%%
|
||||
|
||||
SqlParseSupport.initSyntaxParser(parser);
|
@ -1,28 +0,0 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
%left 'AND' 'OR'
|
||||
%left 'BETWEEN'
|
||||
%left 'NOT' '!' '~'
|
||||
%left '=' '<' '>' 'COMPARISON_OPERATOR'
|
||||
%left '-' '*' 'ARITHMETIC_OPERATOR'
|
||||
|
||||
%left ';' ','
|
||||
%nonassoc 'IN' 'IS' 'LIKE' 'RLIKE' 'REGEXP' 'EXISTS' NEGATION
|
||||
|
||||
%start SqlSyntax
|
||||
|
||||
%%
|
@ -1,19 +0,0 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
%%
|
||||
|
||||
SqlParseSupport.initSqlParser(parser);
|
@ -1,29 +0,0 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
%left 'AND' 'OR'
|
||||
%left 'BETWEEN'
|
||||
%left 'NOT' '!' '~'
|
||||
%left '=' '<' '>' 'COMPARISON_OPERATOR'
|
||||
%left '-' '*' 'ARITHMETIC_OPERATOR'
|
||||
|
||||
%left ';' ','
|
||||
%nonassoc 'CURSOR' 'PARTIAL_CURSOR'
|
||||
%nonassoc 'IN' 'IS' 'LIKE' 'RLIKE' 'REGEXP' 'EXISTS' NEGATION
|
||||
|
||||
%start SqlAutocomplete
|
||||
|
||||
%%
|
@ -1,226 +0,0 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
%options case-insensitive flex
|
||||
%s between
|
||||
%x hdfs doubleQuotedValue singleQuotedValue backtickedValue
|
||||
%%
|
||||
|
||||
\s { /* skip whitespace */ }
|
||||
'--'.* { /* skip comments */ }
|
||||
[/][*][^*]*[*]+([^/*][^*]*[*]+)*[/] { /* skip comments */ }
|
||||
|
||||
'\u2020' { parser.yy.partialCursor = false; parser.yy.cursorFound = yylloc; return 'CURSOR'; }
|
||||
'\u2021' { parser.yy.partialCursor = true; parser.yy.cursorFound = yylloc; return 'PARTIAL_CURSOR'; }
|
||||
|
||||
<between>'AND' { this.popState(); return 'BETWEEN_AND'; }
|
||||
|
||||
// Reserved Keywords
|
||||
'ALL' { return 'ALL'; }
|
||||
'ALTER' { parser.determineCase(yytext); parser.addStatementTypeLocation('ALTER', yylloc, yy.lexer.upcomingInput()); return 'ALTER'; }
|
||||
'AND' { return 'AND'; }
|
||||
'AS' { return 'AS'; }
|
||||
'ASC' { return 'ASC'; }
|
||||
'BETWEEN' { this.begin('between'); return 'BETWEEN'; }
|
||||
'BIGINT' { return 'BIGINT'; }
|
||||
'BOOLEAN' { return 'BOOLEAN'; }
|
||||
'BY' { return 'BY'; }
|
||||
'CASCADE' { return 'CASCADE'; }
|
||||
'CASE' { return 'CASE'; }
|
||||
'CHAR' { return 'CHAR'; }
|
||||
'COMMENT' { return 'COMMENT'; }
|
||||
'CREATE' { parser.determineCase(yytext); return 'CREATE'; }
|
||||
'CROSS' { return 'CROSS'; }
|
||||
'CURRENT' { return 'CURRENT'; }
|
||||
'DATABASE' { return 'DATABASE'; }
|
||||
'DECIMAL' { return 'DECIMAL'; }
|
||||
'DESC' { return 'DESC'; }
|
||||
'DISTINCT' { return 'DISTINCT'; }
|
||||
'DIV' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'DOUBLE' { return 'DOUBLE'; }
|
||||
'DROP' { parser.determineCase(yytext); parser.addStatementTypeLocation('DROP', yylloc, yy.lexer.upcomingInput()); return 'DROP'; }
|
||||
'ELSE' { return 'ELSE'; }
|
||||
'END' { return 'END'; }
|
||||
'EXISTS' { parser.yy.correlatedSubQuery = true; return 'EXISTS'; }
|
||||
'FALSE' { return 'FALSE'; }
|
||||
'FLOAT' { return 'FLOAT'; }
|
||||
'FOLLOWING' { return 'FOLLOWING'; }
|
||||
'FROM' { parser.determineCase(yytext); return 'FROM'; }
|
||||
'FULL' { return 'FULL'; }
|
||||
'GROUP' { return 'GROUP'; }
|
||||
'HAVING' { return 'HAVING'; }
|
||||
'IF' { return 'IF'; }
|
||||
'IN' { return 'IN'; }
|
||||
'INNER' { return 'INNER'; }
|
||||
'INSERT' { return 'INSERT'; }
|
||||
'INT' { return 'INT'; }
|
||||
'INTO' { return 'INTO'; }
|
||||
'IS' { return 'IS'; }
|
||||
'JOIN' { return 'JOIN'; }
|
||||
'LEFT' { return 'LEFT'; }
|
||||
'LIKE' { return 'LIKE'; }
|
||||
'LIMIT' { return 'LIMIT'; }
|
||||
'NOT' { return 'NOT'; }
|
||||
'NULL' { return 'NULL'; }
|
||||
'ON' { return 'ON'; }
|
||||
'OPTION' { return 'OPTION'; }
|
||||
'OR' { return 'OR'; }
|
||||
'ORDER' { return 'ORDER'; }
|
||||
'OUTER' { return 'OUTER'; }
|
||||
'PARTITION' { return 'PARTITION'; }
|
||||
'PRECEDING' { return 'PRECEDING'; }
|
||||
'PURGE' { return 'PURGE'; }
|
||||
'RANGE' { return 'RANGE'; }
|
||||
'REGEXP' { return 'REGEXP'; }
|
||||
'RIGHT' { return 'RIGHT'; }
|
||||
'RLIKE' { return 'RLIKE'; }
|
||||
'ROW' { return 'ROW'; }
|
||||
'ROLE' { return 'ROLE'; }
|
||||
'ROWS' { return 'ROWS'; }
|
||||
'SCHEMA' { return 'SCHEMA'; }
|
||||
'SELECT' { parser.determineCase(yytext); parser.addStatementTypeLocation('SELECT', yylloc); return 'SELECT'; }
|
||||
'SEMI' { return 'SEMI'; }
|
||||
'SET' { parser.determineCase(yytext); parser.addStatementTypeLocation('SET', yylloc); return 'SET'; }
|
||||
'SHOW' { parser.determineCase(yytext); parser.addStatementTypeLocation('SHOW', yylloc); return 'SHOW'; }
|
||||
'SMALLINT' { return 'SMALLINT'; }
|
||||
'STRING' { return 'STRING'; }
|
||||
'TABLE' { return 'TABLE'; }
|
||||
'THEN' { return 'THEN'; }
|
||||
'TIMESTAMP' { return 'TIMESTAMP'; }
|
||||
'TINYINT' { return 'TINYINT'; }
|
||||
'TO' { return 'TO'; }
|
||||
'TRUE' { return 'TRUE'; }
|
||||
'TRUNCATE' { parser.determineCase(yytext); parser.addStatementTypeLocation('TRUNCATE', yylloc, yy.lexer.upcomingInput()); return 'TRUNCATE'; }
|
||||
'UNBOUNDED' { return 'UNBOUNDED'; }
|
||||
'UNION' { return 'UNION'; }
|
||||
'UPDATE' { parser.determineCase(yytext); return 'UPDATE'; }
|
||||
'USE' { parser.determineCase(yytext); parser.addStatementTypeLocation('USE', yylloc); return 'USE'; }
|
||||
'VALUES' { return 'VALUES'; }
|
||||
'VARCHAR' { return 'VARCHAR'; }
|
||||
'VIEW' { return 'VIEW'; }
|
||||
'WHEN' { return 'WHEN'; }
|
||||
'WHERE' { return 'WHERE'; }
|
||||
'WITH' { parser.determineCase(yytext); parser.addStatementTypeLocation('WITH', yylloc); return 'WITH'; }
|
||||
|
||||
// Non-reserved Keywords
|
||||
'OVER' { return 'OVER'; }
|
||||
'ROLE' { return 'ROLE'; }
|
||||
|
||||
// --- UDFs ---
|
||||
AVG\s*\( { yy.lexer.unput('('); yytext = 'avg'; parser.addFunctionLocation(yylloc, yytext); return 'AVG'; }
|
||||
CAST\s*\( { yy.lexer.unput('('); yytext = 'cast'; parser.addFunctionLocation(yylloc, yytext); return 'CAST'; }
|
||||
COUNT\s*\( { yy.lexer.unput('('); yytext = 'count'; parser.addFunctionLocation(yylloc, yytext); return 'COUNT'; }
|
||||
MAX\s*\( { yy.lexer.unput('('); yytext = 'max'; parser.addFunctionLocation(yylloc, yytext); return 'MAX'; }
|
||||
MIN\s*\( { yy.lexer.unput('('); yytext = 'min'; parser.addFunctionLocation(yylloc, yytext); return 'MIN'; }
|
||||
STDDEV_POP\s*\( { yy.lexer.unput('('); yytext = 'stddev_pop'; parser.addFunctionLocation(yylloc, yytext); return 'STDDEV_POP'; }
|
||||
STDDEV_SAMP\s*\( { yy.lexer.unput('('); yytext = 'stddev_samp'; parser.addFunctionLocation(yylloc, yytext); return 'STDDEV_SAMP'; }
|
||||
SUM\s*\( { yy.lexer.unput('('); yytext = 'sum'; parser.addFunctionLocation(yylloc, yytext); return 'SUM'; }
|
||||
VAR_POP\s*\( { yy.lexer.unput('('); yytext = 'var_pop'; parser.addFunctionLocation(yylloc, yytext); return 'VAR_POP'; }
|
||||
VAR_SAMP\s*\( { yy.lexer.unput('('); yytext = 'var_samp'; parser.addFunctionLocation(yylloc, yytext); return 'VAR_SAMP'; }
|
||||
VARIANCE\s*\( { yy.lexer.unput('('); yytext = 'variance'; parser.addFunctionLocation(yylloc, yytext); return 'VARIANCE'; }
|
||||
|
||||
// Analytical functions
|
||||
CUME_DIST\s*\( { yy.lexer.unput('('); yytext = 'cume_dist'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
DENSE_RANK\s*\( { yy.lexer.unput('('); yytext = 'dense_rank'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
FIRST_VALUE\s*\( { yy.lexer.unput('('); yytext = 'first_value'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
LAG\s*\( { yy.lexer.unput('('); yytext = 'lag'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
LAST_VALUE\s*\( { yy.lexer.unput('('); yytext = 'last_value'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
LEAD\s*\( { yy.lexer.unput('('); yytext = 'lead'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
RANK\s*\( { yy.lexer.unput('('); yytext = 'rank'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
ROW_NUMBER\s*\( { yy.lexer.unput('('); yytext = 'row_number'; parser.addFunctionLocation(yylloc, yytext); return 'ANALYTIC'; }
|
||||
|
||||
[0-9]+ { return 'UNSIGNED_INTEGER'; }
|
||||
[0-9]+(?:[YSL]|BD)? { return 'UNSIGNED_INTEGER'; }
|
||||
[0-9]+E { return 'UNSIGNED_INTEGER_E'; }
|
||||
[A-Za-z0-9_]+ { return 'REGULAR_IDENTIFIER'; }
|
||||
|
||||
<hdfs>'\u2020' { parser.yy.cursorFound = true; return 'CURSOR'; }
|
||||
<hdfs>'\u2021' { parser.yy.cursorFound = true; return 'PARTIAL_CURSOR'; }
|
||||
<hdfs>\s+['"] { return 'HDFS_START_QUOTE'; }
|
||||
<hdfs>[^'"\u2020\u2021]+ { parser.addFileLocation(yylloc, yytext); return 'HDFS_PATH'; }
|
||||
<hdfs>['"] { this.popState(); return 'HDFS_END_QUOTE'; }
|
||||
<hdfs><<EOF>> { return 'EOF'; }
|
||||
|
||||
'&&' { return 'AND'; }
|
||||
'||' { return 'OR'; }
|
||||
|
||||
'=' { return '='; }
|
||||
'<' { return '<'; }
|
||||
'>' { return '>'; }
|
||||
'!=' { return 'COMPARISON_OPERATOR'; }
|
||||
'<=' { return 'COMPARISON_OPERATOR'; }
|
||||
'>=' { return 'COMPARISON_OPERATOR'; }
|
||||
'<>' { return 'COMPARISON_OPERATOR'; }
|
||||
'<=>' { return 'COMPARISON_OPERATOR'; }
|
||||
|
||||
'-' { return '-'; }
|
||||
'*' { return '*'; }
|
||||
'+' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'/' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'%' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'|' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'^' { return 'ARITHMETIC_OPERATOR'; }
|
||||
'&' { return 'ARITHMETIC_OPERATOR'; }
|
||||
|
||||
',' { return ','; }
|
||||
'.' { return '.'; }
|
||||
':' { return ':'; }
|
||||
';' { return ';'; }
|
||||
'~' { return '~'; }
|
||||
'!' { return '!'; }
|
||||
|
||||
'(' { return '('; }
|
||||
')' { return ')'; }
|
||||
'[' { return '['; }
|
||||
']' { return ']'; }
|
||||
|
||||
\$\{[^}]*\} { return 'VARIABLE_REFERENCE'; }
|
||||
|
||||
\` { this.begin('backtickedValue'); return 'BACKTICK'; }
|
||||
<backtickedValue>[^`]+ {
|
||||
if (parser.handleQuotedValueWithCursor(this, yytext, yylloc, '`')) {
|
||||
return 'PARTIAL_VALUE';
|
||||
}
|
||||
return 'VALUE';
|
||||
}
|
||||
<backtickedValue>\` { this.popState(); return 'BACKTICK'; }
|
||||
|
||||
\' { this.begin('singleQuotedValue'); return 'SINGLE_QUOTE'; }
|
||||
<singleQuotedValue>(?:\\\\|\\[']|[^'])+ {
|
||||
if (parser.handleQuotedValueWithCursor(this, yytext, yylloc, '\'')) {
|
||||
return 'PARTIAL_VALUE';
|
||||
}
|
||||
return 'VALUE';
|
||||
}
|
||||
<singleQuotedValue>\' { this.popState(); return 'SINGLE_QUOTE'; }
|
||||
|
||||
\" { this.begin('doubleQuotedValue'); return 'DOUBLE_QUOTE'; }
|
||||
<doubleQuotedValue>(?:\\\\|\\["]|[^"])+ {
|
||||
if (parser.handleQuotedValueWithCursor(this, yytext, yylloc, '"')) {
|
||||
return 'PARTIAL_VALUE';
|
||||
}
|
||||
return 'VALUE';
|
||||
}
|
||||
<doubleQuotedValue>\" { this.popState(); return 'DOUBLE_QUOTE'; }
|
||||
|
||||
<<EOF>> { return 'EOF'; }
|
||||
|
||||
. { /* To prevent console logging of unknown chars */ }
|
||||
<between>. { }
|
||||
<hdfs>. { }
|
||||
<backtickedValue>. { }
|
||||
<singleQuotedValue>. { }
|
||||
<doubleQuotedValue>. { }
|
@ -1,109 +0,0 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataDefinition
|
||||
: AlterStatement
|
||||
;
|
||||
|
||||
DataDefinition_EDIT
|
||||
: AlterStatement_EDIT
|
||||
;
|
||||
|
||||
AlterStatement
|
||||
: AlterTable
|
||||
| AlterView
|
||||
;
|
||||
|
||||
AlterStatement_EDIT
|
||||
: AlterTable_EDIT
|
||||
| AlterView_EDIT
|
||||
| 'ALTER' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['TABLE', 'VIEW']);
|
||||
}
|
||||
;
|
||||
|
||||
AlterTable
|
||||
: AlterTableLeftSide PartitionSpec
|
||||
;
|
||||
|
||||
AlterTable_EDIT
|
||||
: AlterTableLeftSide_EDIT
|
||||
| AlterTableLeftSide_EDIT PartitionSpec
|
||||
| AlterTableLeftSide 'CURSOR'
|
||||
| AlterTableLeftSide PartitionSpec 'CURSOR'
|
||||
;
|
||||
|
||||
AlterTableLeftSide
|
||||
: 'ALTER' 'TABLE' SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
}
|
||||
;
|
||||
|
||||
AlterTableLeftSide_EDIT
|
||||
: 'ALTER' 'TABLE' SchemaQualifiedTableIdentifier_EDIT
|
||||
{
|
||||
if (parser.yy.result.suggestTables) {
|
||||
parser.yy.result.suggestTables.onlyTables = true;
|
||||
}
|
||||
}
|
||||
| 'ALTER' 'TABLE' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables({ onlyTables: true });
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
;
|
||||
|
||||
AlterView
|
||||
: AlterViewLeftSide 'AS' QuerySpecification
|
||||
;
|
||||
|
||||
AlterView_EDIT
|
||||
: AlterViewLeftSide_EDIT
|
||||
| AlterViewLeftSide 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['AS']);
|
||||
}
|
||||
| AlterViewLeftSide 'SET' 'CURSOR'
|
||||
| AlterViewLeftSide 'AS' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['SELECT']);
|
||||
}
|
||||
| AlterViewLeftSide 'AS' QuerySpecification_EDIT
|
||||
;
|
||||
|
||||
|
||||
AlterViewLeftSide
|
||||
: 'ALTER' 'VIEW' SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($3);
|
||||
}
|
||||
;
|
||||
|
||||
AlterViewLeftSide_EDIT
|
||||
: 'ALTER' 'VIEW' SchemaQualifiedTableIdentifier_EDIT
|
||||
{
|
||||
if (parser.yy.result.suggestTables) {
|
||||
parser.yy.result.suggestTables.onlyViews = true;
|
||||
}
|
||||
}
|
||||
| 'ALTER' 'VIEW' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables({ onlyViews: true });
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
;
|
@ -1,615 +0,0 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataDefinition
|
||||
: CreateStatement
|
||||
;
|
||||
|
||||
DataDefinition_EDIT
|
||||
: CreateStatement_EDIT
|
||||
;
|
||||
|
||||
CreateStatement
|
||||
: DatabaseDefinition
|
||||
| TableDefinition
|
||||
| ViewDefinition
|
||||
| RoleDefinition
|
||||
;
|
||||
|
||||
CreateStatement_EDIT
|
||||
: DatabaseDefinition_EDIT
|
||||
| TableDefinition_EDIT
|
||||
| ViewDefinition_EDIT
|
||||
| 'CREATE' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['DATABASE', 'ROLE', 'SCHEMA', 'TABLE', 'VIEW']);
|
||||
}
|
||||
;
|
||||
|
||||
DatabaseDefinition
|
||||
: 'CREATE' DatabaseOrSchema OptionalIfNotExists
|
||||
| 'CREATE' DatabaseOrSchema OptionalIfNotExists RegularIdentifier DatabaseDefinitionOptionals
|
||||
{
|
||||
parser.addNewDatabaseLocation(@4, [{ name: $4 }]);
|
||||
}
|
||||
;
|
||||
|
||||
DatabaseDefinition_EDIT
|
||||
: 'CREATE' DatabaseOrSchema OptionalIfNotExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF NOT EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'CREATE' DatabaseOrSchema OptionalIfNotExists_EDIT
|
||||
| 'CREATE' DatabaseOrSchema OptionalIfNotExists 'CURSOR' RegularIdentifier
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF NOT EXISTS']);
|
||||
}
|
||||
parser.addNewDatabaseLocation(@5, [{ name: $5 }]);
|
||||
}
|
||||
| 'CREATE' DatabaseOrSchema OptionalIfNotExists_EDIT RegularIdentifier
|
||||
{
|
||||
parser.addNewDatabaseLocation(@4, [{ name: $4 }]);
|
||||
}
|
||||
| 'CREATE' DatabaseOrSchema OptionalIfNotExists RegularIdentifier DatabaseDefinitionOptionals 'CURSOR'
|
||||
{
|
||||
parser.addNewDatabaseLocation(@4, [{ name: $4 }]);
|
||||
}
|
||||
;
|
||||
|
||||
DatabaseDefinitionOptionals
|
||||
: OptionalComment
|
||||
{
|
||||
if (!$1) {
|
||||
parser.suggestKeywords(['COMMENT']);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
DatabaseDefinitionOptionals_EDIT
|
||||
: OptionalComment_INVALID
|
||||
;
|
||||
|
||||
OptionalComment
|
||||
:
|
||||
| Comment
|
||||
;
|
||||
|
||||
Comment
|
||||
: 'COMMENT' QuotedValue
|
||||
;
|
||||
|
||||
OptionalComment_INVALID
|
||||
: Comment_INVALID
|
||||
;
|
||||
|
||||
Comment_INVALID
|
||||
: 'COMMENT' SINGLE_QUOTE
|
||||
| 'COMMENT' DOUBLE_QUOTE
|
||||
| 'COMMENT' SINGLE_QUOTE VALUE
|
||||
| 'COMMENT' DOUBLE_QUOTE VALUE
|
||||
;
|
||||
|
||||
TableDefinition
|
||||
: 'CREATE' 'TABLE' OptionalIfNotExists TableDefinitionRightPart
|
||||
;
|
||||
|
||||
TableDefinition_EDIT
|
||||
: 'CREATE' 'TABLE' OptionalIfNotExists TableDefinitionRightPart_EDIT
|
||||
| 'CREATE' 'TABLE' OptionalIfNotExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF NOT EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'CREATE' 'TABLE' OptionalIfNotExists_EDIT
|
||||
;
|
||||
|
||||
TableDefinitionRightPart
|
||||
: TableIdentifierAndOptionalColumnSpecification OptionalPartitionedBy OptionalAsSelectStatement
|
||||
;
|
||||
|
||||
TableDefinitionRightPart_EDIT
|
||||
: TableIdentifierAndOptionalColumnSpecification_EDIT OptionalPartitionedBy OptionalAsSelectStatement
|
||||
| TableIdentifierAndOptionalColumnSpecification PartitionedBy_EDIT OptionalAsSelectStatement
|
||||
| TableIdentifierAndOptionalColumnSpecification OptionalPartitionedBy OptionalAsSelectStatement_EDIT
|
||||
| TableIdentifierAndOptionalColumnSpecification OptionalPartitionedBy 'CURSOR'
|
||||
{
|
||||
var keywords = [];
|
||||
if (!$1 && !$2) {
|
||||
keywords.push({ value: 'LIKE', weight: 1 });
|
||||
} else {
|
||||
if (!$2) {
|
||||
keywords.push({ value: 'PARTITIONED BY', weight: 12 });
|
||||
}
|
||||
keywords.push({ value: 'AS', weight: 1 });
|
||||
}
|
||||
|
||||
if (keywords.length > 0) {
|
||||
parser.suggestKeywords(keywords);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
TableIdentifierAndOptionalColumnSpecification
|
||||
: SchemaQualifiedIdentifier OptionalColumnSpecificationsOrLike
|
||||
{
|
||||
parser.addNewTableLocation(@1, $1, $2);
|
||||
$$ = $2;
|
||||
}
|
||||
;
|
||||
|
||||
TableIdentifierAndOptionalColumnSpecification_EDIT
|
||||
: SchemaQualifiedIdentifier OptionalColumnSpecificationsOrLike_EDIT
|
||||
| SchemaQualifiedIdentifier_EDIT OptionalColumnSpecificationsOrLike
|
||||
;
|
||||
|
||||
OptionalColumnSpecificationsOrLike
|
||||
:
|
||||
| ParenthesizedColumnSpecificationList
|
||||
| 'LIKE' SchemaQualifiedTableIdentifier -> []
|
||||
;
|
||||
|
||||
OptionalColumnSpecificationsOrLike_EDIT
|
||||
: ParenthesizedColumnSpecificationList_EDIT
|
||||
| 'LIKE' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'LIKE' SchemaQualifiedTableIdentifier_EDIT
|
||||
;
|
||||
|
||||
ParenthesizedColumnSpecificationList
|
||||
: '(' ColumnSpecificationList ')' -> $2
|
||||
;
|
||||
|
||||
ParenthesizedColumnSpecificationList_EDIT
|
||||
: '(' ColumnSpecificationList_EDIT RightParenthesisOrError
|
||||
;
|
||||
|
||||
ColumnSpecificationList
|
||||
: ColumnSpecification -> [$1]
|
||||
| ColumnSpecificationList ',' ColumnSpecification -> $1.concat($3)
|
||||
;
|
||||
|
||||
ColumnSpecificationList_EDIT
|
||||
: ColumnSpecification_EDIT
|
||||
| ColumnSpecification_EDIT ',' ColumnSpecificationList
|
||||
| ColumnSpecificationList ',' ColumnSpecification_EDIT
|
||||
| ColumnSpecificationList ',' ColumnSpecification_EDIT ',' ColumnSpecificationList
|
||||
| ColumnSpecification 'CURSOR'
|
||||
{
|
||||
parser.checkForKeywords($1);
|
||||
}
|
||||
| ColumnSpecification 'CURSOR' ',' ColumnSpecificationList
|
||||
{
|
||||
parser.checkForKeywords($1);
|
||||
}
|
||||
| ColumnSpecificationList ',' ColumnSpecification 'CURSOR'
|
||||
{
|
||||
parser.checkForKeywords($3);
|
||||
}
|
||||
| ColumnSpecificationList ',' ColumnSpecification 'CURSOR' ',' ColumnSpecificationList
|
||||
{
|
||||
parser.checkForKeywords($3);
|
||||
}
|
||||
;
|
||||
|
||||
ColumnSpecification
|
||||
: ColumnIdentifier ColumnDataType OptionalColumnOptions
|
||||
{
|
||||
$$ = $1;
|
||||
$$.type = $2;
|
||||
var keywords = [];
|
||||
if (!$3['comment']) {
|
||||
keywords.push('COMMENT');
|
||||
}
|
||||
if (keywords.length > 0) {
|
||||
$$.suggestKeywords = keywords;
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
ColumnSpecification_EDIT
|
||||
: ColumnIdentifier 'CURSOR' OptionalColumnOptions
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| ColumnIdentifier ColumnDataType_EDIT OptionalColumnOptions
|
||||
| ColumnIdentifier ColumnDataType ColumnOptions_EDIT
|
||||
;
|
||||
|
||||
OptionalColumnOptions
|
||||
: -> {}
|
||||
| ColumnOptions
|
||||
;
|
||||
|
||||
ColumnOptions
|
||||
: ColumnOption
|
||||
{
|
||||
$$ = {};
|
||||
$$[$1] = true;
|
||||
}
|
||||
| ColumnOptions ColumnOption
|
||||
{
|
||||
$1[$2] = true;
|
||||
}
|
||||
;
|
||||
|
||||
ColumnOptions_EDIT
|
||||
: ColumnOption_EDIT
|
||||
| ColumnOption_EDIT ColumnOptions
|
||||
| ColumnOptions ColumnOption_EDIT
|
||||
| ColumnOptions ColumnOption_EDIT ColumnOptions
|
||||
;
|
||||
|
||||
ColumnOption
|
||||
: 'NOT' 'NULL' -> 'null'
|
||||
| 'NULL' -> 'null'
|
||||
| Comment -> 'comment'
|
||||
;
|
||||
|
||||
ColumnOption_EDIT
|
||||
: 'NOT' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['NULL']);
|
||||
}
|
||||
;
|
||||
|
||||
ColumnDataType
|
||||
: PrimitiveType
|
||||
| ArrayType
|
||||
| MapType
|
||||
| StructType
|
||||
| ArrayType_INVALID
|
||||
| MapType_INVALID
|
||||
| StructType_INVALID
|
||||
;
|
||||
|
||||
ColumnDataType_EDIT
|
||||
: ArrayType_EDIT
|
||||
| MapType_EDIT
|
||||
| StructType_EDIT
|
||||
;
|
||||
|
||||
ArrayType
|
||||
: 'ARRAY' '<' ColumnDataType '>'
|
||||
;
|
||||
|
||||
ArrayType_INVALID
|
||||
: 'ARRAY' '<' '>'
|
||||
;
|
||||
|
||||
ArrayType_EDIT
|
||||
: 'ARRAY' '<' AnyCursor GreaterThanOrError
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| 'ARRAY' '<' ColumnDataType_EDIT GreaterThanOrError
|
||||
;
|
||||
|
||||
MapType
|
||||
: 'MAP' '<' PrimitiveType ',' ColumnDataType '>'
|
||||
;
|
||||
|
||||
MapType_INVALID
|
||||
: 'MAP' '<' '>'
|
||||
;
|
||||
|
||||
MapType_EDIT
|
||||
: 'MAP' '<' PrimitiveType ',' ColumnDataType_EDIT GreaterThanOrError
|
||||
| 'MAP' '<' AnyCursor GreaterThanOrError
|
||||
{
|
||||
parser.suggestKeywords(parser.getTypeKeywords());
|
||||
}
|
||||
| 'MAP' '<' PrimitiveType ',' AnyCursor GreaterThanOrError
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| 'MAP' '<' ',' AnyCursor GreaterThanOrError
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
;
|
||||
|
||||
StructType
|
||||
: 'STRUCT' '<' StructDefinitionList '>'
|
||||
;
|
||||
|
||||
StructType_INVALID
|
||||
: 'STRUCT' '<' '>'
|
||||
;
|
||||
|
||||
StructType_EDIT
|
||||
: 'STRUCT' '<' StructDefinitionList_EDIT GreaterThanOrError
|
||||
;
|
||||
|
||||
StructDefinitionList
|
||||
: StructDefinition
|
||||
| StructDefinitionList ',' StructDefinition
|
||||
;
|
||||
|
||||
StructDefinitionList_EDIT
|
||||
: StructDefinition_EDIT
|
||||
| StructDefinition_EDIT Commas
|
||||
| StructDefinition_EDIT Commas StructDefinitionList
|
||||
| StructDefinitionList ',' StructDefinition_EDIT
|
||||
| StructDefinitionList ',' StructDefinition_EDIT Commas StructDefinitionList
|
||||
;
|
||||
|
||||
StructDefinition
|
||||
: RegularOrBacktickedIdentifier ':' ColumnDataType OptionalComment
|
||||
;
|
||||
|
||||
StructDefinition_EDIT
|
||||
: Commas RegularOrBacktickedIdentifier ':' ColumnDataType 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['COMMENT']);
|
||||
}
|
||||
| Commas RegularOrBacktickedIdentifier ':' AnyCursor
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| Commas RegularOrBacktickedIdentifier ':' ColumnDataType_EDIT
|
||||
| RegularOrBacktickedIdentifier ':' ColumnDataType 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['COMMENT']);
|
||||
}
|
||||
| RegularOrBacktickedIdentifier ':' AnyCursor
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| RegularOrBacktickedIdentifier ':' ColumnDataType_EDIT
|
||||
;
|
||||
|
||||
ColumnDataTypeList
|
||||
: ColumnDataType
|
||||
| ColumnDataTypeList ',' ColumnDataType
|
||||
;
|
||||
|
||||
ColumnDataTypeList_EDIT
|
||||
: ColumnDataTypeListInner_EDIT
|
||||
| ColumnDataTypeListInner_EDIT Commas
|
||||
| ColumnDataTypeList ',' ColumnDataTypeListInner_EDIT
|
||||
| ColumnDataTypeListInner_EDIT Commas ColumnDataTypeList
|
||||
| ColumnDataTypeList ',' ColumnDataTypeListInner_EDIT Commas ColumnDataTypeList
|
||||
;
|
||||
|
||||
ColumnDataTypeListInner_EDIT
|
||||
: Commas AnyCursor
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| Commas ColumnDataType_EDIT
|
||||
| AnyCursor
|
||||
{
|
||||
parser.suggestKeywords(parser.getColumnDataTypeKeywords());
|
||||
}
|
||||
| ColumnDataType_EDIT
|
||||
;
|
||||
|
||||
GreaterThanOrError
|
||||
: '>'
|
||||
| error
|
||||
;
|
||||
|
||||
OptionalPartitionedBy
|
||||
:
|
||||
| PartitionedBy
|
||||
;
|
||||
|
||||
PartitionedBy
|
||||
: 'PARTITION' 'BY' RangeClause
|
||||
;
|
||||
|
||||
PartitionedBy_EDIT
|
||||
: 'PARTITION' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['BY']);
|
||||
}
|
||||
| 'PARTITION' 'BY' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['RANGE']);
|
||||
}
|
||||
| 'PARTITION' 'BY' RangeClause_EDIT
|
||||
;
|
||||
|
||||
RangeClause
|
||||
: 'RANGE' ParenthesizedColumnList ParenthesizedPartitionValuesList
|
||||
;
|
||||
|
||||
RangeClause_EDIT
|
||||
: 'RANGE' 'CURSOR'
|
||||
| 'RANGE' ParenthesizedColumnList_EDIT
|
||||
| 'RANGE' ParenthesizedColumnList 'CURSOR'
|
||||
| 'RANGE' ParenthesizedColumnList ParenthesizedPartitionValuesList_EDIT
|
||||
| 'RANGE' ParenthesizedColumnList_EDIT ParenthesizedPartitionValuesList
|
||||
;
|
||||
|
||||
ParenthesizedPartitionValuesList
|
||||
: '(' PartitionValueList ')'
|
||||
;
|
||||
|
||||
ParenthesizedPartitionValuesList_EDIT
|
||||
: '(' 'CURSOR' RightParenthesisOrError
|
||||
{
|
||||
parser.suggestKeywords(['PARTITION']);
|
||||
}
|
||||
|'(' PartitionValueList_EDIT RightParenthesisOrError
|
||||
;
|
||||
|
||||
PartitionValueList
|
||||
: PartitionValue
|
||||
| PartitionValueList ',' PartitionValue
|
||||
;
|
||||
|
||||
PartitionValueList_EDIT
|
||||
: PartitionValue_EDIT
|
||||
| PartitionValueList ',' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['PARTITION']);
|
||||
}
|
||||
| PartitionValueList ',' 'CURSOR' ',' PartitionValueList
|
||||
{
|
||||
parser.suggestKeywords(['PARTITION']);
|
||||
}
|
||||
| PartitionValueList ',' PartitionValue_EDIT
|
||||
| PartitionValueList ',' PartitionValue_EDIT ',' PartitionValueList
|
||||
;
|
||||
|
||||
PartitionValue
|
||||
: 'PARTITION' ValueExpression LessThanOrEqualTo 'VALUES' LessThanOrEqualTo ValueExpression
|
||||
| 'PARTITION' 'VALUES' LessThanOrEqualTo ValueExpression
|
||||
| 'PARTITION' ValueExpression LessThanOrEqualTo 'VALUES'
|
||||
;
|
||||
|
||||
PartitionValue_EDIT
|
||||
: 'PARTITION' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['VALUE', 'VALUES']);
|
||||
}
|
||||
| 'PARTITION' ValueExpression_EDIT
|
||||
{
|
||||
if ($2.endsWithLessThanOrEqual) {
|
||||
parser.suggestKeywords(['VALUES']);
|
||||
}
|
||||
}
|
||||
| 'PARTITION' ValueExpression 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['<', '<=']);
|
||||
}
|
||||
| 'PARTITION' ValueExpression LessThanOrEqualTo 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['VALUES']);
|
||||
}
|
||||
| 'PARTITION' ValueExpression_EDIT LessThanOrEqualTo 'VALUES'
|
||||
| 'PARTITION' ValueExpression LessThanOrEqualTo 'VALUES' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['<', '<=']);
|
||||
}
|
||||
| 'PARTITION' ValueExpression LessThanOrEqualTo 'VALUES' LessThanOrEqualTo 'CURSOR'
|
||||
{
|
||||
parser.suggestFunctions();
|
||||
}
|
||||
| 'PARTITION' ValueExpression LessThanOrEqualTo 'VALUES' LessThanOrEqualTo ValueExpression_EDIT
|
||||
| 'PARTITION' 'VALUES' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['<', '<=']);
|
||||
}
|
||||
| 'PARTITION' 'VALUES' LessThanOrEqualTo 'CURSOR'
|
||||
{
|
||||
parser.suggestFunctions();
|
||||
}
|
||||
| 'PARTITION' 'VALUES' LessThanOrEqualTo ValueExpression_EDIT
|
||||
;
|
||||
|
||||
LessThanOrEqualTo
|
||||
: '<'
|
||||
| 'COMPARISON_OPERATOR' // This is fine for autocompletion
|
||||
;
|
||||
|
||||
OptionalAsSelectStatement
|
||||
:
|
||||
| 'AS' CommitLocations QuerySpecification
|
||||
;
|
||||
|
||||
OptionalAsSelectStatement_EDIT
|
||||
: 'AS' CommitLocations 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['SELECT']);
|
||||
}
|
||||
| 'AS' CommitLocations QuerySpecification_EDIT
|
||||
;
|
||||
|
||||
CommitLocations
|
||||
: /* empty */
|
||||
{
|
||||
parser.commitLocations();
|
||||
}
|
||||
;
|
||||
|
||||
ViewDefinition
|
||||
: 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment 'AS' QuerySpecification
|
||||
;
|
||||
|
||||
ViewDefinition_EDIT
|
||||
: 'CREATE' 'VIEW' OptionalIfNotExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF NOT EXISTS']);
|
||||
}
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists 'CURSOR' SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment 'AS' QuerySpecification
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF NOT EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists_EDIT
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedViewColumnList_EDIT OptionalComment
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment 'CURSOR'
|
||||
{
|
||||
var keywords = [{value: 'AS', weight: 1 }];
|
||||
if (!$6) {
|
||||
keywords.push({ value: 'COMMENT', weight: 3 });
|
||||
}
|
||||
parser.suggestKeywords(keywords);
|
||||
}
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment 'AS' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['SELECT']);
|
||||
}
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment 'AS' QuerySpecification_EDIT
|
||||
| 'CREATE' 'VIEW' OptionalIfNotExists SchemaQualifiedIdentifier_EDIT OptionalParenthesizedViewColumnList OptionalComment 'AS' QuerySpecification
|
||||
;
|
||||
|
||||
OptionalParenthesizedViewColumnList
|
||||
:
|
||||
| ParenthesizedViewColumnList
|
||||
;
|
||||
|
||||
ParenthesizedViewColumnList
|
||||
: '(' ViewColumnList ')'
|
||||
;
|
||||
|
||||
ParenthesizedViewColumnList_EDIT
|
||||
: '(' ViewColumnList_EDIT RightParenthesisOrError
|
||||
{
|
||||
if (!$2) {
|
||||
parser.suggestKeywords(['COMMENT']);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
ViewColumnList
|
||||
: ColumnReference OptionalComment
|
||||
| ViewColumnList ',' ColumnReference OptionalComment
|
||||
;
|
||||
|
||||
ViewColumnList_EDIT
|
||||
: ColumnReference OptionalComment 'CURSOR' -> $2
|
||||
| ColumnReference OptionalComment 'CURSOR' ',' ViewColumnList -> $2
|
||||
| ViewColumnList ',' ColumnReference OptionalComment 'CURSOR' -> $4
|
||||
| ViewColumnList ',' ColumnReference OptionalComment 'CURSOR' ',' ViewColumnList -> $4
|
||||
;
|
||||
|
||||
RoleDefinition
|
||||
: 'CREATE' 'ROLE' RegularIdentifier
|
||||
;
|
@ -1,184 +0,0 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataDefinition
|
||||
: DropStatement
|
||||
;
|
||||
|
||||
DataDefinition_EDIT
|
||||
: DropStatement_EDIT
|
||||
;
|
||||
|
||||
DropStatement
|
||||
: DropDatabaseStatement
|
||||
| DropRoleStatement
|
||||
| DropTableStatement
|
||||
| DropViewStatement
|
||||
| TruncateTableStatement
|
||||
;
|
||||
|
||||
DropStatement_EDIT
|
||||
: DropDatabaseStatement_EDIT
|
||||
| DropTableStatement_EDIT
|
||||
| DropViewStatement_EDIT
|
||||
| TruncateTableStatement_EDIT
|
||||
| 'DROP' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['DATABASE', 'ROLE', 'SCHEMA', 'TABLE', 'VIEW']);
|
||||
}
|
||||
;
|
||||
|
||||
DropDatabaseStatement
|
||||
: 'DROP' DatabaseOrSchema OptionalIfExists RegularOrBacktickedIdentifier OptionalCascade
|
||||
;
|
||||
|
||||
DropDatabaseStatement_EDIT
|
||||
: 'DROP' DatabaseOrSchema OptionalIfExists
|
||||
| 'DROP' DatabaseOrSchema OptionalIfExists_EDIT
|
||||
| 'DROP' DatabaseOrSchema OptionalIfExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
parser.suggestDatabases();
|
||||
}
|
||||
| 'DROP' DatabaseOrSchema OptionalIfExists RegularOrBacktickedIdentifier 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['CASCADE']);
|
||||
}
|
||||
| 'DROP' DatabaseOrSchema OptionalIfExists_EDIT RegularOrBacktickedIdentifier OptionalCascade
|
||||
| 'DROP' DatabaseOrSchema OptionalIfExists 'CURSOR' RegularOrBacktickedIdentifier OptionalCascade
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
}
|
||||
;
|
||||
DropRoleStatement
|
||||
: 'DROP' 'ROLE' RegularIdentifier
|
||||
;
|
||||
|
||||
DropTableStatement
|
||||
: 'DROP' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier OptionalPurge
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
;
|
||||
|
||||
DropTableStatement_EDIT
|
||||
: 'DROP' 'TABLE' OptionalIfExists_EDIT
|
||||
| 'DROP' 'TABLE' OptionalIfExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
parser.suggestTables({ onlyTables: true });
|
||||
parser.suggestDatabases({
|
||||
appendDot: true
|
||||
});
|
||||
}
|
||||
| 'DROP' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier_EDIT OptionalPurge
|
||||
{
|
||||
if (parser.yy.result.suggestTables) {
|
||||
parser.yy.result.suggestTables.onlyTables = true;
|
||||
}
|
||||
}
|
||||
| 'DROP' 'TABLE' OptionalIfExists_EDIT SchemaQualifiedTableIdentifier OptionalPurge
|
||||
| 'DROP' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier OptionalPurge 'CURSOR'
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
if (!$5) {
|
||||
parser.suggestKeywords(['PURGE']);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
OptionalPurge
|
||||
:
|
||||
| 'PURGE'
|
||||
;
|
||||
|
||||
DropViewStatement
|
||||
: 'DROP' 'VIEW' OptionalIfExists SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
;
|
||||
|
||||
DropViewStatement_EDIT
|
||||
: 'DROP' 'VIEW' OptionalIfExists 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
parser.suggestTables({ onlyViews: true });
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'DROP' 'VIEW' OptionalIfExists 'CURSOR' SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($5);
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'DROP' 'VIEW' OptionalIfExists_EDIT
|
||||
| 'DROP' 'VIEW' OptionalIfExists_EDIT SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
| 'DROP' 'VIEW' OptionalIfExists SchemaQualifiedTableIdentifier_EDIT
|
||||
{
|
||||
if (parser.yy.result.suggestTables) {
|
||||
parser.yy.result.suggestTables.onlyViews = true;
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
TruncateTableStatement
|
||||
: 'TRUNCATE' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
;
|
||||
|
||||
TruncateTableStatement_EDIT
|
||||
: 'TRUNCATE' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['TABLE']);
|
||||
}
|
||||
| 'TRUNCATE' 'TABLE' OptionalIfExists 'CURSOR'
|
||||
{
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'TRUNCATE' 'TABLE' OptionalIfExists_EDIT
|
||||
| 'TRUNCATE' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier_EDIT
|
||||
| 'TRUNCATE' 'TABLE' OptionalIfExists SchemaQualifiedTableIdentifier 'CURSOR'
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
| 'TRUNCATE' 'TABLE' OptionalIfExists 'CURSOR' SchemaQualifiedTableIdentifier
|
||||
{
|
||||
parser.addTablePrimary($4);
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['IF EXISTS']);
|
||||
}
|
||||
}
|
||||
| 'TRUNCATE' 'TABLE' OptionalIfExists_EDIT SchemaQualifiedTableIdentifier OptionalPartitionSpec
|
||||
;
|
@ -1,132 +0,0 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
SqlStatements
|
||||
: error
|
||||
| NonStartingToken error // Having just ': error' does not work for some reason, jison bug?
|
||||
;
|
||||
|
||||
SqlStatement_EDIT
|
||||
: AnyCursor error
|
||||
{
|
||||
parser.suggestDdlAndDmlKeywords();
|
||||
}
|
||||
;
|
||||
|
||||
SelectStatement
|
||||
: 'SELECT' OptionalAllOrDistinct SelectList_ERROR TableExpression
|
||||
| 'SELECT' OptionalAllOrDistinct SelectList TableExpression_ERROR
|
||||
;
|
||||
|
||||
SelectStatement_EDIT
|
||||
: 'SELECT' OptionalAllOrDistinct SelectList_ERROR_EDIT TableExpression
|
||||
{
|
||||
parser.selectListNoTableSuggest($3, $2);
|
||||
}
|
||||
| 'SELECT' OptionalAllOrDistinct SelectList_ERROR TableExpression_EDIT
|
||||
;
|
||||
|
||||
SelectList_ERROR
|
||||
: ErrorList
|
||||
| SelectList ',' ErrorList
|
||||
| ErrorList ',' SelectList ',' ErrorList
|
||||
| ErrorList ',' SelectList
|
||||
| SelectList ',' ErrorList ',' SelectList
|
||||
;
|
||||
|
||||
SelectList_ERROR_EDIT
|
||||
: ErrorList ',' SelectList_EDIT -> $3
|
||||
| SelectList ',' ErrorList ',' SelectList_EDIT -> $5
|
||||
| ErrorList ',' SelectList ',' ErrorList ',' SelectList_EDIT -> $7
|
||||
| ErrorList ',' AnyCursor
|
||||
{
|
||||
$$ = { cursorAtStart : false, suggestFunctions: true, suggestColumns: true, suggestAggregateFunctions: true };
|
||||
}
|
||||
| SelectList ',' ErrorList ',' AnyCursor
|
||||
{
|
||||
$$ = { cursorAtStart : false, suggestFunctions: true, suggestColumns: true, suggestAggregateFunctions: true };
|
||||
}
|
||||
| ErrorList ',' SelectList ',' Errors ',' AnyCursor
|
||||
{
|
||||
$$ = { cursorAtStart : true, suggestFunctions: true, suggestColumns: true, suggestAggregateFunctions: true };
|
||||
}
|
||||
;
|
||||
|
||||
SetSpecification
|
||||
: 'SET' SetOption '=' error
|
||||
;
|
||||
|
||||
ErrorList
|
||||
: error
|
||||
| Errors ',' error
|
||||
;
|
||||
|
||||
JoinType_EDIT
|
||||
: 'FULL' 'CURSOR' error
|
||||
{
|
||||
parser.suggestKeywords(['JOIN', 'OUTER JOIN']);
|
||||
}
|
||||
| 'LEFT' 'CURSOR' error
|
||||
{
|
||||
parser.suggestKeywords(['JOIN', 'OUTER JOIN']);
|
||||
}
|
||||
| 'RIGHT' 'CURSOR' error
|
||||
{
|
||||
parser.suggestKeywords(['JOIN', 'OUTER JOIN']);
|
||||
}
|
||||
;
|
||||
|
||||
OptionalSelectConditions_EDIT
|
||||
: WhereClause error 'CURSOR' OptionalGroupByClause OptionalHavingClause OptionalOrderByClause OptionalLimitClause
|
||||
{
|
||||
$$ = {
|
||||
suggestKeywords: parser.getKeywordsForOptionalsLR([$4, $5, $6, $7], [{ value: 'GROUP BY', weight: 8 }, { value: 'HAVING', weight: 7 }, { value: 'ORDER BY', weight: 5 }, { value: 'LIMIT', weight: 3 }], [true, true, true, true]),
|
||||
cursorAtEnd: !$4 && !$5 && !$6 && !$7
|
||||
};
|
||||
}
|
||||
| OptionalWhereClause OptionalGroupByClause HavingClause error 'CURSOR' OptionalOrderByClause OptionalLimitClause
|
||||
{
|
||||
$$ = {
|
||||
suggestKeywords: parser.getKeywordsForOptionalsLR([$6, $7], [{ value: 'ORDER BY', weight: 5 }, { value: 'LIMIT', weight: 3 }], [true, true]),
|
||||
cursorAtEnd: !$6 && !$7
|
||||
}
|
||||
}
|
||||
| OptionalWhereClause OptionalGroupByClause OptionalHavingClause OrderByClause error 'CURSOR' OptionalLimitClause
|
||||
{
|
||||
$$ = {
|
||||
suggestKeywords: parser.getKeywordsForOptionalsLR([$7], [{ value: 'LIMIT', weight: 3 }], [true]),
|
||||
cursorAtEnd: !$7
|
||||
}
|
||||
}
|
||||
| OptionalWhereClause OptionalGroupByClause OptionalHavingClause OptionalOrderByClause LimitClause error 'CURSOR'
|
||||
;
|
||||
|
||||
OptionalSelectConditions_EDIT
|
||||
: WhereClause error GroupByClause_EDIT OptionalHavingClause OptionalOrderByClause OptionalLimitClause
|
||||
| WhereClause error OptionalGroupByClause HavingClause_EDIT OptionalOrderByClause OptionalLimitClause
|
||||
| WhereClause error OptionalGroupByClause OptionalHavingClause OrderByClause_EDIT OptionalLimitClause
|
||||
| WhereClause error OptionalGroupByClause OptionalHavingClause OptionalOrderByClause LimitClause_EDIT
|
||||
| OptionalWhereClause GroupByClause error HavingClause_EDIT OptionalOrderByClause OptionalLimitClause
|
||||
| OptionalWhereClause GroupByClause error OptionalHavingClause OrderByClause_EDIT OptionalLimitClause
|
||||
| OptionalWhereClause GroupByClause error OptionalHavingClause OptionalOrderByClause LimitClause_EDIT
|
||||
| OptionalWhereClause OptionalGroupByClause HavingClause error OrderByClause_EDIT OptionalLimitClause
|
||||
| OptionalWhereClause OptionalGroupByClause HavingClause error OptionalOrderByClause LimitClause_EDIT
|
||||
| OptionalWhereClause OptionalGroupByClause OptionalHavingClause OrderByClause error LimitClause_EDIT
|
||||
;
|
||||
|
||||
DatabaseDefinition_EDIT
|
||||
: 'CREATE' DatabaseOrSchema OptionalIfNotExists RegularIdentifier DatabaseDefinitionOptionals_EDIT error
|
||||
;
|
@ -1,72 +0,0 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataManipulation
|
||||
: InsertStatement
|
||||
;
|
||||
|
||||
InsertStatement
|
||||
: InsertValuesStatement
|
||||
;
|
||||
|
||||
DataManipulation_EDIT
|
||||
: InsertValuesStatement_EDIT
|
||||
;
|
||||
|
||||
InsertValuesStatement
|
||||
: 'INSERT' 'INTO' OptionalTable SchemaQualifiedTableIdentifier 'VALUES' InsertValuesList
|
||||
{
|
||||
$4.owner = 'insert';
|
||||
parser.addTablePrimary($4);
|
||||
}
|
||||
;
|
||||
|
||||
InsertValuesStatement_EDIT
|
||||
: 'INSERT' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['INTO']);
|
||||
}
|
||||
| 'INSERT' 'INTO' OptionalTable 'CURSOR'
|
||||
{
|
||||
if (!$3) {
|
||||
parser.suggestKeywords(['TABLE']);
|
||||
}
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'INSERT' 'INTO' OptionalTable SchemaQualifiedTableIdentifier_EDIT
|
||||
| 'INSERT' 'INTO' OptionalTable SchemaQualifiedTableIdentifier 'CURSOR'
|
||||
{
|
||||
$4.owner = 'insert';
|
||||
parser.addTablePrimary($4);
|
||||
parser.suggestKeywords(['VALUES']);
|
||||
}
|
||||
| 'INSERT' 'INTO' OptionalTable SchemaQualifiedTableIdentifier_EDIT 'VALUES' InsertValuesList
|
||||
;
|
||||
|
||||
InsertValuesList
|
||||
: ParenthesizedRowValuesList
|
||||
| RowValuesList ',' ParenthesizedRowValuesList
|
||||
;
|
||||
|
||||
ParenthesizedRowValuesList
|
||||
: '(' InValueList ')'
|
||||
;
|
||||
|
||||
OptionalTable
|
||||
:
|
||||
| 'TABLE'
|
||||
;
|
File diff suppressed because it is too large
Load Diff
@ -1,46 +0,0 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataDefinition
|
||||
: SetSpecification
|
||||
;
|
||||
|
||||
DataDefinition_EDIT
|
||||
: 'SET' 'CURSOR'
|
||||
{
|
||||
parser.suggestSetOptions();
|
||||
}
|
||||
;
|
||||
|
||||
SetSpecification
|
||||
: 'SET' SetOption '=' SetValue
|
||||
| 'SET' 'ALL'
|
||||
;
|
||||
|
||||
SetOption
|
||||
: RegularIdentifier
|
||||
| SetOption '.' RegularIdentifier
|
||||
;
|
||||
|
||||
SetValue
|
||||
: RegularIdentifier
|
||||
| SignedInteger
|
||||
| SignedInteger RegularIdentifier
|
||||
| QuotedValue
|
||||
| 'TRUE'
|
||||
| 'FALSE'
|
||||
| 'NULL'
|
||||
;
|
@ -1,122 +0,0 @@
|
||||
// Licensed to Cloudera, Inc. under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. Cloudera, Inc. licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
DataManipulation
|
||||
: UpdateStatement
|
||||
;
|
||||
|
||||
DataManipulation_EDIT
|
||||
: UpdateStatement_EDIT
|
||||
;
|
||||
|
||||
UpdateStatement
|
||||
: 'UPDATE' TargetTable 'SET' SetClauseList OptionalFromJoinedTable OptionalWhereClause
|
||||
;
|
||||
|
||||
UpdateStatement_EDIT
|
||||
: 'UPDATE' TargetTable_EDIT 'SET' SetClauseList OptionalFromJoinedTable OptionalWhereClause
|
||||
| 'UPDATE' TargetTable 'SET' SetClauseList_EDIT OptionalFromJoinedTable OptionalWhereClause
|
||||
| 'UPDATE' TargetTable 'SET' SetClauseList FromJoinedTable_EDIT OptionalWhereClause
|
||||
| 'UPDATE' TargetTable 'SET' SetClauseList OptionalFromJoinedTable WhereClause_EDIT
|
||||
| 'UPDATE' TargetTable 'SET' SetClauseList OptionalFromJoinedTable OptionalWhereClause 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords([ 'WHERE' ]);
|
||||
}
|
||||
| 'UPDATE' TargetTable 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords([ 'SET' ]);
|
||||
}
|
||||
| 'UPDATE' TargetTable_EDIT
|
||||
| 'UPDATE' TargetTable
|
||||
| 'UPDATE' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
;
|
||||
|
||||
TargetTable
|
||||
: TableName
|
||||
;
|
||||
|
||||
TargetTable_EDIT
|
||||
: TableName_EDIT
|
||||
;
|
||||
|
||||
TableName
|
||||
: LocalOrSchemaQualifiedName
|
||||
{
|
||||
parser.addTablePrimary($1);
|
||||
}
|
||||
;
|
||||
|
||||
TableName_EDIT
|
||||
: LocalOrSchemaQualifiedName_EDIT
|
||||
;
|
||||
|
||||
SetClauseList
|
||||
: SetClause
|
||||
| SetClauseList ',' SetClause
|
||||
;
|
||||
|
||||
SetClauseList_EDIT
|
||||
: SetClause_EDIT
|
||||
| SetClauseList ',' SetClause_EDIT
|
||||
| SetClause_EDIT ',' SetClauseList
|
||||
| SetClauseList ',' SetClause_EDIT ',' SetClauseList
|
||||
;
|
||||
|
||||
SetClause
|
||||
: SetTarget '=' UpdateSource
|
||||
;
|
||||
|
||||
SetClause_EDIT
|
||||
: SetTarget '=' UpdateSource_EDIT
|
||||
| SetTarget 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords([ '=' ]);
|
||||
}
|
||||
| 'CURSOR'
|
||||
{
|
||||
parser.suggestColumns();
|
||||
}
|
||||
;
|
||||
|
||||
SetTarget
|
||||
: ColumnReference
|
||||
;
|
||||
|
||||
UpdateSource
|
||||
: ValueExpression
|
||||
;
|
||||
|
||||
UpdateSource_EDIT
|
||||
: ValueExpression_EDIT
|
||||
;
|
||||
|
||||
OptionalFromJoinedTable
|
||||
:
|
||||
| 'FROM' TableReference -> $2
|
||||
;
|
||||
|
||||
FromJoinedTable_EDIT
|
||||
: 'FROM' 'CURSOR'
|
||||
{
|
||||
parser.suggestTables();
|
||||
parser.suggestDatabases({ appendDot: true });
|
||||
}
|
||||
| 'FROM' TableReference_EDIT
|
||||
;
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user