test: add hive validate unit test
This commit is contained in:
parent
e7e0c15b0d
commit
110c4f1fa5
@ -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);
|
|
||||||
|
|
||||||
expect(result.length).toBe(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('Select 1+1', () => {
|
|
||||||
const sql = 'SELECT 1+1;';
|
|
||||||
const result = parser.validate(sql);
|
const result = parser.validate(sql);
|
||||||
expect(result.length).toBe(0);
|
expect(result.length).toBe(0);
|
||||||
});
|
});
|
||||||
|
test('Wrong Select Statement', () => {
|
||||||
|
const sql = 'SELECT add ABC from Where ;'
|
||||||
|
const result = parser.validate(sql);
|
||||||
|
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>`)
|
||||||
|
});
|
||||||
});
|
});
|
Loading…
Reference in New Issue
Block a user