test: hiveSQL test units of index

This commit is contained in:
hayden 2023-07-07 11:19:28 +08:00 committed by Ziv
parent ebd9a1ed85
commit f1ca0738d3
7 changed files with 51 additions and 13 deletions

View File

@ -15,6 +15,6 @@ describe('Hive SQL Syntax Tests', () => {
test('Wrong Select Statement', () => {
const sql = 'SELECT add ABC FROM WHERE;';
const result = parser.validate(sql);
expect(result.length).toBe(2);
expect(result.length).toBe(1);
});
});

View File

@ -0,0 +1,18 @@
import HiveSQL from '../../../../src/parser/hive';
import { readSQL } from '../../../helper';
const parser = new HiveSQL();
const features = {
indexes: readSQL(__dirname, 'alterIndex.sql'),
};
describe('Hive Alter Syntax Tests', () => {
describe('ALTER INDEX', () => {
features.indexes.forEach((index) => {
it(index, () => {
expect(parser.validate(index).length).toBe(0);
});
});
});
});

View File

@ -56,13 +56,13 @@ describe('Hive Create Syntax Tests', () => {
});
});
// describe('CREATE INDEX', () => {
// features.indexes.forEach((index) => {
// it(index, () => {
// expect(parser.validate(index).length).toBe(0);
// });
// });
// });
describe('CREATE INDEX', () => {
features.indexes.forEach((index) => {
it(index, () => {
expect(parser.validate(index).length).toBe(0);
});
});
});
describe('CREATE MACRO', () => {
features.macros.forEach((macro) => {

View File

@ -0,0 +1,18 @@
import HiveSQL from '../../../../src/parser/hive';
import { readSQL } from '../../../helper';
const parser = new HiveSQL();
const features = {
indexes: readSQL(__dirname, 'dropIndex.sql'),
};
describe('Hive Drop Syntax Tests', () => {
describe('DROP INDEX', () => {
features.indexes.forEach((index) => {
it(index, () => {
expect(parser.validate(index).length).toBe(0);
});
});
});
});

View File

@ -0,0 +1,3 @@
ALTER INDEX table01_index ON table01
PARTITION (pt1, pt2 = '2019-04-01')
REBUILD;

View File

@ -16,9 +16,9 @@ TBLPROPERTIES ("prop1"="value1", "prop2"="value2");
CREATE INDEX table04_index
ON TABLE table04 (column5)
AS 'COMPACT'
IDXPROPERTIES ("prop3"="value3", "prop4"="value4")
IN TABLE indextable1
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler';
IDXPROPERTIES ("prop3"="value3", "prop4"="value4");
CREATE INDEX table05_index
ON TABLE table05 (column6)
@ -30,7 +30,3 @@ ON TABLE table06 (column7)
AS 'COMPACT'
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
STORED AS TEXTFILE;

View File

@ -0,0 +1,3 @@
DROP INDEX table01_index ON table01;
DROP INDEX IF EXISTS table02_index ON table02;