Fix/export abstract visitor (#237)
* fix: #236 export AbstractParseTreeVisitor * build: set isolatedModules true * feat: import parser about from filters
This commit is contained in:
parent
55a4832047
commit
8f72a5af60
58
src/index.ts
58
src/index.ts
@ -1,23 +1,45 @@
|
|||||||
export * from './parser';
|
export { AbstractParseTreeVisitor } from 'antlr4ts/tree/AbstractParseTreeVisitor';
|
||||||
export * from './lib/flinksql/FlinkSqlParserListener';
|
|
||||||
export * from './lib/flinksql/FlinkSqlParserVisitor';
|
export {
|
||||||
export * from './lib/mysql/MySqlParserVisitor';
|
MySQL,
|
||||||
export * from './lib/mysql/MySqlParserListener';
|
FlinkSQL,
|
||||||
export * from './lib/hive/HiveSqlParserListener';
|
SparkSQL,
|
||||||
export * from './lib/hive/HiveSqlParserVisitor';
|
HiveSQL,
|
||||||
export * from './lib/plsql/PlSqlParserListener';
|
PostgresSQL,
|
||||||
export * from './lib/plsql/PlSqlParserVisitor';
|
TrinoSQL,
|
||||||
export * from './lib/spark/SparkSqlParserVisitor';
|
ImpalaSQL,
|
||||||
export * from './lib/spark/SparkSqlParserListener';
|
PLSQL,
|
||||||
export * from './lib/pgsql/PostgreSQLParserListener';
|
} from './parser';
|
||||||
export * from './lib/pgsql/PostgreSQLParserVisitor';
|
|
||||||
export * from './lib/trinosql/TrinoSqlListener';
|
export {
|
||||||
export * from './lib/trinosql/TrinoSqlVisitor';
|
MySqlParserListener,
|
||||||
export * from './lib/impala/ImpalaSqlParserListener';
|
MySqlParserVisitor,
|
||||||
export * from './lib/impala/ImpalaSqlParserVisitor';
|
FlinkSqlParserListener,
|
||||||
|
FlinkSqlParserVisitor,
|
||||||
|
SparkSqlParserListener,
|
||||||
|
SparkSqlParserVisitor,
|
||||||
|
HiveSqlParserListener,
|
||||||
|
HiveSqlParserVisitor,
|
||||||
|
PlSqlParserListener,
|
||||||
|
PlSqlParserVisitor,
|
||||||
|
PostgreSQLParserListener,
|
||||||
|
PostgreSQLParserVisitor,
|
||||||
|
TrinoSqlListener,
|
||||||
|
TrinoSqlVisitor,
|
||||||
|
ImpalaSqlParserListener,
|
||||||
|
ImpalaSqlParserVisitor,
|
||||||
|
} from './lib';
|
||||||
|
|
||||||
export { SyntaxContextType } from './parser/common/basic-parser-types';
|
export { SyntaxContextType } from './parser/common/basic-parser-types';
|
||||||
|
|
||||||
export type * from './parser/common/basic-parser-types';
|
export type {
|
||||||
|
CaretPosition,
|
||||||
|
WordRange,
|
||||||
|
Suggestions,
|
||||||
|
SyntaxSuggestion,
|
||||||
|
TextSlice,
|
||||||
|
} from './parser/common/basic-parser-types';
|
||||||
|
|
||||||
export type { SyntaxError, ParseError, ErrorListener } from './parser/common/parseErrorListener';
|
export type { SyntaxError, ParseError, ErrorListener } from './parser/common/parseErrorListener';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
23
src/lib/index.ts
Normal file
23
src/lib/index.ts
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
export { FlinkSqlParserListener } from './flinksql/FlinkSqlParserListener';
|
||||||
|
export { FlinkSqlParserVisitor } from './flinksql/FlinkSqlParserVisitor';
|
||||||
|
|
||||||
|
export { MySqlParserListener } from './mysql/MySqlParserListener';
|
||||||
|
export { MySqlParserVisitor } from './mysql/MySqlParserVisitor';
|
||||||
|
|
||||||
|
export { HiveSqlParserListener } from './hive/HiveSqlParserListener';
|
||||||
|
export { HiveSqlParserVisitor } from './hive/HiveSqlParserVisitor';
|
||||||
|
|
||||||
|
export { PlSqlParserListener } from './plsql/PlSqlParserListener';
|
||||||
|
export { PlSqlParserVisitor } from './plsql/PlSqlParserVisitor';
|
||||||
|
|
||||||
|
export { SparkSqlParserListener } from './spark/SparkSqlParserListener';
|
||||||
|
export { SparkSqlParserVisitor } from './spark/SparkSqlParserVisitor';
|
||||||
|
|
||||||
|
export { PostgreSQLParserListener } from './pgsql/PostgreSQLParserListener';
|
||||||
|
export { PostgreSQLParserVisitor } from './pgsql/PostgreSQLParserVisitor';
|
||||||
|
|
||||||
|
export { TrinoSqlListener } from './trinosql/TrinoSqlListener';
|
||||||
|
export { TrinoSqlVisitor } from './trinosql/TrinoSqlVisitor';
|
||||||
|
|
||||||
|
export { ImpalaSqlParserListener } from './impala/ImpalaSqlParserListener';
|
||||||
|
export { ImpalaSqlParserVisitor } from './impala/ImpalaSqlParserVisitor';
|
@ -1,6 +1,4 @@
|
|||||||
import { CommonTokenStream } from 'antlr4ts';
|
import { CommonTokenStream, ErrorListener, FlinkSQL, FlinkSqlLexer } from '../filters';
|
||||||
import { ErrorListener, FlinkSQL } from '../../src';
|
|
||||||
import { FlinkSqlLexer } from '../../src/lib/flinksql/FlinkSqlLexer';
|
|
||||||
|
|
||||||
describe('BasicParser unit tests', () => {
|
describe('BasicParser unit tests', () => {
|
||||||
const flinkParser = new FlinkSQL();
|
const flinkParser = new FlinkSQL();
|
||||||
|
63
test/filters/index.ts
Normal file
63
test/filters/index.ts
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
/**
|
||||||
|
* All unit tests should import parser about from this file.
|
||||||
|
* In this way, the exports of dt-sql-parser in the entry file is guaranteed to be complete.
|
||||||
|
*
|
||||||
|
* 单测文件中有关 parser 的导入,都应该从这个文件中导入。
|
||||||
|
* 通过这种方式,能保证 dt-sql-parser 的入口文件中的导出完整。
|
||||||
|
*
|
||||||
|
* See this issue https://github.com/DTStack/dt-sql-parser/issues/236.
|
||||||
|
*/
|
||||||
|
|
||||||
|
export * from '../../src';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Something required by unit test but dt-sql-parser'entry not.
|
||||||
|
* If you need to add an export to this file,
|
||||||
|
* consider whether it should be exported in src/index as well.
|
||||||
|
*
|
||||||
|
* 一些单测文件需要但是 dt-sql-parser的入口不需要的导出。
|
||||||
|
* 如果你需要在这个文件中添加新的导出,请考虑它是否应该在 dt-sql-parser 的入口文件中导出。
|
||||||
|
*/
|
||||||
|
export { CommonTokenStream } from 'antlr4ts';
|
||||||
|
|
||||||
|
export { ParseTreeWalker, ParseTreeListener } from 'antlr4ts/tree';
|
||||||
|
|
||||||
|
export { FlinkSqlLexer } from '../../src/lib/flinksql/FlinkSqlLexer';
|
||||||
|
export { FlinkSqlParser } from '../../src/lib/flinksql/FlinkSqlParser';
|
||||||
|
export * as FlinkSqlParserRuleContext from '../../src/lib/flinksql/FlinkSqlParser';
|
||||||
|
|
||||||
|
export { MySqlLexer } from '../../src/lib/mysql/MySqlLexer';
|
||||||
|
export { MySqlParser } from '../../src/lib/mysql/MySqlParser';
|
||||||
|
export * as MySqlParserRuleContext from '../../src/lib/mysql/MySqlParser';
|
||||||
|
|
||||||
|
export { HiveSqlLexer } from '../../src/lib/hive/HiveSqlLexer';
|
||||||
|
export { HiveSqlParser } from '../../src/lib/hive/HiveSqlParser';
|
||||||
|
export * as HiveSqlParserRuleContext from '../../src/lib/hive/HiveSqlParser';
|
||||||
|
|
||||||
|
export { PlSqlLexer } from '../../src/lib/plsql/PlSqlLexer';
|
||||||
|
export { PlSqlParser } from '../../src/lib/plsql/PlSqlParser';
|
||||||
|
export * as PlSqlParserRuleContext from '../../src/lib/plsql/PlSqlParser';
|
||||||
|
|
||||||
|
export { SparkSqlLexer } from '../../src/lib/spark/SparkSqlLexer';
|
||||||
|
export { SparkSqlParser } from '../../src/lib/spark/SparkSqlParser';
|
||||||
|
export * as SparkSQLParserRuleContext from '../../src/lib/spark/SparkSqlParser';
|
||||||
|
|
||||||
|
export { PostgreSQLLexer } from '../../src/lib/pgsql/PostgreSQLLexer';
|
||||||
|
export { PostgreSQLParser } from '../../src/lib/pgsql/PostgreSQLParser';
|
||||||
|
export * as PostgreSQLParserRuleContext from '../../src/lib/pgsql/PostgreSQLParser';
|
||||||
|
|
||||||
|
export { TrinoSqlLexer } from '../../src/lib/trinosql/TrinoSqlLexer';
|
||||||
|
export { TrinoSqlParser } from '../../src/lib/trinosql/TrinoSqlParser';
|
||||||
|
export * as TrinoSqlParserRuleContext from '../../src/lib/trinosql/TrinoSqlParser';
|
||||||
|
|
||||||
|
export { ImpalaSqlLexer } from '../../src/lib/impala/ImpalaSqlLexer';
|
||||||
|
export { ImpalaSqlParser } from '../../src/lib/impala/ImpalaSqlParser';
|
||||||
|
export * as ImpalaSqlParserRuleContext from '../../src/lib/impala/ImpalaSqlParser';
|
||||||
|
|
||||||
|
export { FlinkSqlSplitListener } from '../../src/parser/flinksql';
|
||||||
|
export { MysqlSplitListener } from '../../src/parser/mysql';
|
||||||
|
export { HiveSqlSplitListener } from '../../src/parser/hive';
|
||||||
|
export { SparkSqlSplitListener } from '../../src/parser/spark';
|
||||||
|
export { PgSqlSplitListener } from '../../src/parser/pgsql';
|
||||||
|
export { TrinoSqlSplitListener } from '../../src/parser/trinosql';
|
||||||
|
export { ImpalaSqlSplitListener } from '../../src/parser/impala';
|
@ -1,7 +1,4 @@
|
|||||||
import path from 'path';
|
import { FlinkSQL } from '../../../filters';
|
||||||
import { writeFileSync } from 'node:fs';
|
|
||||||
|
|
||||||
import FlinkSQL from '../../../../src/parser/flinksql';
|
|
||||||
import {
|
import {
|
||||||
readSQL,
|
readSQL,
|
||||||
benchmark,
|
benchmark,
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
import FlinkSQL from '../../../src/parser/flinksql';
|
import { FlinkSQL, FlinkSqlSplitListener, FlinkSqlParserListener } from '../../filters';
|
||||||
import { FlinkSqlSplitListener } from '../../../src/parser/flinksql';
|
|
||||||
import { FlinkSqlParserListener } from '../../../src/lib/flinksql/FlinkSqlParserListener';
|
|
||||||
|
|
||||||
const validSQL1 = `INSERT INTO country_page_view
|
const validSQL1 = `INSERT INTO country_page_view
|
||||||
VALUES ('Chinese', 'mumiao', 18),
|
VALUES ('Chinese', 'mumiao', 18),
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import FlinkSQL from '../../../src/parser/flinksql';
|
import { FlinkSQL } from '../../filters';
|
||||||
|
|
||||||
describe('FlinkSQL Lexer tests', () => {
|
describe('FlinkSQL Lexer tests', () => {
|
||||||
const parser = new FlinkSQL();
|
const parser = new FlinkSQL();
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
import FlinkSQL from '../../../src/parser/flinksql';
|
import {
|
||||||
import { FlinkSqlParserListener } from '../../../src/lib/flinksql/FlinkSqlParserListener';
|
FlinkSQL,
|
||||||
import { TableExpressionContext } from '../../../src/lib/flinksql/FlinkSqlParser';
|
FlinkSqlParserListener,
|
||||||
import { ParseTreeListener } from 'antlr4ts/tree';
|
FlinkSqlParserRuleContext,
|
||||||
|
ParseTreeListener,
|
||||||
|
} from '../../filters';
|
||||||
|
|
||||||
describe('Flink SQL Listener Tests', () => {
|
describe('Flink SQL Listener Tests', () => {
|
||||||
const expectTableName = 'user1';
|
const expectTableName = 'user1';
|
||||||
@ -13,7 +15,9 @@ describe('Flink SQL Listener Tests', () => {
|
|||||||
test('Listener enterTableName', async () => {
|
test('Listener enterTableName', async () => {
|
||||||
let result = '';
|
let result = '';
|
||||||
class MyListener implements FlinkSqlParserListener {
|
class MyListener implements FlinkSqlParserListener {
|
||||||
enterTableExpression = (ctx: TableExpressionContext): void => {
|
enterTableExpression = (
|
||||||
|
ctx: FlinkSqlParserRuleContext.TableExpressionContext
|
||||||
|
): void => {
|
||||||
result = ctx.text.toLowerCase();
|
result = ctx.text.toLowerCase();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { CaretPosition, SyntaxContextType } from '../../../../src/parser/common/basic-parser-types';
|
import { CaretPosition, SyntaxContextType, FlinkSQL } from '../../../filters';
|
||||||
import FlinkSQL from '../../../../src/parser/flinksql';
|
|
||||||
|
|
||||||
const syntaxSql = fs.readFileSync(
|
const syntaxSql = fs.readFileSync(
|
||||||
path.join(__dirname, 'fixtures', 'multipleStatement.sql'),
|
path.join(__dirname, 'fixtures', 'multipleStatement.sql'),
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { CaretPosition, SyntaxContextType } from '../../../../src/parser/common/basic-parser-types';
|
import { CaretPosition, SyntaxContextType, FlinkSQL } from '../../../filters';
|
||||||
import FlinkSQL from '../../../../src/parser/flinksql';
|
|
||||||
import { commentOtherLine } from '../../../helper';
|
import { commentOtherLine } from '../../../helper';
|
||||||
|
|
||||||
const syntaxSql = fs.readFileSync(
|
const syntaxSql = fs.readFileSync(
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { CaretPosition } from '../../../../src/parser/common/basic-parser-types';
|
import { FlinkSQL, CaretPosition } from '../../../filters';
|
||||||
import FlinkSQL from '../../../../src/parser/flinksql';
|
|
||||||
import { commentOtherLine } from '../../../helper';
|
import { commentOtherLine } from '../../../helper';
|
||||||
|
|
||||||
const tokenSql = fs.readFileSync(path.join(__dirname, 'fixtures', 'tokenSuggestion.sql'), 'utf-8');
|
const tokenSql = fs.readFileSync(path.join(__dirname, 'fixtures', 'tokenSuggestion.sql'), 'utf-8');
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import FlinkSQL from '../../../../src/parser/flinksql';
|
import { FlinkSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const features = {
|
const features = {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import FlinkSQL from '../../../../src/parser/flinksql';
|
import { FlinkSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
// 综合测试的 sql 不做切割
|
// 综合测试的 sql 不做切割
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import FlinkSQL from '../../../../src/parser/flinksql';
|
import { FlinkSQL } from '../../../filters';
|
||||||
|
|
||||||
// 注释 sql 不做切割
|
// 注释 sql 不做切割
|
||||||
const features = {
|
const features = {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import FlinkSQL from '../../../../src/parser/flinksql';
|
import { FlinkSQL } from '../../../filters';
|
||||||
|
|
||||||
// 综合测试的 sql 不做切割
|
// 综合测试的 sql 不做切割
|
||||||
const features = {
|
const features = {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import FlinkSQL from '../../../../src/parser/flinksql';
|
import { FlinkSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const parser = new FlinkSQL();
|
const parser = new FlinkSQL();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import FlinkSQL from '../../../../src/parser/flinksql';
|
import { FlinkSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const features = {
|
const features = {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import FlinkSQL from '../../../../src/parser/flinksql';
|
import { FlinkSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const features = {
|
const features = {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import FlinkSQL from '../../../../src/parser/flinksql';
|
import { FlinkSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const features = {
|
const features = {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import FlinkSQL from '../../../../src/parser/flinksql';
|
import { FlinkSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const features = {
|
const features = {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import FlinkSQL from '../../../../src/parser/flinksql';
|
import { FlinkSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const features = {
|
const features = {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import FlinkSQL from '../../../../src/parser/flinksql';
|
import { FlinkSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const parser = new FlinkSQL();
|
const parser = new FlinkSQL();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import FlinkSQL from '../../../../src/parser/flinksql';
|
import { FlinkSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const parser = new FlinkSQL();
|
const parser = new FlinkSQL();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import FlinkSQL from '../../../../src/parser/flinksql';
|
import { FlinkSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const features = {
|
const features = {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import FlinkSQL from '../../../../src/parser/flinksql';
|
import { FlinkSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const features = {
|
const features = {
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
import FlinkSQL from '../../../src/parser/flinksql';
|
import { FlinkSQL, AbstractParseTreeVisitor, FlinkSqlParserVisitor } from '../../filters';
|
||||||
import { FlinkSqlParserVisitor } from '../../../src/lib/flinksql/FlinkSqlParserVisitor';
|
|
||||||
import { AbstractParseTreeVisitor } from 'antlr4ts/tree';
|
|
||||||
|
|
||||||
describe('Flink SQL Visitor Tests', () => {
|
describe('Flink SQL Visitor Tests', () => {
|
||||||
const expectTableName = 'user1';
|
const expectTableName = 'user1';
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
import HiveSQL from '../../../src/parser/hive';
|
import { HiveSQL, HiveSqlSplitListener, HiveSqlParserListener } from '../../filters';
|
||||||
import { HiveSqlSplitListener } from '../../../src/parser/hive';
|
|
||||||
import { HiveSqlParserListener } from '../../../src/lib/hive/HiveSqlParserListener';
|
|
||||||
|
|
||||||
const validSQL1 = `INSERT INTO country_page_view
|
const validSQL1 = `INSERT INTO country_page_view
|
||||||
VALUES ('Chinese', 'mumiao', 18),
|
VALUES ('Chinese', 'mumiao', 18),
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import HiveSQL from '../../../src/parser/hive';
|
import { HiveSQL } from '../../filters';
|
||||||
|
|
||||||
describe('HiveSQL Lexer tests', () => {
|
describe('HiveSQL Lexer tests', () => {
|
||||||
const parser = new HiveSQL();
|
const parser = new HiveSQL();
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
import { ParseTreeListener } from 'antlr4ts/tree';
|
import { ParseTreeListener } from 'antlr4ts/tree';
|
||||||
import { ProgramContext } from '../../../src/lib/hive/HiveSqlParser';
|
import { HiveSQL, HiveSqlParserListener, HiveSqlParserRuleContext } from '../../filters';
|
||||||
import { HiveSqlParserListener } from '../../../src/lib/hive/HiveSqlParserListener';
|
|
||||||
import HiveSQL from '../../../src/parser/hive';
|
|
||||||
|
|
||||||
describe('HiveSQL Listener Tests', () => {
|
describe('HiveSQL Listener Tests', () => {
|
||||||
const parser = new HiveSQL();
|
const parser = new HiveSQL();
|
||||||
@ -18,7 +16,10 @@ describe('HiveSQL Listener Tests', () => {
|
|||||||
}
|
}
|
||||||
const listenTableName = new MyListener();
|
const listenTableName = new MyListener();
|
||||||
|
|
||||||
await parser.listen(listenTableName as ParseTreeListener, parseTree as ProgramContext);
|
await parser.listen(
|
||||||
|
listenTableName as ParseTreeListener,
|
||||||
|
parseTree as HiveSqlParserRuleContext.ProgramContext
|
||||||
|
);
|
||||||
expect(result).toBe(expectTableName.toUpperCase());
|
expect(result).toBe(expectTableName.toUpperCase());
|
||||||
});
|
});
|
||||||
test('Listener enterCreateTable', async () => {
|
test('Listener enterCreateTable', async () => {
|
||||||
@ -32,7 +33,10 @@ describe('HiveSQL Listener Tests', () => {
|
|||||||
}
|
}
|
||||||
const listenTableName = new MyListener();
|
const listenTableName = new MyListener();
|
||||||
|
|
||||||
await parser.listen(listenTableName as ParseTreeListener, parseTree as ProgramContext);
|
await parser.listen(
|
||||||
|
listenTableName as ParseTreeListener,
|
||||||
|
parseTree as HiveSqlParserRuleContext.ProgramContext
|
||||||
|
);
|
||||||
expect(result).toBe('DROPTABLETABLE_NAME');
|
expect(result).toBe('DROPTABLETABLE_NAME');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { CaretPosition, SyntaxContextType } from '../../../../src/parser/common/basic-parser-types';
|
import { CaretPosition, SyntaxContextType, HiveSQL } from '../../../filters';
|
||||||
import HiveSQL from '../../../../src/parser/hive';
|
|
||||||
|
|
||||||
const syntaxSql = fs.readFileSync(
|
const syntaxSql = fs.readFileSync(
|
||||||
path.join(__dirname, 'fixtures', 'multipleStatement.sql'),
|
path.join(__dirname, 'fixtures', 'multipleStatement.sql'),
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { CaretPosition, SyntaxContextType } from '../../../../src/parser/common/basic-parser-types';
|
import { CaretPosition, SyntaxContextType, HiveSQL } from '../../../filters';
|
||||||
import HiveSQL from '../../../../src/parser/hive';
|
|
||||||
import { commentOtherLine } from '../../../helper';
|
import { commentOtherLine } from '../../../helper';
|
||||||
|
|
||||||
const syntaxSql = fs.readFileSync(
|
const syntaxSql = fs.readFileSync(
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { CaretPosition } from '../../../../src/parser/common/basic-parser-types';
|
import { CaretPosition, HiveSQL } from '../../../filters';
|
||||||
import HiveSQL from '../../../../src/parser/hive';
|
|
||||||
import { commentOtherLine } from '../../../helper';
|
import { commentOtherLine } from '../../../helper';
|
||||||
|
|
||||||
const tokenSql = fs.readFileSync(path.join(__dirname, 'fixtures', 'tokenSuggestion.sql'), 'utf-8');
|
const tokenSql = fs.readFileSync(path.join(__dirname, 'fixtures', 'tokenSuggestion.sql'), 'utf-8');
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import HiveSQL from '../../../../src/parser/hive';
|
import { HiveSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const parser = new HiveSQL();
|
const parser = new HiveSQL();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import HiveSQL from '../../../../src/parser/hive';
|
import { HiveSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const parser = new HiveSQL();
|
const parser = new HiveSQL();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import HiveSQL from '../../../../src/parser/hive';
|
import { HiveSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const parser = new HiveSQL();
|
const parser = new HiveSQL();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import HiveSQL from '../../../../src/parser/hive';
|
import { HiveSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const parser = new HiveSQL();
|
const parser = new HiveSQL();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import HiveSQL from '../../../../src/parser/hive';
|
import { HiveSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const parser = new HiveSQL();
|
const parser = new HiveSQL();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import HiveSQL from '../../../../src/parser/hive';
|
import { HiveSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const parser = new HiveSQL();
|
const parser = new HiveSQL();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import HiveSQL from '../../../../src/parser/hive';
|
import { HiveSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const parser = new HiveSQL();
|
const parser = new HiveSQL();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import HiveSQL from '../../../../src/parser/hive';
|
import { HiveSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const parser = new HiveSQL();
|
const parser = new HiveSQL();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import HiveSQL from '../../../../src/parser/hive';
|
import { HiveSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const features = {
|
const features = {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import HiveSQL from '../../../../src/parser/hive';
|
import { HiveSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const features = {
|
const features = {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import HiveSQL from '../../../../src/parser/hive';
|
import { HiveSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const parser = new HiveSQL();
|
const parser = new HiveSQL();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import HiveSQL from '../../../../src/parser/hive';
|
import { HiveSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const parser = new HiveSQL();
|
const parser = new HiveSQL();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import HiveSQL from '../../../../src/parser/hive';
|
import { HiveSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const parser = new HiveSQL();
|
const parser = new HiveSQL();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import HiveSQL from '../../../../src/parser/hive';
|
import { HiveSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const parser = new HiveSQL();
|
const parser = new HiveSQL();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import HiveSQL from '../../../../src/parser/hive';
|
import { HiveSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const parser = new HiveSQL();
|
const parser = new HiveSQL();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import HiveSQL from '../../../../src/parser/hive';
|
import { HiveSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const parser = new HiveSQL();
|
const parser = new HiveSQL();
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
import { AbstractParseTreeVisitor } from 'antlr4ts/tree/AbstractParseTreeVisitor';
|
import {
|
||||||
import { HiveSqlParserVisitor } from '../../../src/lib/hive/HiveSqlParserVisitor';
|
HiveSQL,
|
||||||
import HiveSQL from '../../../src/parser/hive';
|
HiveSqlParserVisitor,
|
||||||
import { ProgramContext } from '../../../src/lib/hive/HiveSqlParser';
|
AbstractParseTreeVisitor,
|
||||||
|
HiveSqlParserRuleContext,
|
||||||
|
} from '../../filters';
|
||||||
|
|
||||||
describe('HiveSQL Visitor Tests', () => {
|
describe('HiveSQL Visitor Tests', () => {
|
||||||
const expectTableName = 'dm_gis.dlv_addr_tc_count';
|
const expectTableName = 'dm_gis.dlv_addr_tc_count';
|
||||||
@ -25,7 +27,7 @@ describe('HiveSQL Visitor Tests', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const visitor = new MyVisitor();
|
const visitor = new MyVisitor();
|
||||||
visitor.visit(parseTree as ProgramContext);
|
visitor.visit(parseTree as HiveSqlParserRuleContext.ProgramContext);
|
||||||
|
|
||||||
expect(result).toBe(expectTableName);
|
expect(result).toBe(expectTableName);
|
||||||
});
|
});
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
import ImpalaSQL from '../../../src/parser/impala';
|
import { ImpalaSQL, ImpalaSqlSplitListener, ImpalaSqlParserListener } from '../../filters';
|
||||||
import { ImpalaSqlSplitListener } from '../../../src/parser/impala';
|
|
||||||
import { ImpalaSqlParserListener } from '../../../src/lib/impala/ImpalaSqlParserListener';
|
|
||||||
|
|
||||||
const validSQL1 = `INSERT INTO country_page_view
|
const validSQL1 = `INSERT INTO country_page_view
|
||||||
VALUES ('Chinese', 'mumiao', 18),
|
VALUES ('Chinese', 'mumiao', 18),
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import ImpalaSQL from '../../../src/parser/impala';
|
import { ImpalaSQL } from '../../filters';
|
||||||
|
|
||||||
describe('ImpalaSQL Lexer tests', () => {
|
describe('ImpalaSQL Lexer tests', () => {
|
||||||
const parser = new ImpalaSQL();
|
const parser = new ImpalaSQL();
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
import impalaSQL from '../../../src/parser/impala';
|
import { ImpalaSQL, ImpalaSqlParserListener, ParseTreeListener } from '../../filters';
|
||||||
import { ImpalaSqlParserListener } from '../../../src/lib/impala/ImpalaSqlParserListener';
|
|
||||||
import { ParseTreeListener } from 'antlr4ts/tree';
|
|
||||||
|
|
||||||
describe('impala SQL Listener Tests', () => {
|
describe('impala SQL Listener Tests', () => {
|
||||||
const expectTableName = 'user1';
|
const expectTableName = 'user1';
|
||||||
const sql = `select id,name,sex from ${expectTableName};`;
|
const sql = `select id,name,sex from ${expectTableName};`;
|
||||||
const parser = new impalaSQL();
|
const parser = new ImpalaSQL();
|
||||||
|
|
||||||
const parseTree = parser.parse(sql);
|
const parseTree = parser.parse(sql);
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { CaretPosition, SyntaxContextType } from '../../../../src/parser/common/basic-parser-types';
|
import { ImpalaSQL, CaretPosition, SyntaxContextType } from '../../../filters';
|
||||||
import ImpalaSQL from '../../../../src/parser/impala';
|
|
||||||
|
|
||||||
const syntaxSql = fs.readFileSync(
|
const syntaxSql = fs.readFileSync(
|
||||||
path.join(__dirname, 'fixtures', 'multipleStatement.sql'),
|
path.join(__dirname, 'fixtures', 'multipleStatement.sql'),
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { CaretPosition, SyntaxContextType } from '../../../../src/parser/common/basic-parser-types';
|
import { ImpalaSQL, CaretPosition, SyntaxContextType } from '../../../filters';
|
||||||
import ImpalaSQL from '../../../../src/parser/impala';
|
|
||||||
import { commentOtherLine } from '../../../helper';
|
import { commentOtherLine } from '../../../helper';
|
||||||
|
|
||||||
const syntaxSql = fs.readFileSync(
|
const syntaxSql = fs.readFileSync(
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { CaretPosition } from '../../../../src/parser/common/basic-parser-types';
|
import { ImpalaSQL, CaretPosition } from '../../../filters';
|
||||||
import impalaSQL from '../../../../src/parser/impala';
|
|
||||||
import { commentOtherLine } from '../../../helper';
|
import { commentOtherLine } from '../../../helper';
|
||||||
|
|
||||||
const tokenSql = fs.readFileSync(path.join(__dirname, 'fixtures', 'tokenSuggestion.sql'), 'utf-8');
|
const tokenSql = fs.readFileSync(path.join(__dirname, 'fixtures', 'tokenSuggestion.sql'), 'utf-8');
|
||||||
|
|
||||||
describe('Impala SQL Token Suggestion', () => {
|
describe('Impala SQL Token Suggestion', () => {
|
||||||
const parser = new impalaSQL();
|
const parser = new ImpalaSQL();
|
||||||
|
|
||||||
test('After ALTER', () => {
|
test('After ALTER', () => {
|
||||||
const pos: CaretPosition = {
|
const pos: CaretPosition = {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import ImpalaSQL from '../../../../src/parser/impala';
|
import { ImpalaSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const parser = new ImpalaSQL();
|
const parser = new ImpalaSQL();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import ImpalaSQL from '../../../../src/parser/impala';
|
import { ImpalaSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const parser = new ImpalaSQL();
|
const parser = new ImpalaSQL();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import ImpalaSQL from '../../../../src/parser/impala';
|
import { ImpalaSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const parser = new ImpalaSQL();
|
const parser = new ImpalaSQL();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import ImpalaSQL from '../../../../src/parser/impala';
|
import { ImpalaSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const parser = new ImpalaSQL();
|
const parser = new ImpalaSQL();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import ImpalaSQL from '../../../../src/parser/impala';
|
import { ImpalaSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const parser = new ImpalaSQL();
|
const parser = new ImpalaSQL();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import ImpalaSQL from '../../../../src/parser/impala';
|
import { ImpalaSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const parser = new ImpalaSQL();
|
const parser = new ImpalaSQL();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import ImpalaSQL from '../../../../src/parser/impala';
|
import { ImpalaSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const parser = new ImpalaSQL();
|
const parser = new ImpalaSQL();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import ImpalaSQL from '../../../../src/parser/impala';
|
import { ImpalaSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const parser = new ImpalaSQL();
|
const parser = new ImpalaSQL();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import ImpalaSQL from '../../../../src/parser/impala';
|
import { ImpalaSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const parser = new ImpalaSQL();
|
const parser = new ImpalaSQL();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import ImpalaSQL from '../../../../src/parser/impala';
|
import { ImpalaSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const parser = new ImpalaSQL();
|
const parser = new ImpalaSQL();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import ImpalaSQL from '../../../../src/parser/impala';
|
import { ImpalaSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const parser = new ImpalaSQL();
|
const parser = new ImpalaSQL();
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
import impalaSQL from '../../../src/parser/impala';
|
import { ImpalaSQL, ImpalaSqlParserVisitor, AbstractParseTreeVisitor } from '../../filters';
|
||||||
import { ImpalaSqlParserVisitor } from '../../../src/lib/impala/ImpalaSqlParserVisitor';
|
|
||||||
import { AbstractParseTreeVisitor } from 'antlr4ts/tree';
|
|
||||||
|
|
||||||
describe('impala SQL Visitor Tests', () => {
|
describe('impala SQL Visitor Tests', () => {
|
||||||
const expectTableName = 'user1';
|
const expectTableName = 'user1';
|
||||||
const sql = `select id,name,sex from ${expectTableName};`;
|
const sql = `select id,name,sex from ${expectTableName};`;
|
||||||
const parser = new impalaSQL();
|
const parser = new ImpalaSQL();
|
||||||
|
|
||||||
const parseTree = parser.parse(sql, (error) => {
|
const parseTree = parser.parse(sql, (error) => {
|
||||||
console.log('Parse error:', error);
|
console.log('Parse error:', error);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import MySQL from '../../../src/parser/mysql';
|
import { MySQL } from '../../filters';
|
||||||
import { MysqlSplitListener } from '../../../src/parser/mysql';
|
import { MysqlSplitListener, MySqlParserListener } from '../../filters';
|
||||||
import { MySqlParserListener } from '../../../src/lib/mysql/MySqlParserListener';
|
|
||||||
|
|
||||||
const validSQL1 = `INSERT INTO country_page_view
|
const validSQL1 = `INSERT INTO country_page_view
|
||||||
VALUES ('Chinese', 'mumiao', 18),
|
VALUES ('Chinese', 'mumiao', 18),
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import MySQL from '../../../src/parser/mysql';
|
import { MySQL } from '../../filters';
|
||||||
|
|
||||||
describe('MySQL Lexer tests', () => {
|
describe('MySQL Lexer tests', () => {
|
||||||
const parser = new MySQL();
|
const parser = new MySQL();
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import MySQL from '../../../src/parser/mysql';
|
import { MySQL } from '../../filters';
|
||||||
import { MySqlParserListener } from '../../../src/lib/mysql/MySqlParserListener';
|
import { MySqlParserListener, ParseTreeListener } from '../../filters';
|
||||||
import { ParseTreeListener } from 'antlr4ts/tree';
|
|
||||||
|
|
||||||
describe('MySQL Listener Tests', () => {
|
describe('MySQL Listener Tests', () => {
|
||||||
const expectTableName = 'user1';
|
const expectTableName = 'user1';
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { CaretPosition, SyntaxContextType } from '../../../../src/parser/common/basic-parser-types';
|
import { MySQL, CaretPosition, SyntaxContextType } from '../../../filters';
|
||||||
import MySQL from '../../../../src/parser/mysql';
|
|
||||||
|
|
||||||
const syntaxSql = fs.readFileSync(
|
const syntaxSql = fs.readFileSync(
|
||||||
path.join(__dirname, 'fixtures', 'multipleStatement.sql'),
|
path.join(__dirname, 'fixtures', 'multipleStatement.sql'),
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { CaretPosition, SyntaxContextType } from '../../../../src/parser/common/basic-parser-types';
|
import { MySQL, CaretPosition, SyntaxContextType } from '../../../filters';
|
||||||
import MySQL from '../../../../src/parser/mysql';
|
|
||||||
import { commentOtherLine } from '../../../helper';
|
import { commentOtherLine } from '../../../helper';
|
||||||
|
|
||||||
const syntaxSql = fs.readFileSync(
|
const syntaxSql = fs.readFileSync(
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { CaretPosition } from '../../../../src/parser/common/basic-parser-types';
|
import { MySQL, CaretPosition } from '../../../filters';
|
||||||
import MySQL from '../../../../src/parser/mysql';
|
|
||||||
import { commentOtherLine } from '../../../helper';
|
import { commentOtherLine } from '../../../helper';
|
||||||
|
|
||||||
const tokenSql = fs.readFileSync(path.join(__dirname, 'fixtures', 'tokenSuggestion.sql'), 'utf-8');
|
const tokenSql = fs.readFileSync(path.join(__dirname, 'fixtures', 'tokenSuggestion.sql'), 'utf-8');
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import MySQL from '../../../src/parser/mysql';
|
import { MySQL } from '../../filters';
|
||||||
|
|
||||||
describe('MySQL Syntax Tests', () => {
|
describe('MySQL Syntax Tests', () => {
|
||||||
const parser = new MySQL();
|
const parser = new MySQL();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import MySQL from '../../../../src/parser/mysql';
|
import { MySQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const parser = new MySQL();
|
const parser = new MySQL();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import MySQL from '../../../../src/parser/mysql';
|
import { MySQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const parser = new MySQL();
|
const parser = new MySQL();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import MySQL from '../../../../src/parser/mysql';
|
import { MySQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const parser = new MySQL();
|
const parser = new MySQL();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import MySQL from '../../../../src/parser/mysql';
|
import { MySQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const parser = new MySQL();
|
const parser = new MySQL();
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
import MySQL from '../../../src/parser/mysql';
|
import { MySQL, MySqlParserVisitor, AbstractParseTreeVisitor } from '../../filters';
|
||||||
import { MySqlParserVisitor } from '../../../src/lib/mysql/MySqlParserVisitor';
|
|
||||||
import { AbstractParseTreeVisitor } from 'antlr4ts/tree';
|
|
||||||
|
|
||||||
describe('MySQL Visitor Tests', () => {
|
describe('MySQL Visitor Tests', () => {
|
||||||
const expectTableName = 'user1';
|
const expectTableName = 'user1';
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
import PgSQL from '../../../src/parser/pgsql';
|
import { PostgresSQL, PgSqlSplitListener, PostgreSQLParserListener } from '../../filters';
|
||||||
import { PgSqlSplitListener } from '../../../src/parser/pgsql';
|
|
||||||
import { PostgreSQLParserListener } from '../../../src/lib/pgsql/PostgreSQLParserListener';
|
|
||||||
|
|
||||||
const validSQL1 = `INSERT INTO country_page_view
|
const validSQL1 = `INSERT INTO country_page_view
|
||||||
VALUES ('Chinese', 'mumiao', 18),
|
VALUES ('Chinese', 'mumiao', 18),
|
||||||
@ -9,7 +7,7 @@ const validSQL2 = 'SELECT * FROM tb;';
|
|||||||
const inValidSQL = 'CREATE TABLE';
|
const inValidSQL = 'CREATE TABLE';
|
||||||
|
|
||||||
describe('PgSQL ErrorStrategy test', () => {
|
describe('PgSQL ErrorStrategy test', () => {
|
||||||
const pgSQL = new PgSQL();
|
const pgSQL = new PostgresSQL();
|
||||||
|
|
||||||
// TODO: handle unexpected case
|
// TODO: handle unexpected case
|
||||||
// test('begin inValid', () => {
|
// test('begin inValid', () => {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import PostgresSQL from '../../../src/parser/pgsql';
|
import { PostgresSQL } from '../../filters';
|
||||||
|
|
||||||
describe('PostgresSQL Lexer tests', () => {
|
describe('PostgresSQL Lexer tests', () => {
|
||||||
const mysqlParser = new PostgresSQL();
|
const mysqlParser = new PostgresSQL();
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
import { ParseTreeListener } from 'antlr4ts/tree';
|
import { PostgresSQL, PostgreSQLParserListener, ParseTreeListener } from '../../filters';
|
||||||
import { PostgreSQLParserListener } from '../../../src/lib/pgsql/PostgreSQLParserListener';
|
|
||||||
import PostgresSQL from '../../../src/parser/pgsql';
|
|
||||||
|
|
||||||
describe('PostgresSQL Listener Tests', () => {
|
describe('PostgresSQL Listener Tests', () => {
|
||||||
const expectTableName = 'user1';
|
const expectTableName = 'user1';
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { CaretPosition, SyntaxContextType } from '../../../../src/parser/common/basic-parser-types';
|
import { CaretPosition, SyntaxContextType, PostgresSQL } from '../../../filters';
|
||||||
import PgSQL from '../../../../src/parser/pgsql';
|
|
||||||
|
|
||||||
const syntaxSql = fs.readFileSync(
|
const syntaxSql = fs.readFileSync(
|
||||||
path.join(__dirname, 'fixtures', 'multipleStatement.sql'),
|
path.join(__dirname, 'fixtures', 'multipleStatement.sql'),
|
||||||
@ -9,7 +8,7 @@ const syntaxSql = fs.readFileSync(
|
|||||||
);
|
);
|
||||||
|
|
||||||
describe('PgSQL Multiple Statements Syntax Suggestion', () => {
|
describe('PgSQL Multiple Statements Syntax Suggestion', () => {
|
||||||
const parser = new PgSQL();
|
const parser = new PostgresSQL();
|
||||||
|
|
||||||
test('Create table ', () => {
|
test('Create table ', () => {
|
||||||
const pos: CaretPosition = {
|
const pos: CaretPosition = {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { CaretPosition, SyntaxContextType } from '../../../../src/parser/common/basic-parser-types';
|
import { PostgresSQL, CaretPosition, SyntaxContextType } from '../../../filters';
|
||||||
import PgSQL from '../../../../src/parser/pgsql';
|
|
||||||
import { commentOtherLine } from '../../../helper';
|
import { commentOtherLine } from '../../../helper';
|
||||||
|
|
||||||
const syntaxSql = fs.readFileSync(
|
const syntaxSql = fs.readFileSync(
|
||||||
@ -10,7 +9,7 @@ const syntaxSql = fs.readFileSync(
|
|||||||
);
|
);
|
||||||
|
|
||||||
describe('Postgre SQL Syntax Suggestion', () => {
|
describe('Postgre SQL Syntax Suggestion', () => {
|
||||||
const parser = new PgSQL();
|
const parser = new PostgresSQL();
|
||||||
|
|
||||||
test('Validate Syntax SQL', () => {
|
test('Validate Syntax SQL', () => {
|
||||||
expect(parser.validate(syntaxSql).length).not.toBe(0);
|
expect(parser.validate(syntaxSql).length).not.toBe(0);
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { CaretPosition } from '../../../../src/parser/common/basic-parser-types';
|
import { PostgresSQL, CaretPosition } from '../../../filters';
|
||||||
import PostgresSQL from '../../../../src/parser/pgsql';
|
|
||||||
import { commentOtherLine } from '../../../helper';
|
import { commentOtherLine } from '../../../helper';
|
||||||
|
|
||||||
const tokenSql = fs.readFileSync(path.join(__dirname, 'fixtures', 'tokenSuggestion.sql'), 'utf-8');
|
const tokenSql = fs.readFileSync(path.join(__dirname, 'fixtures', 'tokenSuggestion.sql'), 'utf-8');
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import PgSQL from '../../../../src/parser/pgsql';
|
import { PostgresSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const parser = new PgSQL();
|
const parser = new PostgresSQL();
|
||||||
|
|
||||||
const features = {
|
const features = {
|
||||||
alters: readSQL(__dirname, 'alter.sql'),
|
alters: readSQL(__dirname, 'alter.sql'),
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import PgSQL from '../../../../src/parser/pgsql';
|
import { PostgresSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const parser = new PgSQL();
|
const parser = new PostgresSQL();
|
||||||
|
|
||||||
const features = {
|
const features = {
|
||||||
creates: readSQL(__dirname, 'create.sql'),
|
creates: readSQL(__dirname, 'create.sql'),
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import PgSQL from '../../../../src/parser/pgsql';
|
import { PostgresSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const parser = new PgSQL();
|
const parser = new PostgresSQL();
|
||||||
|
|
||||||
const features = {
|
const features = {
|
||||||
deletes: readSQL(__dirname, 'delete.sql'),
|
deletes: readSQL(__dirname, 'delete.sql'),
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import PgSQL from '../../../../src/parser/pgsql';
|
import { PostgresSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const parser = new PgSQL();
|
const parser = new PostgresSQL();
|
||||||
|
|
||||||
const features = {
|
const features = {
|
||||||
drops: readSQL(__dirname, 'drop.sql'),
|
drops: readSQL(__dirname, 'drop.sql'),
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import PgSQL from '../../../../src/parser/pgsql';
|
import { PostgresSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const parser = new PgSQL();
|
const parser = new PostgresSQL();
|
||||||
|
|
||||||
const features = {
|
const features = {
|
||||||
inserts: readSQL(__dirname, 'insert.sql'),
|
inserts: readSQL(__dirname, 'insert.sql'),
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import PgSQL from '../../../../src/parser/pgsql';
|
import { PostgresSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const parser = new PgSQL();
|
const parser = new PostgresSQL();
|
||||||
|
|
||||||
const features = {
|
const features = {
|
||||||
others: readSQL(__dirname, 'others.sql'),
|
others: readSQL(__dirname, 'others.sql'),
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import PgSQL from '../../../../src/parser/pgsql';
|
import { PostgresSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const parser = new PgSQL();
|
const parser = new PostgresSQL();
|
||||||
|
|
||||||
const features = {
|
const features = {
|
||||||
selects: readSQL(__dirname, 'select.sql'),
|
selects: readSQL(__dirname, 'select.sql'),
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import PgSQL from '../../../../src/parser/pgsql';
|
import { PostgresSQL } from '../../../filters';
|
||||||
import { readSQL } from '../../../helper';
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
const parser = new PgSQL();
|
const parser = new PostgresSQL();
|
||||||
|
|
||||||
const features = {
|
const features = {
|
||||||
updates: readSQL(__dirname, 'update.sql'),
|
updates: readSQL(__dirname, 'update.sql'),
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
import { AbstractParseTreeVisitor } from 'antlr4ts/tree/AbstractParseTreeVisitor';
|
import { PostgresSQL, AbstractParseTreeVisitor, PostgreSQLParserVisitor } from '../../filters';
|
||||||
import { PostgreSQLParserVisitor } from '../../../src/lib/pgsql/PostgreSQLParserVisitor';
|
|
||||||
import PostgresSQL from '../../../src/parser/pgsql';
|
|
||||||
|
|
||||||
describe('MySQL Visitor Tests', () => {
|
describe('MySQL Visitor Tests', () => {
|
||||||
const expectTableName = 'user1';
|
const expectTableName = 'user1';
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import PLSQL from '../../../src/parser/plsql';
|
import { PLSQL } from '../../filters';
|
||||||
|
|
||||||
describe('PLSQL Lexer tests', () => {
|
describe('PLSQL Lexer tests', () => {
|
||||||
const parser = new PLSQL();
|
const parser = new PLSQL();
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
import { ParseTreeListener } from 'antlr4ts/tree';
|
import { PLSQL, PlSqlParserListener, ParseTreeListener } from '../../filters';
|
||||||
import { PlSqlParserListener } from '../../../src/lib/plsql/PlSqlParserListener';
|
|
||||||
import PLSQL from '../../../src/parser/plsql';
|
|
||||||
|
|
||||||
describe('PLSQL Listener Tests', () => {
|
describe('PLSQL Listener Tests', () => {
|
||||||
const expectTableName = 'user1';
|
const expectTableName = 'user1';
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import PLSQLParser from '../../../src/parser/plsql';
|
import { PLSQL } from '../../filters';
|
||||||
|
|
||||||
describe('PLSQL Syntax Tests', () => {
|
describe('PLSQL Syntax Tests', () => {
|
||||||
const parser = new PLSQLParser();
|
const parser = new PLSQL();
|
||||||
|
|
||||||
test('Test simple select Statement', () => {
|
test('Test simple select Statement', () => {
|
||||||
const sql = 'select id,name from user1;';
|
const sql = 'select id,name from user1;';
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
import { AbstractParseTreeVisitor } from 'antlr4ts/tree/AbstractParseTreeVisitor';
|
import { PLSQL, AbstractParseTreeVisitor, PlSqlParserVisitor } from '../../filters';
|
||||||
import { PlSqlParserVisitor } from '../../../src/lib/plsql/PlSqlParserVisitor';
|
|
||||||
import PLSQL from '../../../src/parser/plsql';
|
|
||||||
|
|
||||||
describe('PLSQL Visitor Tests', () => {
|
describe('PLSQL Visitor Tests', () => {
|
||||||
const expectTableName = 'user1';
|
const expectTableName = 'user1';
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
import SparkSQL from '../../../src/parser/spark';
|
import { SparkSQL, SparkSqlSplitListener, SparkSqlParserListener } from '../../filters';
|
||||||
import { SparkSqlSplitListener } from '../../../src/parser/spark';
|
|
||||||
import { SparkSqlParserListener } from '../../../src/lib/spark/SparkSqlParserListener';
|
|
||||||
|
|
||||||
const validSQL1 = `INSERT INTO country_page_view
|
const validSQL1 = `INSERT INTO country_page_view
|
||||||
VALUES ('Chinese', 'mumiao', 18),
|
VALUES ('Chinese', 'mumiao', 18),
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import SparkSQL from '../../../src/parser/spark';
|
import { SparkSQL } from '../../filters';
|
||||||
|
|
||||||
describe('SparkSQL Lexer tests', () => {
|
describe('SparkSQL Lexer tests', () => {
|
||||||
const parser = new SparkSQL();
|
const parser = new SparkSQL();
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user