refactor: unify the parser generator to antlr4
This commit is contained in:
parent
534e42ee63
commit
c069f9f714
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
|
||||
};
|
||||
});
|
63
src/core/common/baseParser.ts
Normal file
63
src/core/common/baseParser.ts
Normal file
@ -0,0 +1,63 @@
|
||||
import { Token, Lexer } from 'antlr4';
|
||||
|
||||
import ParserErrorListener, { ParserError } from './parserErrorListener';
|
||||
|
||||
/**
|
||||
* Custom Parser class, subclass needs extends it.
|
||||
*/
|
||||
export default abstract class BaseParser {
|
||||
/**
|
||||
* Create antrl4 Lexer object
|
||||
* @param input source string
|
||||
*/
|
||||
public abstract createLexer(input: string): Lexer;
|
||||
|
||||
/**
|
||||
* Create Parser by lexer
|
||||
* @param lexer Lexer
|
||||
*/
|
||||
public abstract createParserFromLexer(lexer: Lexer);
|
||||
|
||||
public getAllTokens(input: string): Token[] {
|
||||
return this.createLexer(input).getAllTokens();
|
||||
};
|
||||
|
||||
public createParser(input: string) {
|
||||
const lexer = this.createLexer(input);
|
||||
return this.createParserFromLexer(lexer);
|
||||
}
|
||||
|
||||
public parserTree(input: string) {
|
||||
const lexer = this.createLexer(input);
|
||||
const parser: any = this.createParserFromLexer(lexer);
|
||||
parser.buildParseTrees = true;
|
||||
return parser;
|
||||
}
|
||||
|
||||
/**
|
||||
* It convert tree to string, it's convenient to use in unit test.
|
||||
* @param string input
|
||||
*/
|
||||
public parserTreeToString(input: string): string {
|
||||
const parser = this.parserTree(input);
|
||||
const tree = parser.statement();
|
||||
return tree.toStringTree(parser.ruleNames);
|
||||
}
|
||||
|
||||
public validate(input: string): ParserError[] {
|
||||
const lexerError = []; const syntaxErrors = [];
|
||||
const lexer = this.createLexer(input);
|
||||
lexer.removeErrorListeners();
|
||||
lexer.addErrorListener(new ParserErrorListener(lexerError));
|
||||
|
||||
const parser: any = this.createParserFromLexer(lexer);
|
||||
parser.buildParseTrees = true;
|
||||
|
||||
parser.removeErrorListeners();
|
||||
parser.addErrorListener(new ParserErrorListener(syntaxErrors));
|
||||
|
||||
parser.statement();
|
||||
|
||||
return lexerError.concat(syntaxErrors);
|
||||
}
|
||||
}
|
36
src/core/common/parserErrorListener.ts
Normal file
36
src/core/common/parserErrorListener.ts
Normal file
@ -0,0 +1,36 @@
|
||||
import { Token, Recognizer } from 'antlr4';
|
||||
import { ErrorListener } from 'antlr4/error';
|
||||
|
||||
export interface ParserError {
|
||||
startLine: number;
|
||||
endLine: number;
|
||||
startCol: number;
|
||||
endCol: number;
|
||||
message: string;
|
||||
}
|
||||
|
||||
export default class ParserErrorListener extends ErrorListener {
|
||||
private _errors: ParserError[] = [];
|
||||
|
||||
constructor(errors: ParserError[]) {
|
||||
super();
|
||||
this._errors = errors;
|
||||
}
|
||||
|
||||
syntaxError(
|
||||
recognizer: Recognizer, offendingSymbol: Token, line: number,
|
||||
charPositionInLine: number, msg: string, e: any,
|
||||
) {
|
||||
let endCol = charPositionInLine + 1;
|
||||
if (offendingSymbol.text !== null) {
|
||||
endCol = charPositionInLine + offendingSymbol.text.length;
|
||||
}
|
||||
this._errors.push({
|
||||
startLine: line,
|
||||
endLine: line,
|
||||
startCol: charPositionInLine,
|
||||
endCol: endCol,
|
||||
message: msg,
|
||||
});
|
||||
}
|
||||
}
|
2
src/core/index.ts
Normal file
2
src/core/index.ts
Normal file
@ -0,0 +1,2 @@
|
||||
export * as mySQLParser from './mysql';
|
||||
export * as tSQLParser from './tsql';
|
17
src/core/mysql.ts
Normal file
17
src/core/mysql.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { InputStream, CommonTokenStream, Lexer } from 'antlr4';
|
||||
import { MySQLLexer } from '../parser/MySQLLexer';
|
||||
import { MySQLParser } from '../parser/MySQLParser';
|
||||
|
||||
import BaseParser from './common/baseParser';
|
||||
|
||||
export default class MySQL extends BaseParser {
|
||||
public createLexer(input: string): Lexer {
|
||||
const chars = new InputStream(input.toUpperCase());
|
||||
const lexer = <unknown> new MySQLLexer(chars) as Lexer;
|
||||
return lexer;
|
||||
}
|
||||
public createParserFromLexer(lexer: Lexer) {
|
||||
const tokenStream = new CommonTokenStream(lexer);
|
||||
return new MySQLParser(tokenStream);
|
||||
}
|
||||
}
|
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;
|
17
src/core/tsql.ts
Normal file
17
src/core/tsql.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { InputStream, CommonTokenStream, Lexer } from 'antlr4';
|
||||
import { TSqlParser } from '../parser/TSqlParser';
|
||||
import { TSqlLexer } from '../parser/TSqlLexer';
|
||||
|
||||
import BaseParser from './common/baseParser';
|
||||
|
||||
export default class TSQLParser extends BaseParser {
|
||||
public createLexer(input: string): Lexer {
|
||||
const chars = new InputStream(input.toUpperCase());
|
||||
const lexer = <unknown> new TSqlLexer(chars) as Lexer;
|
||||
return lexer;
|
||||
}
|
||||
public createParserFromLexer(lexer: Lexer) {
|
||||
const tokenStream = new CommonTokenStream(lexer);
|
||||
return new TSqlParser(tokenStream);
|
||||
}
|
||||
}
|
4
src/grammar/hello/Hello.g4
Normal file
4
src/grammar/hello/Hello.g4
Normal file
@ -0,0 +1,4 @@
|
||||
grammar helloSQL;
|
||||
r: 'hello' ID ;
|
||||
ID: [a-z]+ ;
|
||||
WS: [ \t\r\n]+ -> skip ;
|
3
src/grammar/hive/README.md
Normal file
3
src/grammar/hive/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# Hive SQL Grammar
|
||||
|
||||
Source file from [Hive Github](https://github.com/apache/hive/tree/master/hplsql/src/main/antlr4/org/apache/hive/hplsql)
|
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)
|
1245
src/grammar/mysql/MySQLLexer.g4
Normal file
1245
src/grammar/mysql/MySQLLexer.g4
Normal file
File diff suppressed because it is too large
Load Diff
2586
src/grammar/mysql/MySQLParser.g4
Normal file
2586
src/grammar/mysql/MySQLParser.g4
Normal file
File diff suppressed because it is too large
Load Diff
3
src/grammar/mysql/README.md
Normal file
3
src/grammar/mysql/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# MySQL Grammar
|
||||
|
||||
[MySQL Grammar](https://github.com/mysql/mysql-workbench/tree/8.0/library/parsers/grammars)
|
2543
src/grammar/tsql/.antlr/TSqlLexer.interp
Normal file
2543
src/grammar/tsql/.antlr/TSqlLexer.interp
Normal file
File diff suppressed because one or more lines are too long
2178
src/grammar/tsql/.antlr/TSqlParser.interp
Normal file
2178
src/grammar/tsql/.antlr/TSqlParser.interp
Normal file
File diff suppressed because one or more lines are too long
902
src/grammar/tsql/TSqlLexer.g4
Normal file
902
src/grammar/tsql/TSqlLexer.g4
Normal file
@ -0,0 +1,902 @@
|
||||
/*
|
||||
T-SQL (Transact-SQL, MSSQL) grammar.
|
||||
The MIT License (MIT).
|
||||
Copyright (c) 2017, Mark Adams (madams51703@gmail.com)
|
||||
Copyright (c) 2015-2017, Ivan Kochurkin (kvanttt@gmail.com), Positive Technologies.
|
||||
Copyright (c) 2016, Scott Ure (scott@redstormsoftware.com).
|
||||
Copyright (c) 2016, Rui Zhang (ruizhang.ccs@gmail.com).
|
||||
Copyright (c) 2016, Marcus Henriksson (kuseman80@gmail.com).
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
lexer grammar TSqlLexer;
|
||||
|
||||
// Basic keywords (from https://msdn.microsoft.com/en-us/library/ms189822.aspx)
|
||||
ABSENT: 'ABSENT';
|
||||
ADD: 'ADD';
|
||||
AES: 'AES';
|
||||
ALL: 'ALL';
|
||||
ALLOW_CONNECTIONS: 'ALLOW_CONNECTIONS';
|
||||
ALLOW_MULTIPLE_EVENT_LOSS: 'ALLOW_MULTIPLE_EVENT_LOSS';
|
||||
ALLOW_SINGLE_EVENT_LOSS: 'ALLOW_SINGLE_EVENT_LOSS';
|
||||
ALTER: 'ALTER';
|
||||
AND: 'AND';
|
||||
ANONYMOUS: 'ANONYMOUS';
|
||||
ANY: 'ANY';
|
||||
APPEND: 'APPEND';
|
||||
APPLICATION: 'APPLICATION';
|
||||
AS: 'AS';
|
||||
ASC: 'ASC';
|
||||
ASYMMETRIC: 'ASYMMETRIC';
|
||||
ASYNCHRONOUS_COMMIT: 'ASYNCHRONOUS_COMMIT';
|
||||
AUTHORIZATION: 'AUTHORIZATION';
|
||||
AUTHENTICATION: 'AUTHENTICATION';
|
||||
AUTOMATED_BACKUP_PREFERENCE: 'AUTOMATED_BACKUP_PREFERENCE';
|
||||
AUTOMATIC: 'AUTOMATIC';
|
||||
AVAILABILITY_MODE: 'AVAILABILITY_MODE';
|
||||
BACKSLASH: '\\';
|
||||
BACKUP: 'BACKUP';
|
||||
BEFORE: 'BEFORE';
|
||||
BEGIN: 'BEGIN';
|
||||
BETWEEN: 'BETWEEN';
|
||||
BLOCK: 'BLOCK';
|
||||
BLOCKSIZE: 'BLOCKSIZE';
|
||||
BLOCKING_HIERARCHY: 'BLOCKING_HIERARCHY';
|
||||
BREAK: 'BREAK';
|
||||
BROWSE: 'BROWSE';
|
||||
BUFFER: 'BUFFER';
|
||||
BUFFERCOUNT: 'BUFFERCOUNT';
|
||||
BULK: 'BULK';
|
||||
BY: 'BY';
|
||||
CACHE: 'CACHE';
|
||||
CALLED: 'CALLED';
|
||||
CASCADE: 'CASCADE';
|
||||
CASE: 'CASE';
|
||||
CERTIFICATE: 'CERTIFICATE';
|
||||
CHANGETABLE: 'CHANGETABLE';
|
||||
CHANGES: 'CHANGES';
|
||||
CHECK: 'CHECK';
|
||||
CHECKPOINT: 'CHECKPOINT';
|
||||
CHECK_POLICY: 'CHECK_POLICY';
|
||||
CHECK_EXPIRATION: 'CHECK_EXPIRATION';
|
||||
CLASSIFIER_FUNCTION: 'CLASSIFIER_FUNCTION';
|
||||
CLOSE: 'CLOSE';
|
||||
CLUSTER: 'CLUSTER';
|
||||
CLUSTERED: 'CLUSTERED';
|
||||
COALESCE: 'COALESCE';
|
||||
COLLATE: 'COLLATE';
|
||||
COLUMN: 'COLUMN';
|
||||
COMPRESSION: 'COMPRESSION';
|
||||
COMMIT: 'COMMIT';
|
||||
COMPUTE: 'COMPUTE';
|
||||
CONFIGURATION: 'CONFIGURATION';
|
||||
CONSTRAINT: 'CONSTRAINT';
|
||||
CONTAINMENT: 'CONTAINMENT';
|
||||
CONTAINS: 'CONTAINS';
|
||||
CONTAINSTABLE: 'CONTAINSTABLE';
|
||||
CONTEXT: 'CONTEXT';
|
||||
CONTINUE: 'CONTINUE';
|
||||
CONTINUE_AFTER_ERROR: 'CONTINUE_AFTER_ERROR';
|
||||
CONTRACT: 'CONTRACT';
|
||||
CONTRACT_NAME: 'CONTRACT_NAME';
|
||||
CONVERSATION: 'CONVERSATION';
|
||||
CONVERT: 'TRY_'? 'CONVERT';
|
||||
COPY_ONLY: 'COPY_ONLY';
|
||||
CREATE: 'CREATE';
|
||||
CROSS: 'CROSS';
|
||||
CURRENT: 'CURRENT';
|
||||
CURRENT_DATE: 'CURRENT_DATE';
|
||||
CURRENT_TIME: 'CURRENT_TIME';
|
||||
CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP';
|
||||
CURRENT_USER: 'CURRENT_USER';
|
||||
CURSOR: 'CURSOR';
|
||||
CYCLE: 'CYCLE';
|
||||
DATA_COMPRESSION: 'DATA_COMPRESSION';
|
||||
DATA_SOURCE: 'DATA_SOURCE';
|
||||
DATABASE: 'DATABASE';
|
||||
DATABASE_MIRRORING: 'DATABASE_MIRRORING';
|
||||
DBCC: 'DBCC';
|
||||
DEALLOCATE: 'DEALLOCATE';
|
||||
DECLARE: 'DECLARE';
|
||||
DEFAULT: 'DEFAULT';
|
||||
DEFAULT_DATABASE: 'DEFAULT_DATABASE';
|
||||
DEFAULT_SCHEMA: 'DEFAULT_SCHEMA';
|
||||
DELETE: 'DELETE';
|
||||
DENY: 'DENY';
|
||||
DESC: 'DESC';
|
||||
DIAGNOSTICS: 'DIAGNOSTICS';
|
||||
DIFFERENTIAL: 'DIFFERENTIAL';
|
||||
DISK: 'DISK';
|
||||
DISTINCT: 'DISTINCT';
|
||||
DISTRIBUTED: 'DISTRIBUTED';
|
||||
DOUBLE: 'DOUBLE';
|
||||
DOUBLE_BACK_SLASH: '\\\\';
|
||||
DOUBLE_FORWARD_SLASH: '//';
|
||||
DROP: 'DROP';
|
||||
DTC_SUPPORT: 'DTC_SUPPORT';
|
||||
DUMP: 'DUMP';
|
||||
ELSE: 'ELSE';
|
||||
ENABLED: 'ENABLED';
|
||||
END: 'END';
|
||||
ENDPOINT: 'ENDPOINT';
|
||||
ERRLVL: 'ERRLVL';
|
||||
ESCAPE: 'ESCAPE';
|
||||
ERROR: 'ERROR';
|
||||
EVENT: 'EVENT';
|
||||
EVENTDATA: 'EVENTDATA' '(' ')';
|
||||
EVENT_RETENTION_MODE: 'EVENT_RETENTION_MODE';
|
||||
EXCEPT: 'EXCEPT';
|
||||
EXECUTABLE_FILE: 'EXECUTABLE_FILE';
|
||||
EXECUTE: 'EXEC' 'UTE'?;
|
||||
EXISTS: 'EXISTS';
|
||||
EXPIREDATE: 'EXPIREDATE';
|
||||
EXIT: 'EXIT';
|
||||
EXTENSION: 'EXTENSION';
|
||||
EXTERNAL: 'EXTERNAL';
|
||||
EXTERNAL_ACCESS: 'EXTERNAL_ACCESS';
|
||||
FAILOVER: 'FAILOVER';
|
||||
FAILURECONDITIONLEVEL: 'FAILURECONDITIONLEVEL';
|
||||
FAN_IN: 'FAN_IN';
|
||||
FETCH: 'FETCH';
|
||||
FILE: 'FILE';
|
||||
FILENAME: 'FILENAME';
|
||||
FILLFACTOR: 'FILLFACTOR';
|
||||
FILE_SNAPSHOT: 'FILE_SNAPSHOT';
|
||||
FOR: 'FOR';
|
||||
FORCESEEK: 'FORCESEEK';
|
||||
FORCE_SERVICE_ALLOW_DATA_LOSS: 'FORCE_SERVICE_ALLOW_DATA_LOSS';
|
||||
FOREIGN: 'FOREIGN';
|
||||
FREETEXT: 'FREETEXT';
|
||||
FREETEXTTABLE: 'FREETEXTTABLE';
|
||||
FROM: 'FROM';
|
||||
FULL: 'FULL';
|
||||
FUNCTION: 'FUNCTION';
|
||||
GET: 'GET';
|
||||
GOTO: 'GOTO';
|
||||
GOVERNOR: 'GOVERNOR';
|
||||
GRANT: 'GRANT';
|
||||
GROUP: 'GROUP';
|
||||
HAVING: 'HAVING';
|
||||
HASHED: 'HASHED';
|
||||
HEALTHCHECKTIMEOUT: 'HEALTHCHECKTIMEOUT';
|
||||
IDENTITY: 'IDENTITY';
|
||||
IDENTITYCOL: 'IDENTITYCOL';
|
||||
IDENTITY_INSERT: 'IDENTITY_INSERT';
|
||||
IF: 'IF';
|
||||
IIF: 'IIF';
|
||||
IN: 'IN';
|
||||
INCLUDE: 'INCLUDE';
|
||||
INCREMENT: 'INCREMENT';
|
||||
INDEX: 'INDEX';
|
||||
INFINITE: 'INFINITE';
|
||||
INIT: 'INIT';
|
||||
INNER: 'INNER';
|
||||
INSERT: 'INSERT';
|
||||
INSTEAD: 'INSTEAD';
|
||||
INTERSECT: 'INTERSECT';
|
||||
INTO: 'INTO';
|
||||
IPV4_ADDR: [']? IPV4_OCTECT DOT IPV4_OCTECT DOT IPV4_OCTECT DOT IPV4_OCTECT [']?;
|
||||
IPV6_ADDR: [']?[0-9A-F]?[0-9A-F]?[0-9A-F]?[0-9A-F]?[:][0-9A-F]?[0-9A-F]?[0-9A-F]?[0-9A-F]?[:][0-9A-F]?[0-9A-F]?[0-9A-F]?[0-9A-F]?[:][0-9A-F]?[0-9A-F]?[0-9A-F]?[0-9A-F]?[:][0-9A-F]?[0-9A-F]?[0-9A-F]?[0-9A-F]?[:][0-9A-F]?[0-9A-F]?[0-9A-F]?[0-9A-F]?[:][0-9A-F]?[0-9A-F]?[0-9A-F]?[0-9A-F]?[:][0-9A-F]?[0-9A-F]?[0-9A-F]?[0-9A-F]?[']?;
|
||||
IS: 'IS';
|
||||
ISNULL: 'ISNULL';
|
||||
JOIN: 'JOIN';
|
||||
KERBEROS: 'KERBEROS';
|
||||
KEY: 'KEY';
|
||||
KEY_PATH: 'KEY_PATH';
|
||||
KEY_STORE_PROVIDER_NAME: 'KEY_STORE_PROVIDER_NAME';
|
||||
KILL: 'KILL';
|
||||
LANGUAGE: 'LANGUAGE';
|
||||
LEFT: 'LEFT';
|
||||
LIBRARY: 'LIBRARY';
|
||||
LIFETIME: 'LIFETIME';
|
||||
LIKE: 'LIKE';
|
||||
LINENO: 'LINENO';
|
||||
LINUX: 'LINUX';
|
||||
LISTENER_IP: 'LISTENER_IP';
|
||||
LISTENER_PORT: 'LISTENER_PORT';
|
||||
LOAD: 'LOAD';
|
||||
LOCAL_SERVICE_NAME: 'LOCAL_SERVICE_NAME';
|
||||
LOG: 'LOG';
|
||||
MATCHED: 'MATCHED';
|
||||
MASTER: 'MASTER';
|
||||
MAX_MEMORY: 'MAX_MEMORY';
|
||||
MAXTRANSFER: 'MAXTRANSFER';
|
||||
MAXVALUE: 'MAXVALUE';
|
||||
MAX_DISPATCH_LATENCY: 'MAX_DISPATCH_LATENCY';
|
||||
MAX_EVENT_SIZE: 'MAX_EVENT_SIZE';
|
||||
MAX_SIZE: 'MAX_SIZE';
|
||||
MAX_OUTSTANDING_IO_PER_VOLUME: 'MAX_OUTSTANDING_IO_PER_VOLUME';
|
||||
MEDIADESCRIPTION: 'MEDIADESCRIPTION';
|
||||
MEDIANAME: 'MEDIANAME';
|
||||
MEMBER: 'MEMBER';
|
||||
MEMORY_PARTITION_MODE: 'MEMORY_PARTITION_MODE';
|
||||
MERGE: 'MERGE';
|
||||
MESSAGE_FORWARDING: 'MESSAGE_FORWARDING';
|
||||
MESSAGE_FORWARD_SIZE: 'MESSAGE_FORWARD_SIZE';
|
||||
MINVALUE: 'MINVALUE';
|
||||
MIRROR: 'MIRROR';
|
||||
MUST_CHANGE: 'MUST_CHANGE';
|
||||
NATIONAL: 'NATIONAL';
|
||||
NEGOTIATE: 'NEGOTIATE';
|
||||
NOCHECK: 'NOCHECK';
|
||||
NOFORMAT: 'NOFORMAT';
|
||||
NOINIT: 'NOINIT';
|
||||
NONCLUSTERED: 'NONCLUSTERED';
|
||||
NONE: 'NONE';
|
||||
NOREWIND: 'NOREWIND';
|
||||
NOSKIP: 'NOSKIP';
|
||||
NOUNLOAD: 'NOUNLOAD';
|
||||
NO_CHECKSUM: 'NO_CHECKSUM';
|
||||
NO_COMPRESSION: 'NO_COMPRESSION';
|
||||
NO_EVENT_LOSS: 'NO_EVENT_LOSS';
|
||||
NOT: 'NOT';
|
||||
NOTIFICATION: 'NOTIFICATION';
|
||||
NTLM: 'NTLM';
|
||||
NULL: 'NULL';
|
||||
NULLIF: 'NULLIF';
|
||||
OF: 'OF';
|
||||
OFF: 'OFF';
|
||||
OFFSETS: 'OFFSETS';
|
||||
OLD_PASSWORD: 'OLD_PASSWORD';
|
||||
ON: 'ON';
|
||||
ON_FAILURE: 'ON_FAILURE';
|
||||
OPEN: 'OPEN';
|
||||
OPENDATASOURCE: 'OPENDATASOURCE';
|
||||
OPENQUERY: 'OPENQUERY';
|
||||
OPENROWSET: 'OPENROWSET';
|
||||
OPENXML: 'OPENXML';
|
||||
OPTION: 'OPTION';
|
||||
OR: 'OR';
|
||||
ORDER: 'ORDER';
|
||||
OUTER: 'OUTER';
|
||||
OVER: 'OVER';
|
||||
PAGE: 'PAGE';
|
||||
PARAM_NODE: 'PARAM_NODE';
|
||||
PARTIAL: 'PARTIAL';
|
||||
PASSWORD: 'PASSWORD';
|
||||
PERCENT: 'PERCENT';
|
||||
PERMISSION_SET: 'PERMISSION_SET';
|
||||
PER_CPU: 'PER_CPU';
|
||||
PER_DB: 'PER_DB';
|
||||
PER_NODE: 'PER_NODE';
|
||||
PIVOT: 'PIVOT';
|
||||
PLAN: 'PLAN';
|
||||
PLATFORM: 'PLATFORM';
|
||||
POLICY: 'POLICY';
|
||||
PRECISION: 'PRECISION';
|
||||
PREDICATE: 'PREDICATE';
|
||||
PRIMARY: 'PRIMARY';
|
||||
PRINT: 'PRINT';
|
||||
PROC: 'PROC';
|
||||
PROCEDURE: 'PROCEDURE';
|
||||
PROCESS: 'PROCESS';
|
||||
PUBLIC: 'PUBLIC';
|
||||
PYTHON: 'PYTHON';
|
||||
R: 'R';
|
||||
RAISERROR: 'RAISERROR';
|
||||
RAW: 'RAW';
|
||||
READ: 'READ';
|
||||
READTEXT: 'READTEXT';
|
||||
READ_WRITE_FILEGROUPS: 'READ_WRITE_FILEGROUPS';
|
||||
RECONFIGURE: 'RECONFIGURE';
|
||||
REFERENCES: 'REFERENCES';
|
||||
REGENERATE: 'REGENERATE';
|
||||
RELATED_CONVERSATION: 'RELATED_CONVERSATION';
|
||||
RELATED_CONVERSATION_GROUP: 'RELATED_CONVERSATION_GROUP';
|
||||
REPLICATION: 'REPLICATION';
|
||||
REQUIRED: 'REQUIRED';
|
||||
RESET: 'RESET';
|
||||
RESTART: 'RESTART';
|
||||
RESTORE: 'RESTORE';
|
||||
RESTRICT: 'RESTRICT';
|
||||
RESUME: 'RESUME';
|
||||
RETAINDAYS: 'RETAINDAYS';
|
||||
RETURN: 'RETURN';
|
||||
RETURNS: 'RETURNS';
|
||||
REVERT: 'REVERT';
|
||||
REVOKE: 'REVOKE';
|
||||
REWIND: 'REWIND';
|
||||
RIGHT: 'RIGHT';
|
||||
ROLLBACK: 'ROLLBACK';
|
||||
ROLE: 'ROLE';
|
||||
ROWCOUNT: 'ROWCOUNT';
|
||||
ROWGUIDCOL: 'ROWGUIDCOL';
|
||||
RSA_512: 'RSA_512';
|
||||
RSA_1024: 'RSA_1024';
|
||||
RSA_2048: 'RSA_2048';
|
||||
RSA_3072: 'RSA_3072';
|
||||
RSA_4096: 'RSA_4096';
|
||||
SAFETY: 'SAFETY';
|
||||
RULE: 'RULE';
|
||||
SAFE: 'SAFE';
|
||||
SAVE: 'SAVE';
|
||||
SCHEDULER: 'SCHEDULER';
|
||||
SCHEMA: 'SCHEMA';
|
||||
SCHEME: 'SCHEME';
|
||||
SECURITYAUDIT: 'SECURITYAUDIT';
|
||||
SELECT: 'SELECT';
|
||||
SEMANTICKEYPHRASETABLE: 'SEMANTICKEYPHRASETABLE';
|
||||
SEMANTICSIMILARITYDETAILSTABLE: 'SEMANTICSIMILARITYDETAILSTABLE';
|
||||
SEMANTICSIMILARITYTABLE: 'SEMANTICSIMILARITYTABLE';
|
||||
SERVER: 'SERVER';
|
||||
SERVICE: 'SERVICE';
|
||||
SERVICE_BROKER: 'SERVICE_BROKER';
|
||||
SERVICE_NAME: 'SERVICE_NAME';
|
||||
SESSION: 'SESSION';
|
||||
SESSION_USER: 'SESSION_USER';
|
||||
SET: 'SET';
|
||||
SETUSER: 'SETUSER';
|
||||
SHUTDOWN: 'SHUTDOWN';
|
||||
SID: 'SID';
|
||||
SKIP_KEYWORD: 'SKIP';
|
||||
SOFTNUMA: 'SOFTNUMA';
|
||||
SOME: 'SOME';
|
||||
SOURCE: 'SOURCE';
|
||||
SPECIFICATION: 'SPECIFICATION';
|
||||
SPLIT: 'SPLIT';
|
||||
SQLDUMPERFLAGS: 'SQLDUMPERFLAGS';
|
||||
SQLDUMPERPATH: 'SQLDUMPERPATH';
|
||||
SQLDUMPERTIMEOUT: 'SQLDUMPERTIMEOUTS';
|
||||
STATISTICS: 'STATISTICS';
|
||||
STATE: 'STATE';
|
||||
STATS: 'STATS';
|
||||
START: 'START';
|
||||
STARTED: 'STARTED';
|
||||
STARTUP_STATE: 'STARTUP_STATE';
|
||||
STOP: 'STOP';
|
||||
STOPPED: 'STOPPED';
|
||||
STOP_ON_ERROR: 'STOP_ON_ERROR';
|
||||
SUPPORTED: 'SUPPORTED';
|
||||
SYSTEM_USER: 'SYSTEM_USER';
|
||||
TABLE: 'TABLE';
|
||||
TABLESAMPLE: 'TABLESAMPLE';
|
||||
TAPE: 'TAPE';
|
||||
TARGET: 'TARGET';
|
||||
TCP: 'TCP';
|
||||
TEXTSIZE: 'TEXTSIZE';
|
||||
THEN: 'THEN';
|
||||
TO: 'TO';
|
||||
TOP: 'TOP';
|
||||
TRACK_CAUSALITY: 'TRACK_CAUSALITY';
|
||||
TRAN: 'TRAN';
|
||||
TRANSACTION: 'TRANSACTION';
|
||||
TRANSFER: 'TRANSFER';
|
||||
TRIGGER: 'TRIGGER';
|
||||
TRUNCATE: 'TRUNCATE';
|
||||
TSEQUAL: 'TSEQUAL';
|
||||
UNCHECKED: 'UNCHECKED';
|
||||
UNION: 'UNION';
|
||||
UNIQUE: 'UNIQUE';
|
||||
UNLOCK: 'UNLOCK';
|
||||
UNPIVOT: 'UNPIVOT';
|
||||
UNSAFE: 'UNSAFE';
|
||||
UPDATE: 'UPDATE';
|
||||
UPDATETEXT: 'UPDATETEXT';
|
||||
URL: 'URL';
|
||||
USE: 'USE';
|
||||
USED: 'USED';
|
||||
USER: 'USER';
|
||||
VALUES: 'VALUES';
|
||||
VARYING: 'VARYING';
|
||||
VERBOSELOGGING: 'VERBOSELOGGING';
|
||||
VIEW: 'VIEW';
|
||||
VISIBILITY: 'VISIBILITY';
|
||||
WAITFOR: 'WAITFOR';
|
||||
WHEN: 'WHEN';
|
||||
WHERE: 'WHERE';
|
||||
WHILE: 'WHILE';
|
||||
WINDOWS: 'WINDOWS';
|
||||
WITH: 'WITH';
|
||||
WITHIN: 'WITHIN';
|
||||
WITHOUT: 'WITHOUT';
|
||||
WITNESS: 'WITNESS';
|
||||
WRITETEXT: 'WRITETEXT';
|
||||
|
||||
// Additional keywords. They can be id, please keep them in sync with the parser.
|
||||
ABSOLUTE: 'ABSOLUTE';
|
||||
ACCENT_SENSITIVITY: 'ACCENT_SENSITIVITY';
|
||||
ACTION: 'ACTION';
|
||||
ACTIVATION: 'ACTIVATION';
|
||||
ACTIVE: 'ACTIVE';
|
||||
ADDRESS: 'ADDRESS';
|
||||
AES_128: 'AES_128';
|
||||
AES_192: 'AES_192';
|
||||
AES_256: 'AES_256';
|
||||
AFFINITY: 'AFFINITY';
|
||||
AFTER: 'AFTER';
|
||||
AGGREGATE: 'AGGREGATE';
|
||||
ALGORITHM: 'ALGORITHM';
|
||||
ALLOW_ENCRYPTED_VALUE_MODIFICATIONS: 'ALLOW_ENCRYPTED_VALUE_MODIFICATIONS';
|
||||
ALLOW_SNAPSHOT_ISOLATION: 'ALLOW_SNAPSHOT_ISOLATION';
|
||||
ALLOWED: 'ALLOWED';
|
||||
ANSI_NULL_DEFAULT: 'ANSI_NULL_DEFAULT';
|
||||
ANSI_NULLS: 'ANSI_NULLS';
|
||||
ANSI_PADDING: 'ANSI_PADDING';
|
||||
ANSI_WARNINGS: 'ANSI_WARNINGS';
|
||||
APPLICATION_LOG: 'APPLICATION_LOG';
|
||||
APPLY: 'APPLY';
|
||||
ARITHABORT: 'ARITHABORT';
|
||||
ASSEMBLY: 'ASSEMBLY';
|
||||
AUDIT: 'AUDIT';
|
||||
AUDIT_GUID: 'AUDIT_GUID';
|
||||
AUTO: 'AUTO';
|
||||
AUTO_CLEANUP: 'AUTO_CLEANUP';
|
||||
AUTO_CLOSE: 'AUTO_CLOSE';
|
||||
AUTO_CREATE_STATISTICS: 'AUTO_CREATE_STATISTICS';
|
||||
AUTO_SHRINK: 'AUTO_SHRINK';
|
||||
AUTO_UPDATE_STATISTICS: 'AUTO_UPDATE_STATISTICS';
|
||||
AUTO_UPDATE_STATISTICS_ASYNC: 'AUTO_UPDATE_STATISTICS_ASYNC';
|
||||
AVAILABILITY: 'AVAILABILITY';
|
||||
AVG: 'AVG';
|
||||
BACKUP_PRIORITY: 'BACKUP_PRIORITY';
|
||||
BEGIN_DIALOG: 'BEGIN_DIALOG';
|
||||
BIGINT: 'BIGINT';
|
||||
BINARY_BASE64: 'BINARY BASE64';
|
||||
BINARY_CHECKSUM: 'BINARY_CHECKSUM';
|
||||
BINDING: 'BINDING';
|
||||
BLOB_STORAGE: 'BLOB_STORAGE';
|
||||
BROKER: 'BROKER';
|
||||
BROKER_INSTANCE: 'BROKER_INSTANCE';
|
||||
BULK_LOGGED: 'BULK_LOGGED';
|
||||
CALLER: 'CALLER';
|
||||
CAP_CPU_PERCENT: 'CAP_CPU_PERCENT';
|
||||
CAST: 'TRY_'? 'CAST';
|
||||
CATALOG: 'CATALOG';
|
||||
CATCH: 'CATCH';
|
||||
CHANGE_RETENTION: 'CHANGE_RETENTION';
|
||||
CHANGE_TRACKING: 'CHANGE_TRACKING';
|
||||
CHECKSUM: 'CHECKSUM';
|
||||
CHECKSUM_AGG: 'CHECKSUM_AGG';
|
||||
CLEANUP: 'CLEANUP';
|
||||
COLLECTION: 'COLLECTION';
|
||||
COLUMN_MASTER_KEY: 'COLUMN_MASTER_KEY';
|
||||
COMMITTED: 'COMMITTED';
|
||||
COMPATIBILITY_LEVEL: 'COMPATIBILITY_LEVEL';
|
||||
CONCAT: 'CONCAT';
|
||||
CONCAT_NULL_YIELDS_NULL: 'CONCAT_NULL_YIELDS_NULL';
|
||||
CONTENT: 'CONTENT';
|
||||
CONTROL: 'CONTROL';
|
||||
COOKIE: 'COOKIE';
|
||||
COUNT: 'COUNT';
|
||||
COUNT_BIG: 'COUNT_BIG';
|
||||
COUNTER: 'COUNTER';
|
||||
CPU: 'CPU';
|
||||
CREATE_NEW: 'CREATE_NEW';
|
||||
CREATION_DISPOSITION: 'CREATION_DISPOSITION';
|
||||
CREDENTIAL: 'CREDENTIAL';
|
||||
CRYPTOGRAPHIC: 'CRYPTOGRAPHIC';
|
||||
CURSOR_CLOSE_ON_COMMIT: 'CURSOR_CLOSE_ON_COMMIT';
|
||||
CURSOR_DEFAULT: 'CURSOR_DEFAULT';
|
||||
DATA: 'DATA';
|
||||
DATE_CORRELATION_OPTIMIZATION: 'DATE_CORRELATION_OPTIMIZATION';
|
||||
DATEADD: 'DATEADD';
|
||||
DATEDIFF: 'DATEDIFF';
|
||||
DATENAME: 'DATENAME';
|
||||
DATEPART: 'DATEPART';
|
||||
DAYS: 'DAYS';
|
||||
DB_CHAINING: 'DB_CHAINING';
|
||||
DB_FAILOVER: 'DB_FAILOVER';
|
||||
DECRYPTION: 'DECRYPTION';
|
||||
DEFAULT_DOUBLE_QUOTE: ["]'DEFAULT'["];
|
||||
DEFAULT_FULLTEXT_LANGUAGE: 'DEFAULT_FULLTEXT_LANGUAGE';
|
||||
DEFAULT_LANGUAGE: 'DEFAULT_LANGUAGE';
|
||||
DELAY: 'DELAY';
|
||||
DELAYED_DURABILITY: 'DELAYED_DURABILITY';
|
||||
DELETED: 'DELETED';
|
||||
DENSE_RANK: 'DENSE_RANK';
|
||||
DEPENDENTS: 'DEPENDENTS';
|
||||
DES: 'DES';
|
||||
DESCRIPTION: 'DESCRIPTION';
|
||||
DESX: 'DESX';
|
||||
DHCP: 'DHCP';
|
||||
DIALOG: 'DIALOG';
|
||||
DIRECTORY_NAME: 'DIRECTORY_NAME';
|
||||
DISABLE: 'DISABLE';
|
||||
DISABLE_BROKER: 'DISABLE_BROKER';
|
||||
DISABLED: 'DISABLED';
|
||||
DISK_DRIVE: [A-Z][:];
|
||||
DOCUMENT: 'DOCUMENT';
|
||||
DYNAMIC: 'DYNAMIC';
|
||||
ELEMENTS: 'ELEMENTS';
|
||||
EMERGENCY: 'EMERGENCY';
|
||||
EMPTY: 'EMPTY';
|
||||
ENABLE: 'ENABLE';
|
||||
ENABLE_BROKER: 'ENABLE_BROKER';
|
||||
ENCRYPTED_VALUE: 'ENCRYPTED_VALUE';
|
||||
ENCRYPTION: 'ENCRYPTION';
|
||||
ENDPOINT_URL: 'ENDPOINT_URL';
|
||||
ERROR_BROKER_CONVERSATIONS: 'ERROR_BROKER_CONVERSATIONS';
|
||||
EXCLUSIVE: 'EXCLUSIVE';
|
||||
EXECUTABLE: 'EXECUTABLE';
|
||||
EXIST: 'EXIST';
|
||||
EXPAND: 'EXPAND';
|
||||
EXPIRY_DATE: 'EXPIRY_DATE';
|
||||
EXPLICIT: 'EXPLICIT';
|
||||
FAIL_OPERATION: 'FAIL_OPERATION';
|
||||
FAILOVER_MODE: 'FAILOVER_MODE';
|
||||
FAILURE: 'FAILURE';
|
||||
FAILURE_CONDITION_LEVEL: 'FAILURE_CONDITION_LEVEL';
|
||||
FAST: 'FAST';
|
||||
FAST_FORWARD: 'FAST_FORWARD';
|
||||
FILEGROUP: 'FILEGROUP';
|
||||
FILEGROWTH: 'FILEGROWTH';
|
||||
FILEPATH: 'FILEPATH';
|
||||
FILESTREAM: 'FILESTREAM';
|
||||
FILTER: 'FILTER';
|
||||
FIRST: 'FIRST';
|
||||
FIRST_VALUE: 'FIRST_VALUE';
|
||||
FOLLOWING: 'FOLLOWING';
|
||||
FORCE: 'FORCE';
|
||||
FORCE_FAILOVER_ALLOW_DATA_LOSS: 'FORCE_FAILOVER_ALLOW_DATA_LOSS';
|
||||
FORCED: 'FORCED';
|
||||
FORMAT: 'FORMAT';
|
||||
FORWARD_ONLY: 'FORWARD_ONLY';
|
||||
FULLSCAN: 'FULLSCAN';
|
||||
FULLTEXT: 'FULLTEXT';
|
||||
GB: 'GB';
|
||||
GETDATE: 'GETDATE';
|
||||
GETUTCDATE: 'GETUTCDATE';
|
||||
GLOBAL: 'GLOBAL';
|
||||
GO: 'GO';
|
||||
GROUP_MAX_REQUESTS: 'GROUP_MAX_REQUESTS';
|
||||
GROUPING: 'GROUPING';
|
||||
GROUPING_ID: 'GROUPING_ID';
|
||||
HADR: 'HADR';
|
||||
HASH: 'HASH';
|
||||
HEALTH_CHECK_TIMEOUT: 'HEALTH_CHECK_TIMEOUT';
|
||||
HIGH: 'HIGH';
|
||||
HONOR_BROKER_PRIORITY: 'HONOR_BROKER_PRIORITY';
|
||||
HOURS: 'HOURS';
|
||||
IDENTITY_VALUE: 'IDENTITY_VALUE';
|
||||
IGNORE_NONCLUSTERED_COLUMNSTORE_INDEX: 'IGNORE_NONCLUSTERED_COLUMNSTORE_INDEX';
|
||||
IMMEDIATE: 'IMMEDIATE';
|
||||
IMPERSONATE: 'IMPERSONATE';
|
||||
IMPORTANCE: 'IMPORTANCE';
|
||||
INCLUDE_NULL_VALUES: 'INCLUDE_NULL_VALUES';
|
||||
INCREMENTAL: 'INCREMENTAL';
|
||||
INITIATOR: 'INITIATOR';
|
||||
INPUT: 'INPUT';
|
||||
INSENSITIVE: 'INSENSITIVE';
|
||||
INSERTED: 'INSERTED';
|
||||
INT: 'INT';
|
||||
IP: 'IP';
|
||||
ISOLATION: 'ISOLATION';
|
||||
JOB: 'JOB';
|
||||
JSON: 'JSON';
|
||||
KB: 'KB';
|
||||
KEEP: 'KEEP';
|
||||
KEEPFIXED: 'KEEPFIXED';
|
||||
KEY_SOURCE: 'KEY_SOURCE';
|
||||
KEYS: 'KEYS';
|
||||
KEYSET: 'KEYSET';
|
||||
LAG: 'LAG';
|
||||
LAST: 'LAST';
|
||||
LAST_VALUE: 'LAST_VALUE';
|
||||
LEAD: 'LEAD';
|
||||
LEVEL: 'LEVEL';
|
||||
LIST: 'LIST';
|
||||
LISTENER: 'LISTENER';
|
||||
LISTENER_URL: 'LISTENER_URL';
|
||||
LOB_COMPACTION: 'LOB_COMPACTION';
|
||||
LOCAL: 'LOCAL';
|
||||
LOCATION: 'LOCATION';
|
||||
LOCK: 'LOCK';
|
||||
LOCK_ESCALATION: 'LOCK_ESCALATION';
|
||||
LOGIN: 'LOGIN';
|
||||
LOOP: 'LOOP';
|
||||
LOW: 'LOW';
|
||||
MANUAL: 'MANUAL';
|
||||
MARK: 'MARK';
|
||||
MATERIALIZED: 'MATERIALIZED';
|
||||
MAX: 'MAX';
|
||||
MAX_CPU_PERCENT: 'MAX_CPU_PERCENT';
|
||||
MAX_DOP: 'MAX_DOP';
|
||||
MAX_FILES: 'MAX_FILES';
|
||||
MAX_IOPS_PER_VOLUME: 'MAX_IOPS_PER_VOLUME';
|
||||
MAX_MEMORY_PERCENT: 'MAX_MEMORY_PERCENT';
|
||||
MAX_PROCESSES: 'MAX_PROCESSES';
|
||||
MAX_QUEUE_READERS: 'MAX_QUEUE_READERS';
|
||||
MAX_ROLLOVER_FILES: 'MAX_ROLLOVER_FILES';
|
||||
MAXDOP: 'MAXDOP';
|
||||
MAXRECURSION: 'MAXRECURSION';
|
||||
MAXSIZE: 'MAXSIZE';
|
||||
MB: 'MB';
|
||||
MEDIUM: 'MEDIUM';
|
||||
MEMORY_OPTIMIZED_DATA: 'MEMORY_OPTIMIZED_DATA';
|
||||
MESSAGE: 'MESSAGE';
|
||||
MIN: 'MIN';
|
||||
MIN_ACTIVE_ROWVERSION: 'MIN_ACTIVE_ROWVERSION';
|
||||
MIN_CPU_PERCENT: 'MIN_CPU_PERCENT';
|
||||
MIN_IOPS_PER_VOLUME: 'MIN_IOPS_PER_VOLUME';
|
||||
MIN_MEMORY_PERCENT: 'MIN_MEMORY_PERCENT';
|
||||
MINUTES: 'MINUTES';
|
||||
MIRROR_ADDRESS: 'MIRROR_ADDRESS';
|
||||
MIXED_PAGE_ALLOCATION: 'MIXED_PAGE_ALLOCATION';
|
||||
MODE: 'MODE';
|
||||
MODIFY: 'MODIFY';
|
||||
MOVE: 'MOVE';
|
||||
MULTI_USER: 'MULTI_USER';
|
||||
NAME: 'NAME';
|
||||
NESTED_TRIGGERS: 'NESTED_TRIGGERS';
|
||||
NEW_ACCOUNT: 'NEW_ACCOUNT';
|
||||
NEW_BROKER: 'NEW_BROKER';
|
||||
NEW_PASSWORD: 'NEW_PASSWORD';
|
||||
NEXT: 'NEXT';
|
||||
NO: 'NO';
|
||||
NO_TRUNCATE: 'NO_TRUNCATE';
|
||||
NO_WAIT: 'NO_WAIT';
|
||||
NOCOUNT: 'NOCOUNT';
|
||||
NODES: 'NODES';
|
||||
NOEXPAND: 'NOEXPAND';
|
||||
NON_TRANSACTED_ACCESS: 'NON_TRANSACTED_ACCESS';
|
||||
NORECOMPUTE: 'NORECOMPUTE';
|
||||
NORECOVERY: 'NORECOVERY';
|
||||
NOWAIT: 'NOWAIT';
|
||||
NTILE: 'NTILE';
|
||||
NUMANODE: 'NUMANODE';
|
||||
NUMBER: 'NUMBER';
|
||||
NUMERIC_ROUNDABORT: 'NUMERIC_ROUNDABORT';
|
||||
OBJECT: 'OBJECT';
|
||||
OFFLINE: 'OFFLINE';
|
||||
OFFSET: 'OFFSET';
|
||||
OLD_ACCOUNT: 'OLD_ACCOUNT';
|
||||
ONLINE: 'ONLINE';
|
||||
ONLY: 'ONLY';
|
||||
OPEN_EXISTING: 'OPEN_EXISTING';
|
||||
OPTIMISTIC: 'OPTIMISTIC';
|
||||
OPTIMIZE: 'OPTIMIZE';
|
||||
OUT: 'OUT';
|
||||
OUTPUT: 'OUTPUT';
|
||||
OVERRIDE: 'OVERRIDE';
|
||||
OWNER: 'OWNER';
|
||||
PAGE_VERIFY: 'PAGE_VERIFY';
|
||||
PARAMETERIZATION: 'PARAMETERIZATION';
|
||||
PARTITION: 'PARTITION';
|
||||
PARTITIONS: 'PARTITIONS';
|
||||
PARTNER: 'PARTNER';
|
||||
PATH: 'PATH';
|
||||
POISON_MESSAGE_HANDLING: 'POISON_MESSAGE_HANDLING';
|
||||
POOL: 'POOL';
|
||||
PORT: 'PORT';
|
||||
PRECEDING: 'PRECEDING';
|
||||
PRIMARY_ROLE: 'PRIMARY_ROLE';
|
||||
PRIOR: 'PRIOR';
|
||||
PRIORITY: 'PRIORITY';
|
||||
PRIORITY_LEVEL: 'PRIORITY_LEVEL';
|
||||
PRIVATE: 'PRIVATE';
|
||||
PRIVATE_KEY: 'PRIVATE_KEY';
|
||||
PRIVILEGES: 'PRIVILEGES';
|
||||
PROCEDURE_NAME: 'PROCEDURE_NAME';
|
||||
PROPERTY: 'PROPERTY';
|
||||
PROVIDER: 'PROVIDER';
|
||||
PROVIDER_KEY_NAME: 'PROVIDER_KEY_NAME';
|
||||
QUERY: 'QUERY';
|
||||
QUEUE: 'QUEUE';
|
||||
QUEUE_DELAY: 'QUEUE_DELAY';
|
||||
QUOTED_IDENTIFIER: 'QUOTED_IDENTIFIER';
|
||||
RANGE: 'RANGE';
|
||||
RANK: 'RANK';
|
||||
RC2: 'RC2';
|
||||
RC4: 'RC4';
|
||||
RC4_128: 'RC4_128';
|
||||
READ_COMMITTED_SNAPSHOT: 'READ_COMMITTED_SNAPSHOT';
|
||||
READ_ONLY: 'READ_ONLY';
|
||||
READ_ONLY_ROUTING_LIST: 'READ_ONLY_ROUTING_LIST';
|
||||
READ_WRITE: 'READ_WRITE';
|
||||
READONLY: 'READONLY';
|
||||
REBUILD: 'REBUILD';
|
||||
RECEIVE: 'RECEIVE';
|
||||
RECOMPILE: 'RECOMPILE';
|
||||
RECOVERY: 'RECOVERY';
|
||||
RECURSIVE_TRIGGERS: 'RECURSIVE_TRIGGERS';
|
||||
RELATIVE: 'RELATIVE';
|
||||
REMOTE: 'REMOTE';
|
||||
REMOTE_SERVICE_NAME: 'REMOTE_SERVICE_NAME';
|
||||
REMOVE: 'REMOVE';
|
||||
REORGANIZE: 'REORGANIZE';
|
||||
REPEATABLE: 'REPEATABLE';
|
||||
REPLICA: 'REPLICA';
|
||||
REQUEST_MAX_CPU_TIME_SEC: 'REQUEST_MAX_CPU_TIME_SEC';
|
||||
REQUEST_MAX_MEMORY_GRANT_PERCENT: 'REQUEST_MAX_MEMORY_GRANT_PERCENT';
|
||||
REQUEST_MEMORY_GRANT_TIMEOUT_SEC: 'REQUEST_MEMORY_GRANT_TIMEOUT_SEC';
|
||||
REQUIRED_SYNCHRONIZED_SECONDARIES_TO_COMMIT: 'REQUIRED_SYNCHRONIZED_SECONDARIES_TO_COMMIT';
|
||||
RESERVE_DISK_SPACE: 'RESERVE_DISK_SPACE';
|
||||
RESOURCE: 'RESOURCE';
|
||||
RESOURCE_MANAGER_LOCATION: 'RESOURCE_MANAGER_LOCATION';
|
||||
RESTRICTED_USER: 'RESTRICTED_USER';
|
||||
RETENTION: 'RETENTION';
|
||||
ROBUST: 'ROBUST';
|
||||
ROOT: 'ROOT';
|
||||
ROUTE: 'ROUTE';
|
||||
ROW: 'ROW';
|
||||
ROW_NUMBER: 'ROW_NUMBER';
|
||||
ROWGUID: 'ROWGUID';
|
||||
ROWS: 'ROWS';
|
||||
SAMPLE: 'SAMPLE';
|
||||
SCHEMABINDING: 'SCHEMABINDING';
|
||||
SCOPED: 'SCOPED';
|
||||
SCROLL: 'SCROLL';
|
||||
SCROLL_LOCKS: 'SCROLL_LOCKS';
|
||||
SEARCH: 'SEARCH';
|
||||
SECONDARY: 'SECONDARY';
|
||||
SECONDARY_ONLY: 'SECONDARY_ONLY';
|
||||
SECONDARY_ROLE: 'SECONDARY_ROLE';
|
||||
SECONDS: 'SECONDS';
|
||||
SECRET: 'SECRET';
|
||||
SECURITY: 'SECURITY';
|
||||
SECURITY_LOG: 'SECURITY_LOG';
|
||||
SEEDING_MODE: 'SEEDING_MODE';
|
||||
SELF: 'SELF';
|
||||
SEMI_SENSITIVE: 'SEMI_SENSITIVE';
|
||||
SEND: 'SEND';
|
||||
SENT: 'SENT';
|
||||
SEQUENCE: 'SEQUENCE';
|
||||
SERIALIZABLE: 'SERIALIZABLE';
|
||||
SESSION_TIMEOUT: 'SESSION_TIMEOUT';
|
||||
SETERROR: 'SETERROR';
|
||||
SHARE: 'SHARE';
|
||||
SHOWPLAN: 'SHOWPLAN';
|
||||
SIGNATURE: 'SIGNATURE';
|
||||
SIMPLE: 'SIMPLE';
|
||||
SINGLE_USER: 'SINGLE_USER';
|
||||
SIZE: 'SIZE';
|
||||
SMALLINT: 'SMALLINT';
|
||||
SNAPSHOT: 'SNAPSHOT';
|
||||
SPATIAL_WINDOW_MAX_CELLS: 'SPATIAL_WINDOW_MAX_CELLS';
|
||||
STANDBY: 'STANDBY';
|
||||
START_DATE: 'START_DATE';
|
||||
STATIC: 'STATIC';
|
||||
STATS_STREAM: 'STATS_STREAM';
|
||||
STATUS: 'STATUS';
|
||||
STATUSONLY: 'STATUSONLY';
|
||||
STDEV: 'STDEV';
|
||||
STDEVP: 'STDEVP';
|
||||
STOPLIST: 'STOPLIST';
|
||||
STRING_AGG: 'STRING_AGG';
|
||||
STUFF: 'STUFF';
|
||||
SUBJECT: 'SUBJECT';
|
||||
SUBSCRIPTION: 'SUBSCRIPTION';
|
||||
SUM: 'SUM';
|
||||
SUSPEND: 'SUSPEND';
|
||||
SYMMETRIC: 'SYMMETRIC';
|
||||
SYNCHRONOUS_COMMIT: 'SYNCHRONOUS_COMMIT';
|
||||
SYNONYM: 'SYNONYM';
|
||||
SYSTEM: 'SYSTEM';
|
||||
TAKE: 'TAKE';
|
||||
TARGET_RECOVERY_TIME: 'TARGET_RECOVERY_TIME';
|
||||
TB: 'TB';
|
||||
TEXTIMAGE_ON: 'TEXTIMAGE_ON';
|
||||
THROW: 'THROW';
|
||||
TIES: 'TIES';
|
||||
TIME: 'TIME';
|
||||
TIMEOUT: 'TIMEOUT';
|
||||
TIMER: 'TIMER';
|
||||
TINYINT: 'TINYINT';
|
||||
TORN_PAGE_DETECTION: 'TORN_PAGE_DETECTION';
|
||||
TRANSFORM_NOISE_WORDS: 'TRANSFORM_NOISE_WORDS';
|
||||
TRIPLE_DES: 'TRIPLE_DES';
|
||||
TRIPLE_DES_3KEY: 'TRIPLE_DES_3KEY';
|
||||
TRUSTWORTHY: 'TRUSTWORTHY';
|
||||
TRY: 'TRY';
|
||||
TSQL: 'TSQL';
|
||||
TWO_DIGIT_YEAR_CUTOFF: 'TWO_DIGIT_YEAR_CUTOFF';
|
||||
TYPE: 'TYPE';
|
||||
TYPE_WARNING: 'TYPE_WARNING';
|
||||
UNBOUNDED: 'UNBOUNDED';
|
||||
UNCOMMITTED: 'UNCOMMITTED';
|
||||
UNKNOWN: 'UNKNOWN';
|
||||
UNLIMITED: 'UNLIMITED';
|
||||
UOW: 'UOW';
|
||||
USING: 'USING';
|
||||
VALID_XML: 'VALID_XML';
|
||||
VALIDATION: 'VALIDATION';
|
||||
VALUE: 'VALUE';
|
||||
VAR: 'VAR';
|
||||
VARP: 'VARP';
|
||||
VIEW_METADATA: 'VIEW_METADATA';
|
||||
VIEWS: 'VIEWS';
|
||||
WAIT: 'WAIT';
|
||||
WELL_FORMED_XML: 'WELL_FORMED_XML';
|
||||
WITHOUT_ARRAY_WRAPPER: 'WITHOUT_ARRAY_WRAPPER';
|
||||
WORK: 'WORK';
|
||||
WORKLOAD: 'WORKLOAD';
|
||||
XML: 'XML';
|
||||
XMLDATA: 'XMLDATA';
|
||||
XMLNAMESPACES: 'XMLNAMESPACES';
|
||||
XMLSCHEMA: 'XMLSCHEMA';
|
||||
XSINIL: 'XSINIL';
|
||||
|
||||
DOLLAR_ACTION: '$ACTION';
|
||||
|
||||
SPACE: [ \t\r\n]+ -> skip;
|
||||
// https://docs.microsoft.com/en-us/sql/t-sql/language-elements/slash-star-comment-transact-sql
|
||||
COMMENT: '/*' (COMMENT | .)*? '*/' -> channel(HIDDEN);
|
||||
LINE_COMMENT: '--' ~[\r\n]* -> channel(HIDDEN);
|
||||
|
||||
// TODO: ID can be not only Latin.
|
||||
DOUBLE_QUOTE_ID: '"' ~'"'+ '"';
|
||||
SINGLE_QUOTE: '\'';
|
||||
SQUARE_BRACKET_ID: '[' ~']'+ ']';
|
||||
LOCAL_ID: '@' ([A-Z_$@#0-9] | FullWidthLetter)+;
|
||||
DECIMAL: DEC_DIGIT+;
|
||||
ID: ( [A-Z_#] | FullWidthLetter) ( [A-Z_#$@0-9] | FullWidthLetter )*;
|
||||
QUOTED_URL: '\''([A-Z][A-Z]+[:]) '//'(([A-Z]+[.]|[A-Z]+)|IPV4_ADDR) [:] DECIMAL '\'';
|
||||
QUOTED_HOST_AND_PORT:'\''(([A-Z]+[.]|[A-Z]+)|IPV4_ADDR) ([:] DECIMAL) '\'';
|
||||
STRING: 'N'? '\'' (~'\'' | '\'\'')* '\'';
|
||||
BINARY: '0' 'X' HEX_DIGIT*;
|
||||
FLOAT: DEC_DOT_DEC;
|
||||
REAL: (DECIMAL | DEC_DOT_DEC) ('E' [+-]? DEC_DIGIT+);
|
||||
|
||||
EQUAL: '=';
|
||||
|
||||
GREATER: '>';
|
||||
LESS: '<';
|
||||
EXCLAMATION: '!';
|
||||
|
||||
PLUS_ASSIGN: '+=';
|
||||
MINUS_ASSIGN: '-=';
|
||||
MULT_ASSIGN: '*=';
|
||||
DIV_ASSIGN: '/=';
|
||||
MOD_ASSIGN: '%=';
|
||||
AND_ASSIGN: '&=';
|
||||
XOR_ASSIGN: '^=';
|
||||
OR_ASSIGN: '|=';
|
||||
|
||||
DOUBLE_BAR: '||';
|
||||
DOT: '.';
|
||||
UNDERLINE: '_';
|
||||
AT: '@';
|
||||
SHARP: '#';
|
||||
DOLLAR: '$';
|
||||
LR_BRACKET: '(';
|
||||
RR_BRACKET: ')';
|
||||
COMMA: ',';
|
||||
SEMI: ';';
|
||||
COLON: ':';
|
||||
STAR: '*';
|
||||
DIVIDE: '/';
|
||||
MODULE: '%';
|
||||
PLUS: '+';
|
||||
MINUS: '-';
|
||||
BIT_NOT: '~';
|
||||
BIT_OR: '|';
|
||||
BIT_AND: '&';
|
||||
BIT_XOR: '^';
|
||||
|
||||
fragment LETTER: [A-Z_];
|
||||
fragment IPV6_OCTECT: [0-9A-F][0-9A-F][0-9A-F][0-9A-F];
|
||||
IPV4_OCTECT: [0-9]?[0-9]?[0-9];
|
||||
fragment DEC_DOT_DEC: (DEC_DIGIT+ '.' DEC_DIGIT+ | DEC_DIGIT+ '.' | '.' DEC_DIGIT+);
|
||||
fragment HEX_DIGIT: [0-9A-F];
|
||||
fragment DEC_DIGIT: [0-9];
|
||||
|
||||
fragment FullWidthLetter
|
||||
: '\u00c0'..'\u00d6'
|
||||
| '\u00d8'..'\u00f6'
|
||||
| '\u00f8'..'\u00ff'
|
||||
| '\u0100'..'\u1fff'
|
||||
| '\u2c00'..'\u2fff'
|
||||
| '\u3040'..'\u318f'
|
||||
| '\u3300'..'\u337f'
|
||||
| '\u3400'..'\u3fff'
|
||||
| '\u4e00'..'\u9fff'
|
||||
| '\ua000'..'\ud7ff'
|
||||
| '\uf900'..'\ufaff'
|
||||
| '\uff00'..'\ufff0'
|
||||
// | '\u10000'..'\u1F9FF' //not support four bytes chars
|
||||
// | '\u20000'..'\u2FA1F'
|
||||
;
|
4072
src/grammar/tsql/TSqlParser.g4
Normal file
4072
src/grammar/tsql/TSqlParser.g4
Normal file
File diff suppressed because it is too large
Load Diff
8175
src/grammar/tsql/parser/TSqlLexer.js
Normal file
8175
src/grammar/tsql/parser/TSqlLexer.js
Normal file
File diff suppressed because it is too large
Load Diff
1657
src/grammar/tsql/parser/TSqlLexer.tokens
Normal file
1657
src/grammar/tsql/parser/TSqlLexer.tokens
Normal file
File diff suppressed because it is too large
Load Diff
126333
src/grammar/tsql/parser/TSqlParser.js
Normal file
126333
src/grammar/tsql/parser/TSqlParser.js
Normal file
File diff suppressed because one or more lines are too long
1657
src/grammar/tsql/parser/TSqlParser.tokens
Normal file
1657
src/grammar/tsql/parser/TSqlParser.tokens
Normal file
File diff suppressed because it is too large
Load Diff
4632
src/grammar/tsql/parser/TSqlParserListener.js
Normal file
4632
src/grammar/tsql/parser/TSqlParserListener.js
Normal file
File diff suppressed because it is too large
Load Diff
3094
src/grammar/tsql/parser/TSqlParserVisitor.js
Normal file
3094
src/grammar/tsql/parser/TSqlParserVisitor.js
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 './core';
|
||||
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
|
||||
;
|
@ -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
|
||||
;
|
@ -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,279 +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
|
||||
'ADVANCE' { return 'ADVANCE'; }
|
||||
'ANALYZE' { return 'ANALYZE'; }
|
||||
'AND' { return 'AND'; }
|
||||
'ARRAY' { return 'ARRAY'; }
|
||||
'AS' { return 'AS'; }
|
||||
'AT' { return 'AT'; }
|
||||
'BEGINNING' { return 'BEGINNING' }
|
||||
'BETWEEN' { this.begin('between'); return 'BETWEEN'; }
|
||||
'BIGINT' { return 'BIGINT'; }
|
||||
'BOOLEAN' { return 'BOOLEAN'; }
|
||||
'BY' { return 'BY'; }
|
||||
'CASE' { return 'CASE'; }
|
||||
'CAST' { return 'CAST'; }
|
||||
'CATALOG' { return 'CATALOG'; }
|
||||
'CHANGES' { return 'CHANGES'; }
|
||||
'COLUMN' { return 'COLUMN'; }
|
||||
'COLUMNS' { return 'COLUMNS'; }
|
||||
'CONNECTOR' { return 'CONNECTOR'; }
|
||||
'CONNECTORS' { return 'CONNECTORS'; }
|
||||
'CREATE' { parser.determineCase(yytext); return 'CREATE'; }
|
||||
'DATE' { return 'DATE'; }
|
||||
'DAY' { return 'DAY'; }
|
||||
'DECIMAL' { return 'DECIMAL'; }
|
||||
'DELETE' { return 'DELETE'; }
|
||||
'DESCRIBE' { return 'DESCRIBE'; }
|
||||
'DISTINCT' { return 'DISTINCT'; }
|
||||
'DOUBLE' { return 'DOUBLE'; }
|
||||
'DROP' { parser.determineCase(yytext); parser.addStatementTypeLocation('DROP', yylloc, yy.lexer.upcomingInput()); return 'DROP'; }
|
||||
'ELSE' { return 'ELSE'; }
|
||||
'EMIT' { return 'EMIT'; }
|
||||
'END' { return 'END'; }
|
||||
'EXISTS' { parser.yy.correlatedSubQuery = true; return 'EXISTS'; }
|
||||
'EXPLAIN' { parser.determineCase(yytext); return 'EXPLAIN'; }
|
||||
'EXPORT' { return 'EXPORT'; }
|
||||
'EXTENDED' { return 'EXTENDED'; }
|
||||
'FROM' { parser.determineCase(yytext); return 'FROM'; }
|
||||
'FULL' { return 'FULL'; }
|
||||
'FUNCTION' { return 'FUNCTION'; }
|
||||
'FUNCTIONS' { return 'FUNCTIONS'; }
|
||||
'GROUP' { return 'GROUP'; }
|
||||
'HAVING' { return 'HAVING'; }
|
||||
'HOPPING' { return 'HOPPING'; }
|
||||
'HOUR' { return 'HOUR'; }
|
||||
'HOURS' { return 'HOURS'; }
|
||||
'IF' { return 'IF'; }
|
||||
'IN' { return 'IN'; }
|
||||
'INNER' { return 'INNER'; }
|
||||
'INSERT' { return 'INSERT'; }
|
||||
'INT' { return 'INT'; }
|
||||
'INTEGER' { return 'INTEGER'; }
|
||||
'INTO' { return 'INTO'; }
|
||||
'IS' { return 'IS'; }
|
||||
'JOIN' { return 'JOIN'; }
|
||||
'KEY' { return 'KEY'; }
|
||||
'LEFT' { return 'LEFT'; }
|
||||
'LIKE' { return 'LIKE'; }
|
||||
'LIMIT' { return 'LIMIT'; }
|
||||
'LIST' { return 'LIST'; }
|
||||
'LOAD' { return 'LOAD'; }
|
||||
'MAP' { return 'MAP'; }
|
||||
'MILLISECOND' { return 'MILLISECOND'; }
|
||||
'MILLISECONDS' { return 'MILLISECONDS'; }
|
||||
'MINUTE' { return 'MINUTE'; }
|
||||
'MINUTES' { return 'MINUTES'; }
|
||||
'MONTH' { return 'MONTH'; }
|
||||
'MONTHS' { return 'MONTHS'; }
|
||||
'NOT' { return 'NOT'; }
|
||||
'NULL' { return 'NULL'; }
|
||||
'ON' { return 'ON'; }
|
||||
'OR' { return 'OR'; }
|
||||
'OUTER' { return 'OUTER'; }
|
||||
'PARTITION' { return 'PARTITION'; }
|
||||
'PARTITIONS' { return 'PARTITIONS'; }
|
||||
'PRINT' { return 'PRINT'; }
|
||||
'PROPERTIES' { return 'PROPERTIES'; }
|
||||
'QUERIES' { return 'QUERIES'; }
|
||||
'QUERY' { return 'QUERY'; }
|
||||
'RENAME' { return 'RENAME'; }
|
||||
'RESET' { return 'RESET'; }
|
||||
'RIGHT' { return 'RIGHT'; }
|
||||
'RUN' { return 'RUN'; }
|
||||
'SAMPLE' { return 'SAMPLE'; }
|
||||
'SCRIPT' { return 'SCRIPT'; }
|
||||
'SECOND' { return 'SECOND'; }
|
||||
'SECOND' { return 'SECOND'; }
|
||||
'SELECT' { parser.determineCase(yytext); parser.addStatementTypeLocation('SELECT', yylloc); return 'SELECT'; }
|
||||
'SESSION' { return 'SESSION'; }
|
||||
'SET' { parser.determineCase(yytext); parser.addStatementTypeLocation('SET', yylloc); return 'SET'; }
|
||||
'SHOW' { parser.determineCase(yytext); parser.addStatementTypeLocation('SHOW', yylloc); return 'SHOW'; }
|
||||
'SINK' { return 'SINK'; }
|
||||
'SOURCE' { return 'SOURCE'; }
|
||||
'STREAM' { return 'STREAM'; }
|
||||
'STREAMS' { return 'STREAMS'; }
|
||||
'STRING' { return 'STRING'; }
|
||||
'STRUCT' { return 'STRUCT'; }
|
||||
'TABLE' { return 'TABLE'; }
|
||||
'TABLES' { return 'TABLES'; }
|
||||
'TERMINATE' { return 'TERMINATE'; }
|
||||
'THEN' { return 'THEN'; }
|
||||
'TIME' { return 'TIME'; }
|
||||
'TIMESTAMP' { return 'TIMESTAMP'; }
|
||||
'TO' { return 'TO'; }
|
||||
'TRUE' { return 'TRUE'; }
|
||||
'TOPIC' { return 'TOPIC'; }
|
||||
'TOPICS' { return 'TOPICS'; }
|
||||
'TUMBLING' { return 'TUMBLING'; }
|
||||
'TYPE' { return 'TYPE'; }
|
||||
'TYPES' { return 'TYPES'; }
|
||||
'UNSET' { return 'UNSET'; }
|
||||
'VALUES' { return 'VALUES'; }
|
||||
'VARCHAR' { return 'VARCHAR'; }
|
||||
'WHEN' { return 'WHEN'; }
|
||||
'WHERE' { return 'WHERE'; }
|
||||
'WITH' { parser.determineCase(yytext); parser.addStatementTypeLocation('WITH', yylloc); return 'WITH'; }
|
||||
'WITHIN' { return 'WITHIN'; }
|
||||
'YEAR' { return 'YEAR'; }
|
||||
'YEARS' { return 'YEARS'; }
|
||||
'ZONE' { return 'ZONE'; }
|
||||
|
||||
// --- UDFs ---
|
||||
ABS\s*\( { yy.lexer.unput('('); yytext = 'abs'; parser.addFunctionLocation(yylloc, yytext); return 'ABS'; }
|
||||
ARRAYCONTAINS\s*\( { yy.lexer.unput('('); yytext = 'arraycontains'; parser.addFunctionLocation(yylloc, yytext); return 'ARRAYCONTAINS'; }
|
||||
CEIL\s*\( { yy.lexer.unput('('); yytext = 'ceil'; parser.addFunctionLocation(yylloc, yytext); return 'CEIL'; }
|
||||
CONCAT\s*\( { yy.lexer.unput('('); yytext = 'concat'; parser.addFunctionLocation(yylloc, yytext); return 'CONCAT'; }
|
||||
DATETOSTRING\s*\( { yy.lexer.unput('('); yytext = 'datetostring'; parser.addFunctionLocation(yylloc, yytext); return 'DATETOSTRING'; }
|
||||
ELT\s*\( { yy.lexer.unput('('); yytext = 'elt'; parser.addFunctionLocation(yylloc, yytext); return 'ELT'; }
|
||||
EXTRACTJSONFIELD\s*\( { yy.lexer.unput('('); yytext = 'extractjsonfield'; parser.addFunctionLocation(yylloc, yytext); return 'EXTRACTJSONFIELD'; }
|
||||
FIELD\s*\( { yy.lexer.unput('('); yytext = 'field'; parser.addFunctionLocation(yylloc, yytext); return 'FIELD'; }
|
||||
FLOOR\s*\( { yy.lexer.unput('('); yytext = 'floor'; parser.addFunctionLocation(yylloc, yytext); return 'FLOOR'; }
|
||||
GEO_DISTANCE\s*\( { yy.lexer.unput('('); yytext = 'geo_distance'; parser.addFunctionLocation(yylloc, yytext); return 'GEO_DISTANCE'; }
|
||||
IFNULL\s*\( { yy.lexer.unput('('); yytext = 'ifnull'; parser.addFunctionLocation(yylloc, yytext); return 'IFNULL'; }
|
||||
LCASE\s*\( { yy.lexer.unput('('); yytext = 'lcase'; parser.addFunctionLocation(yylloc, yytext); return 'LCASE'; }
|
||||
LEN\s*\( { yy.lexer.unput('('); yytext = 'len'; parser.addFunctionLocation(yylloc, yytext); return 'LEN'; }
|
||||
MASK\s*\( { yy.lexer.unput('('); yytext = 'msk'; parser.addFunctionLocation(yylloc, yytext); return 'MASK'; }
|
||||
MASK_KEEP_LEFT\s*\( { yy.lexer.unput('('); yytext = 'mask_keep_left'; parser.addFunctionLocation(yylloc, yytext); return 'MASK_KEEP_LEFT'; }
|
||||
MASK_KEEP_RIGHT\s*\( { yy.lexer.unput('('); yytext = 'mask_keep_right'; parser.addFunctionLocation(yylloc, yytext); return 'MASK_KEEP_RIGHT'; }
|
||||
MASK_LEFT\s*\( { yy.lexer.unput('('); yytext = 'mask_left'; parser.addFunctionLocation(yylloc, yytext); return 'MASK_LEFT'; }
|
||||
MASK_RIGHT\s*\( { yy.lexer.unput('('); yytext = 'mask_right'; parser.addFunctionLocation(yylloc, yytext); return 'MASK_RIGHT'; }
|
||||
RANDOM\s*\( { yy.lexer.unput('('); yytext = 'random'; parser.addFunctionLocation(yylloc, yytext); return 'RANDOM'; }
|
||||
ROUND\s*\( { yy.lexer.unput('('); yytext = 'round'; parser.addFunctionLocation(yylloc, yytext); return 'ROUND'; }
|
||||
SPLIT\s*\( { yy.lexer.unput('('); yytext = 'split'; parser.addFunctionLocation(yylloc, yytext); return 'SPLIT'; }
|
||||
STRINGTODATE\s*\( { yy.lexer.unput('('); yytext = 'stringtodate'; parser.addFunctionLocation(yylloc, yytext); return 'STRINGTODATE'; }
|
||||
STRINGTOTIMESTAMP\s*\( { yy.lexer.unput('('); yytext = 'stringtotimestamp'; parser.addFunctionLocation(yylloc, yytext); return 'STRINGTOTIMESTAMP'; }
|
||||
SUBSTRING\s*\( { yy.lexer.unput('('); yytext = 'substring'; parser.addFunctionLocation(yylloc, yytext); return 'SUBSTRING'; }
|
||||
TIMESTAMPTOSTRING\s*\( { yy.lexer.unput('('); yytext = 'timestamptostring'; parser.addFunctionLocation(yylloc, yytext); return 'TIMESTAMPTOSTRING'; }
|
||||
TRIM\s*\( { yy.lexer.unput('('); yytext = 'trim'; parser.addFunctionLocation(yylloc, yytext); return 'TRIM'; }
|
||||
UCASE\s*\( { yy.lexer.unput('('); yytext = 'ucase'; parser.addFunctionLocation(yylloc, yytext); return 'UCASE'; }
|
||||
URL_DECODE_PARAM\s*\( { yy.lexer.unput('('); yytext = 'url_decode_param'; parser.addFunctionLocation(yylloc, yytext); return 'URL_DECODE_PARAM'; }
|
||||
URL_ENCODE_PARAM\s*\( { yy.lexer.unput('('); yytext = 'urel_encode_param'; parser.addFunctionLocation(yylloc, yytext); return 'URL_ENCODE_PARAM'; }
|
||||
URL_EXTRACT_FRAGMENT\s*\( { yy.lexer.unput('('); yytext = 'url_extract_fragment'; parser.addFunctionLocation(yylloc, yytext); return 'URL_EXTRACT_FRAGMENT'; }
|
||||
URL_EXTRACT_HOST\s*\( { yy.lexer.unput('('); yytext = 'url_extract_host'; parser.addFunctionLocation(yylloc, yytext); return 'URL_EXTRACT_HOST'; }
|
||||
URL_EXTRACT_PARAMETER\s*\( { yy.lexer.unput('('); yytext = 'url_extract_parameter'; parser.addFunctionLocation(yylloc, yytext); return 'URL_EXTRACT_PARAMETER'; }
|
||||
URL_EXTRACT_PATH\s*\( { yy.lexer.unput('('); yytext = 'url_extrct_path'; parser.addFunctionLocation(yylloc, yytext); return 'URL_EXTRACT_PATH'; }
|
||||
URL_EXTRACT_PORT\s*\( { yy.lexer.unput('('); yytext = 'url_extract_port'; parser.addFunctionLocation(yylloc, yytext); return 'URL_EXTRACT_PORT'; }
|
||||
URL_EXTRACT_PROTOCOL\s*\( { yy.lexer.unput('('); yytext = 'url_extract_protocol'; parser.addFunctionLocation(yylloc, yytext); return 'URL_EXTRACT_PROTOCOL'; }
|
||||
URL_EXTRACT_QUERY\s*\( { yy.lexer.unput('('); yytext = 'url_extract_query'; parser.addFunctionLocation(yylloc, yytext); return 'URL_EXTRACT_QUERY'; }
|
||||
|
||||
|
||||
// Analytical functions
|
||||
COLLECT_LIST\s*\( { yy.lexer.unput('('); yytext = 'collect_list'; parser.addFunctionLocation(yylloc, yytext); return 'COLLECT_LIST'; }
|
||||
COLLECT_SET\s*\( { yy.lexer.unput('('); yytext = 'collect_set'; parser.addFunctionLocation(yylloc, yytext); return 'COLLECT_SET'; }
|
||||
COUNT\s*\( { yy.lexer.unput('('); yytext = 'count'; parser.addFunctionLocation(yylloc, yytext); return 'COUNT'; }
|
||||
HISTOGRAM\s*\( { yy.lexer.unput('('); yytext = 'historgram'; parser.addFunctionLocation(yylloc, yytext); return 'HISTOGRAM'; }
|
||||
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'; }
|
||||
SUM\s*\( { yy.lexer.unput('('); yytext = 'sum'; parser.addFunctionLocation(yylloc, yytext); return 'SUM'; }
|
||||
TOPK\s*\( { yy.lexer.unput('('); yytext = 'topk'; parser.addFunctionLocation(yylloc, yytext); return 'TOPK'; }
|
||||
TOPKDISTINCT\s*\( { yy.lexer.unput('('); yytext = 'topkdistinct'; parser.addFunctionLocation(yylloc, yytext); return 'TOPKDISTINCT'; }
|
||||
WindowStart\s*\( { yy.lexer.unput('('); yytext = 'windowstart'; parser.addFunctionLocation(yylloc, yytext); return 'WindowStart'; }
|
||||
WindowEnd\s*\( { yy.lexer.unput('('); yytext = 'windowend'; parser.addFunctionLocation(yylloc, yytext); return 'WindowEnd'; }
|
||||
|
||||
|
||||
[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'; }
|
||||
|
||||
|
||||
'&&' { 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,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'
|
||||
;
|
@ -1,37 +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
|
||||
: 'LIST' ListStatement
|
||||
;
|
||||
|
||||
DataDefinition_EDIT
|
||||
: ListStatement_EDIT
|
||||
;
|
||||
|
||||
ListStatement
|
||||
: 'TABLES'
|
||||
| 'STREAMS'
|
||||
| 'TOPICS'
|
||||
;
|
||||
|
||||
|
||||
ListStatement_EDIT
|
||||
: 'LIST' 'CURSOR'
|
||||
{
|
||||
parser.suggestKeywords(['TABLES', 'STREAMS', 'TOPICS']);
|
||||
}
|
||||
;
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user