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', () => {
|
||||
const parser = new SQLParser();
|
||||
|
||||
test('Select Statement', () => {
|
||||
const sql = 'SELECT * FROM employee WHERE salary>30000;';
|
||||
test('Create Table Statement', () => {
|
||||
const sql = 'CREATE TABLE person(name STRING,age INT);';
|
||||
const result = parser.validate(sql);
|
||||
|
||||
expect(result.length).toBe(0);
|
||||
});
|
||||
|
||||
test('Select 1+1', () => {
|
||||
const sql = 'SELECT 1+1;';
|
||||
test('Wrong Select Statement', () => {
|
||||
const sql = 'SELECT add ABC from Where ;'
|
||||
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>`)
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user