refactor(hive): extract hive export into src index
This commit is contained in:
parent
0f6c7849f2
commit
57aba357ab
@ -4,3 +4,5 @@ export * from './lib/flinksql/FlinkSqlParserListener';
|
|||||||
export * from './lib/flinksql/FlinkSqlParserVisitor';
|
export * from './lib/flinksql/FlinkSqlParserVisitor';
|
||||||
export * from './lib/generic/SqlParserVisitor';
|
export * from './lib/generic/SqlParserVisitor';
|
||||||
export * from './lib/generic/SqlParserListener';
|
export * from './lib/generic/SqlParserListener';
|
||||||
|
export * from './lib/hive/HiveSqlListener';
|
||||||
|
export * from './lib/hive/HiveSqlVisitor';
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
import { InputStream, CommonTokenStream, Lexer } from 'antlr4';
|
import { InputStream, CommonTokenStream, Lexer } from 'antlr4';
|
||||||
import { HiveSqlLexer } from '../lib/hive/HiveSqlLexer';
|
import { HiveSqlLexer } from '../lib/hive/HiveSqlLexer';
|
||||||
import { HiveSql } from '../lib/hive/HiveSql';
|
import { HiveSql } from '../lib/hive/HiveSql';
|
||||||
export * from '../lib/hive/HiveSqlListener';
|
|
||||||
export * from '../lib/hive/HiveSqlVisitor';
|
|
||||||
|
|
||||||
import BasicParser from './common/basicParser';
|
import BasicParser from './common/basicParser';
|
||||||
|
|
||||||
export default class HiveSQL extends BasicParser {
|
export default class HiveSQL extends BasicParser {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import SQLParser from '../../../src/parser/hive';
|
import { HiveSQL } from '../../../src';
|
||||||
|
|
||||||
describe('HiveSQL Lexer tests', () => {
|
describe('HiveSQL Lexer tests', () => {
|
||||||
const parser = new SQLParser();
|
const parser = new HiveSQL();
|
||||||
test('select token counts', () => {
|
test('select token counts', () => {
|
||||||
const sql = 'SELECT * FROM t1';
|
const sql = 'SELECT * FROM t1';
|
||||||
const tokens = parser.getAllTokens(sql);
|
const tokens = parser.getAllTokens(sql);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import SQLParser, { HiveSqlListener } from '../../../src/parser/hive';
|
import { HiveSQL, HiveSqlListener } from '../../../src';
|
||||||
|
|
||||||
describe('Hive SQL Listener Tests', () => {
|
describe('Hive SQL Listener Tests', () => {
|
||||||
const parser = new SQLParser();
|
const parser = new HiveSQL();
|
||||||
test('Listener enterSelectList', async () => {
|
test('Listener enterSelectList', async () => {
|
||||||
const expectTableName = 'userName';
|
const expectTableName = 'userName';
|
||||||
const sql = `select ${expectTableName} from user1 where inc_day='20190601' limit 1000;`;
|
const sql = `select ${expectTableName} from user1 where inc_day='20190601' limit 1000;`;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import SQLParser from '../../../src/parser/hive';
|
import { HiveSQL } from '../../../src';
|
||||||
|
|
||||||
describe('Hive SQL Syntax Tests', () => {
|
describe('Hive SQL Syntax Tests', () => {
|
||||||
const parser = new SQLParser();
|
const parser = new HiveSQL();
|
||||||
test('Create Table Statement', () => {
|
test('Create Table Statement', () => {
|
||||||
const sql = 'CREATE TABLE person(name STRING,age INT);';
|
const sql = 'CREATE TABLE person(name STRING,age INT);';
|
||||||
const result = parser.validate(sql);
|
const result = parser.validate(sql);
|
||||||
@ -13,10 +13,10 @@ describe('Hive SQL Syntax Tests', () => {
|
|||||||
expect(result.length).toBe(0);
|
expect(result.length).toBe(0);
|
||||||
});
|
});
|
||||||
test('Wrong Select Statement', () => {
|
test('Wrong Select Statement', () => {
|
||||||
const sql = 'SELECT add ABC from Where ;'
|
const sql = 'SELECT add ABC from Where ;';
|
||||||
const result = parser.validate(sql);
|
const result = parser.validate(sql);
|
||||||
expect(result.length).toBe(2);
|
expect(result.length).toBe(2);
|
||||||
expect(result[0].message).toBe(`no viable alternative at input 'SELECTaddABCfromWhere'`)
|
expect(result[0].message).toBe(`no viable alternative at input 'SELECTaddABCfromWhere'`);
|
||||||
expect(result[1].message).toBe(`mismatched input 'Where' expecting <EOF>`)
|
expect(result[1].message).toBe(`mismatched input 'Where' expecting <EOF>`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import SQLParser, { HiveSqlVisitor } from '../../../src/parser/hive';
|
import { HiveSQL, HiveSqlVisitor } from '../../../src';
|
||||||
|
|
||||||
describe('Generic SQL Visitor Tests', () => {
|
describe('Generic SQL Visitor Tests', () => {
|
||||||
const expectTableName = 'dm_gis.dlv_addr_tc_count';
|
const expectTableName = 'dm_gis.dlv_addr_tc_count';
|
||||||
const sql = `select citycode,tc,inc_day from ${expectTableName} where inc_day='20190501' limit 100;`;
|
const sql = `select citycode,tc,inc_day from ${expectTableName} where inc_day='20190501' limit 100;`;
|
||||||
const parser = new SQLParser();
|
const parser = new HiveSQL();
|
||||||
|
|
||||||
const parserTree = parser.parse(sql, (error) => {
|
const parserTree = parser.parse(sql, (error) => {
|
||||||
console.log('Parse error:', error);
|
console.log('Parse error:', error);
|
||||||
|
Loading…
Reference in New Issue
Block a user