Skip to content

Commit f1ca073

Browse files
HaydenOrzwewoor
authored andcommitted
test: hiveSQL test units of index
1 parent ebd9a1e commit f1ca073

File tree

7 files changed

+51
-13
lines changed

7 files changed

+51
-13
lines changed

test/parser/hive/syntax.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ describe('Hive SQL Syntax Tests', () => {
1515
test('Wrong Select Statement', () => {
1616
const sql = 'SELECT add ABC FROM WHERE;';
1717
const result = parser.validate(sql);
18-
expect(result.length).toBe(2);
18+
expect(result.length).toBe(1);
1919
});
2020
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import HiveSQL from '../../../../src/parser/hive';
2+
import { readSQL } from '../../../helper';
3+
4+
const parser = new HiveSQL();
5+
6+
const features = {
7+
indexes: readSQL(__dirname, 'alterIndex.sql'),
8+
};
9+
10+
describe('Hive Alter Syntax Tests', () => {
11+
describe('ALTER INDEX', () => {
12+
features.indexes.forEach((index) => {
13+
it(index, () => {
14+
expect(parser.validate(index).length).toBe(0);
15+
});
16+
});
17+
});
18+
});

test/parser/hive/syntax/createStatement.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ describe('Hive Create Syntax Tests', () => {
5656
});
5757
});
5858

59-
// describe('CREATE INDEX', () => {
60-
// features.indexes.forEach((index) => {
61-
// it(index, () => {
62-
// expect(parser.validate(index).length).toBe(0);
63-
// });
64-
// });
65-
// });
59+
describe('CREATE INDEX', () => {
60+
features.indexes.forEach((index) => {
61+
it(index, () => {
62+
expect(parser.validate(index).length).toBe(0);
63+
});
64+
});
65+
});
6666

6767
describe('CREATE MACRO', () => {
6868
features.macros.forEach((macro) => {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import HiveSQL from '../../../../src/parser/hive';
2+
import { readSQL } from '../../../helper';
3+
4+
const parser = new HiveSQL();
5+
6+
const features = {
7+
indexes: readSQL(__dirname, 'dropIndex.sql'),
8+
};
9+
10+
describe('Hive Drop Syntax Tests', () => {
11+
describe('DROP INDEX', () => {
12+
features.indexes.forEach((index) => {
13+
it(index, () => {
14+
expect(parser.validate(index).length).toBe(0);
15+
});
16+
});
17+
});
18+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ALTER INDEX table01_index ON table01
2+
PARTITION (pt1, pt2 = '2019-04-01')
3+
REBUILD;

test/parser/hive/syntax/fixtures/createIndex.sql

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ TBLPROPERTIES ("prop1"="value1", "prop2"="value2");
1616
CREATE INDEX table04_index
1717
ON TABLE table04 (column5)
1818
AS 'COMPACT'
19+
IDXPROPERTIES ("prop3"="value3", "prop4"="value4")
1920
IN TABLE indextable1
2021
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler';
21-
IDXPROPERTIES ("prop3"="value3", "prop4"="value4");
2222

2323
CREATE INDEX table05_index
2424
ON TABLE table05 (column6)
@@ -30,7 +30,3 @@ ON TABLE table06 (column7)
3030
AS 'COMPACT'
3131
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
3232
STORED AS TEXTFILE;
33-
34-
35-
36-
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
DROP INDEX table01_index ON table01;
2+
3+
DROP INDEX IF EXISTS table02_index ON table02;

0 commit comments

Comments
 (0)