add hive sql automComplate
This commit is contained in:
		@ -1,20 +1,21 @@
 | 
			
		||||
const Parser = require('../core/astParser');
 | 
			
		||||
const Cache = require("../core/cache");
 | 
			
		||||
const dtSqlParser=require("../core/sqlSyntaxParser");
 | 
			
		||||
const sqlSyntaxParser = require("../core/sqlSyntaxParser");
 | 
			
		||||
const sqlAutoCompleteParser = require("../core/sqlAutoCompleteParser");
 | 
			
		||||
const filter = require("./filter");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
const astCache=new Cache();
 | 
			
		||||
const astCache = new Cache();
 | 
			
		||||
 | 
			
		||||
function parse(sql){
 | 
			
		||||
    const cleanSql=filter.cleanSql(sql);
 | 
			
		||||
function parse(sql) {
 | 
			
		||||
    const cleanSql = filter.cleanSql(sql);
 | 
			
		||||
    console.log(cleanSql)
 | 
			
		||||
    let ast=astCache.get(cleanSql);
 | 
			
		||||
    if(ast){
 | 
			
		||||
    let ast = astCache.get(cleanSql);
 | 
			
		||||
    if (ast) {
 | 
			
		||||
        return ast
 | 
			
		||||
    }else{
 | 
			
		||||
        ast=Parser.parse(cleanSql).ast;
 | 
			
		||||
        astCache.set(cleanSql,ast);
 | 
			
		||||
    } else {
 | 
			
		||||
        ast = Parser.parse(cleanSql).ast;
 | 
			
		||||
        astCache.set(cleanSql, ast);
 | 
			
		||||
        return ast;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -24,12 +25,20 @@ function parse(sql){
 | 
			
		||||
 * type 语法类型。默认hive
 | 
			
		||||
 * return 返回解析对象
 | 
			
		||||
 */
 | 
			
		||||
function parseSyntax(sql,type){
 | 
			
		||||
    if(typeof type=="undefined"){
 | 
			
		||||
        type="hive"
 | 
			
		||||
function parseSyntax(sql, type) {
 | 
			
		||||
    if (typeof type == "undefined") {
 | 
			
		||||
        type = "hive"
 | 
			
		||||
    }
 | 
			
		||||
    return dtSqlParser.parser.parseSyntax(sql,'',type,false)
 | 
			
		||||
    return sqlSyntaxParser.parser.parseSyntax(sql, '', type, false)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
exports.parse=parse;
 | 
			
		||||
exports.parseSyntax=parseSyntax;
 | 
			
		||||
function parserSql(sql, type) {
 | 
			
		||||
    if (typeof type == "undefined") {
 | 
			
		||||
        type = "hive"
 | 
			
		||||
    }
 | 
			
		||||
    return sqlAutoCompleteParser.parser.parseSql(sql, '', type, false)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
exports.parse = parse;
 | 
			
		||||
exports.parseSyntax = parseSyntax;
 | 
			
		||||
exports.parserSql = parserSql;
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user