diff --git a/test/parser/hive/syntax.test.ts b/test/parser/hive/syntax.test.ts index 75c5b56..d3fe724 100644 --- a/test/parser/hive/syntax.test.ts +++ b/test/parser/hive/syntax.test.ts @@ -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); }); }); diff --git a/test/parser/hive/syntax/alterStatement.test.ts b/test/parser/hive/syntax/alterStatement.test.ts new file mode 100644 index 0000000..eb81e3e --- /dev/null +++ b/test/parser/hive/syntax/alterStatement.test.ts @@ -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); + }); + }); + }); +}); diff --git a/test/parser/hive/syntax/createStatement.test.ts b/test/parser/hive/syntax/createStatement.test.ts index 0e40a7c..19472d3 100644 --- a/test/parser/hive/syntax/createStatement.test.ts +++ b/test/parser/hive/syntax/createStatement.test.ts @@ -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) => { diff --git a/test/parser/hive/syntax/dropStatement.test.ts b/test/parser/hive/syntax/dropStatement.test.ts new file mode 100644 index 0000000..d2301f1 --- /dev/null +++ b/test/parser/hive/syntax/dropStatement.test.ts @@ -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); + }); + }); + }); +}); diff --git a/test/parser/hive/syntax/fixtures/alterIndex.sql b/test/parser/hive/syntax/fixtures/alterIndex.sql new file mode 100644 index 0000000..15f3c7a --- /dev/null +++ b/test/parser/hive/syntax/fixtures/alterIndex.sql @@ -0,0 +1,3 @@ +ALTER INDEX table01_index ON table01 +PARTITION (pt1, pt2 = '2019-04-01') +REBUILD; diff --git a/test/parser/hive/syntax/fixtures/createIndex.sql b/test/parser/hive/syntax/fixtures/createIndex.sql index 176d6dd..1de1187 100644 --- a/test/parser/hive/syntax/fixtures/createIndex.sql +++ b/test/parser/hive/syntax/fixtures/createIndex.sql @@ -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; - - - - diff --git a/test/parser/hive/syntax/fixtures/dropIndex.sql b/test/parser/hive/syntax/fixtures/dropIndex.sql new file mode 100644 index 0000000..95aad1b --- /dev/null +++ b/test/parser/hive/syntax/fixtures/dropIndex.sql @@ -0,0 +1,3 @@ +DROP INDEX table01_index ON table01; + +DROP INDEX IF EXISTS table02_index ON table02;