From 110c4f1fa585872dff309bbc7d8688381c565b21 Mon Sep 17 00:00:00 2001 From: chenfeng Date: Wed, 25 Nov 2020 15:04:22 +0800 Subject: [PATCH] test: add hive validate unit test --- test/parser/hive/syntax.test.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/test/parser/hive/syntax.test.ts b/test/parser/hive/syntax.test.ts index e6f6da6..2ef6f36 100644 --- a/test/parser/hive/syntax.test.ts +++ b/test/parser/hive/syntax.test.ts @@ -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;'; - const result = parser.validate(sql); - - expect(result.length).toBe(0); - }); - - test('Select 1+1', () => { - const sql = 'SELECT 1+1;'; + test('Create Table Statement', () => { + const sql = 'CREATE TABLE person(name STRING,age INT);'; const result = parser.validate(sql); 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 `) + }); +}); \ No newline at end of file