refactor(spark): extract spark export into src index

This commit is contained in:
xiaowei 2021-01-05 17:57:33 +08:00
parent 221482cc7c
commit dc9974bbff
6 changed files with 11 additions and 12 deletions

View File

@ -8,3 +8,6 @@ export * from './lib/hive/HiveSqlListener';
export * from './lib/hive/HiveSqlVisitor'; export * from './lib/hive/HiveSqlVisitor';
export * from './lib/plsql/PlSqlParserListener'; export * from './lib/plsql/PlSqlParserListener';
export * from './lib/plsql/PlSqlParserVisitor'; export * from './lib/plsql/PlSqlParserVisitor';
export * from './lib/spark/SparkSqlVisitor';
export * from './lib/spark/SparkSqlListener';

View File

@ -1,9 +1,6 @@
import { InputStream, CommonTokenStream, Lexer } from 'antlr4'; import { InputStream, CommonTokenStream, Lexer } from 'antlr4';
import { SparkSqlLexer } from '../lib/spark/SparkSqlLexer'; import { SparkSqlLexer } from '../lib/spark/SparkSqlLexer';
import { SparkSqlParser } from '../lib/spark/SparkSqlParser'; import { SparkSqlParser } from '../lib/spark/SparkSqlParser';
export * from '../lib/spark/SparkSqlVisitor';
export * from '../lib/spark/SparkSqlListener';
import BasicParser from './common/basicParser'; import BasicParser from './common/basicParser';
export default class SparkSQL extends BasicParser { export default class SparkSQL extends BasicParser {

View File

@ -1,9 +1,9 @@
import SQLParser from '../../../src/parser/spark'; import { SparkSQL } from '../../../src';
const log = console.log.bind(console); const log = console.log.bind(console);
describe('SparkSQL Lexer tests', () => { describe('SparkSQL Lexer tests', () => {
const parser = new SQLParser(); const parser = new SparkSQL();
test('select id,name from user1;', () => { test('select id,name from user1;', () => {
const sql = `select id,name from user1;`; const sql = `select id,name from user1;`;

View File

@ -1,9 +1,9 @@
import SQLParser, { SparkSqlListener } from '../../../src/parser/spark'; import { SparkSQL, SparkSqlListener } from '../../../src';
describe('Spark SQL Listener Tests', () => { describe('Spark 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 SQLParser(); const parser = new SparkSQL();
const parserTree = parser.parse(sql); const parserTree = parser.parse(sql);

View File

@ -1,10 +1,9 @@
/* eslint-disable max-len */ import { SparkSQL } from '../../../src';
import SQLParser from '../../../src/parser/spark';
const error = console.log.bind(console, '***** error\n'); const error = console.log.bind(console, '***** error\n');
const validateTest = (sqls) => { const validateTest = (sqls) => {
const parser = new SQLParser(); const parser = new SparkSQL();
sqls.forEach((sql, i) => { sqls.forEach((sql, i) => {
const result = parser.validate(sql); const result = parser.validate(sql);
if (result.length !== 0) { if (result.length !== 0) {

View File

@ -1,9 +1,9 @@
import SQLParser, { SparkSqlVisitor } from '../../../src/parser/spark'; import { SparkSQL, SparkSqlVisitor } from '../../../src';
describe('Spark SQL Visitor Tests', () => { describe('Spark 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 SQLParser(); const parser = new SparkSQL();
const parserTree = parser.parse(sql, (error) => { const parserTree = parser.parse(sql, (error) => {
console.log('Parse error:', error); console.log('Parse error:', error);