2023-05-04 10:13:05 +08:00
|
|
|
import HiveSQL from '../../../src/parser/hive';
|
2020-09-11 17:39:10 +08:00
|
|
|
|
|
|
|
describe('Hive SQL Syntax Tests', () => {
|
2021-01-05 17:45:54 +08:00
|
|
|
const parser = new HiveSQL();
|
2020-11-25 15:04:22 +08:00
|
|
|
test('Create Table Statement', () => {
|
|
|
|
const sql = 'CREATE TABLE person(name STRING,age INT);';
|
2020-09-11 17:39:10 +08:00
|
|
|
const result = parser.validate(sql);
|
|
|
|
expect(result.length).toBe(0);
|
|
|
|
});
|
2020-11-25 17:04:55 +08:00
|
|
|
test('Create Table Statement', () => {
|
|
|
|
const sql = `alter table dm_gis.table_name add if not exists partition (inc_day = '20190601');`;
|
|
|
|
const result = parser.validate(sql);
|
|
|
|
expect(result.length).toBe(0);
|
|
|
|
});
|
2020-11-25 15:04:22 +08:00
|
|
|
test('Wrong Select Statement', () => {
|
2023-05-30 14:44:03 +08:00
|
|
|
const sql = 'SELECT add ABC FROM WHERE;';
|
2020-09-11 17:39:10 +08:00
|
|
|
const result = parser.validate(sql);
|
2020-11-25 15:04:22 +08:00
|
|
|
expect(result.length).toBe(2);
|
2020-09-11 17:39:10 +08:00
|
|
|
});
|
2021-01-05 17:45:54 +08:00
|
|
|
});
|