Skip to content

Commit

Permalink
test: hivesql schedule query ddl syntax unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
HaydenOrz committed Jul 10, 2023
1 parent faabeff commit 13e52f5
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
9 changes: 9 additions & 0 deletions test/parser/hive/syntax/alterStatement.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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);
});
});
});
});
7 changes: 7 additions & 0 deletions test/parser/hive/syntax/fixtures/alterScheduleQuery.sql
Original file line number Diff line number Diff line change
@@ -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;
4 changes: 2 additions & 2 deletions test/parser/hive/syntax/fixtures/createScheduledQuery.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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);
3 changes: 3 additions & 0 deletions test/parser/hive/syntax/fixtures/drop.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit 13e52f5

Please sign in to comment.