test: add hive validate unit test

This commit is contained in:
chenfeng 2020-11-25 15:04:22 +08:00
parent e7e0c15b0d
commit 110c4f1fa5

View File

@ -2,17 +2,17 @@ import SQLParser from '../../../src/parser/hive';
describe('Hive SQL Syntax Tests', () => { describe('Hive SQL Syntax Tests', () => {
const parser = new SQLParser(); const parser = new SQLParser();
test('Create Table Statement', () => {
test('Select Statement', () => { const sql = 'CREATE TABLE person(name STRING,age INT);';
const sql = 'SELECT * FROM employee WHERE salary>30000;';
const result = parser.validate(sql); const result = parser.validate(sql);
expect(result.length).toBe(0); expect(result.length).toBe(0);
}); });
test('Wrong Select Statement', () => {
test('Select 1+1', () => { const sql = 'SELECT add ABC from Where ;'
const sql = 'SELECT 1+1;';
const result = parser.validate(sql); const result = parser.validate(sql);
expect(result.length).toBe(0); console.log(result)
expect(result.length).toBe(2);
expect(result[0].message).toBe(`no viable alternative at input 'SELECTaddABCfromWhere'`)
expect(result[1].message).toBe(`mismatched input 'Where' expecting <EOF>`)
}); });
}); });