From 13e52f50f777315c2151b8019f4561c218aae3ee Mon Sep 17 00:00:00 2001 From: hayden Date: Mon, 10 Jul 2023 10:37:19 +0800 Subject: [PATCH] test: hivesql schedule query ddl syntax unit tests --- test/parser/hive/syntax/alterStatement.test.ts | 9 +++++++++ test/parser/hive/syntax/fixtures/alterScheduleQuery.sql | 7 +++++++ .../parser/hive/syntax/fixtures/createScheduledQuery.sql | 4 ++-- test/parser/hive/syntax/fixtures/drop.sql | 3 +++ 4 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 test/parser/hive/syntax/fixtures/alterScheduleQuery.sql diff --git a/test/parser/hive/syntax/alterStatement.test.ts b/test/parser/hive/syntax/alterStatement.test.ts index ca5599a..b319d74 100644 --- a/test/parser/hive/syntax/alterStatement.test.ts +++ b/test/parser/hive/syntax/alterStatement.test.ts @@ -9,6 +9,7 @@ const features = { tables: readSQL(__dirname, 'alterTable.sql'), indexes: readSQL(__dirname, 'alterIndex.sql'), views: readSQL(__dirname, 'alterView.sql'), + scheduleQueries: readSQL(__dirname, 'alterScheduleQuery.sql'), }; describe('Hive Alter Syntax Tests', () => { @@ -51,4 +52,12 @@ describe('Hive Alter Syntax Tests', () => { }); }); }); + + describe('ALTER SCHEDULE QUERY', () => { + features.scheduleQueries.forEach((sq) => { + it(sq, () => { + expect(parser.validate(sq).length).toBe(0); + }); + }); + }); }); diff --git a/test/parser/hive/syntax/fixtures/alterScheduleQuery.sql b/test/parser/hive/syntax/fixtures/alterScheduleQuery.sql new file mode 100644 index 0000000..d545165 --- /dev/null +++ b/test/parser/hive/syntax/fixtures/alterScheduleQuery.sql @@ -0,0 +1,7 @@ +ALTER SCHEDULED QUERY sq_1 EVERY HOUR AT '0:07:30'; + +ALTER SCHEDULED QUERY sq_2 EXECUTED AS 'user2'; + +ALTER SCHEDULED QUERY sq_3 DISABLED; + +ALTER SCHEDULED QUERY sq_4 AS SELECT * FROM tbl1; diff --git a/test/parser/hive/syntax/fixtures/createScheduledQuery.sql b/test/parser/hive/syntax/fixtures/createScheduledQuery.sql index a1a8ae2..d5e5437 100644 --- a/test/parser/hive/syntax/fixtures/createScheduledQuery.sql +++ b/test/parser/hive/syntax/fixtures/createScheduledQuery.sql @@ -9,12 +9,12 @@ AS ANALYZE TABLE t CREATE SCHEDULED QUERY s_day EVERY 2 DAY OFFSET BY 'offsetTs' -EXECUTED AS 'SELECT * FROM aa' +EXECUTED AS 'admin' ENABLE DEFINED AS INSERT INTO t VALUES (1); CREATE SCHEDULED QUERY s_hour EVERY HOUR AT '0:07:30' -EXECUTED AS 'SELECT * FROM aa' +EXECUTED AS 'query_user_1' DISABLE DEFINED AS INSERT INTO t VALUES (1); diff --git a/test/parser/hive/syntax/fixtures/drop.sql b/test/parser/hive/syntax/fixtures/drop.sql index 0145002..b84630c 100644 --- a/test/parser/hive/syntax/fixtures/drop.sql +++ b/test/parser/hive/syntax/fixtures/drop.sql @@ -39,3 +39,6 @@ DROP INDEX IF EXISTS table02_index ON table02; DROP FUNCTION func1; DROP FUNCTION IF EXISTS func2; + +-- Drop Schedule Query +DROP SCHEDULED QUERY sq_1; \ No newline at end of file