feat: hive Authorization syntax and unit tests (#159)
Co-authored-by: zhaoge <>
This commit is contained in:
parent
6a99d63d71
commit
2ec03f1770
@ -471,6 +471,7 @@ privilegeType
|
|||||||
| KW_UPDATE
|
| KW_UPDATE
|
||||||
| KW_CREATE
|
| KW_CREATE
|
||||||
| KW_DROP
|
| KW_DROP
|
||||||
|
| KW_INDEX
|
||||||
| KW_LOCK
|
| KW_LOCK
|
||||||
| KW_SELECT
|
| KW_SELECT
|
||||||
| KW_SHOW_DATABASE
|
| KW_SHOW_DATABASE
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Generated from /Users/xuxiaoqi/Documents/dt-sql-parser-copy/src/grammar/hive/HiveSqlLexer.g4 by ANTLR 4.9.0-SNAPSHOT
|
// Generated from /Users/xuxiaoqi/Documents/work/daishu-code/dt-sql-parser/src/grammar/hive/HiveSqlLexer.g4 by ANTLR 4.9.0-SNAPSHOT
|
||||||
|
|
||||||
|
|
||||||
import { ATN } from "antlr4ts/atn/ATN";
|
import { ATN } from "antlr4ts/atn/ATN";
|
||||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
|||||||
// Generated from /Users/xuxiaoqi/Documents/dt-sql-parser-copy/src/grammar/hive/HiveSqlParser.g4 by ANTLR 4.9.0-SNAPSHOT
|
// Generated from /Users/xuxiaoqi/Documents/work/daishu-code/dt-sql-parser/src/grammar/hive/HiveSqlParser.g4 by ANTLR 4.9.0-SNAPSHOT
|
||||||
|
|
||||||
|
|
||||||
import { ParseTreeListener } from "antlr4ts/tree/ParseTreeListener";
|
import { ParseTreeListener } from "antlr4ts/tree/ParseTreeListener";
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Generated from /Users/xuxiaoqi/Documents/dt-sql-parser-copy/src/grammar/hive/HiveSqlParser.g4 by ANTLR 4.9.0-SNAPSHOT
|
// Generated from /Users/xuxiaoqi/Documents/work/daishu-code/dt-sql-parser/src/grammar/hive/HiveSqlParser.g4 by ANTLR 4.9.0-SNAPSHOT
|
||||||
|
|
||||||
|
|
||||||
import { ParseTreeVisitor } from "antlr4ts/tree/ParseTreeVisitor";
|
import { ParseTreeVisitor } from "antlr4ts/tree/ParseTreeVisitor";
|
||||||
|
16
test/parser/hive/syntax/authorizationStatement.test.ts
Normal file
16
test/parser/hive/syntax/authorizationStatement.test.ts
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import HiveSQL from '../../../../src/parser/hive';
|
||||||
|
import { readSQL } from '../../../helper';
|
||||||
|
|
||||||
|
const parser = new HiveSQL();
|
||||||
|
|
||||||
|
const features = {
|
||||||
|
manageRoles: readSQL(__dirname, 'authorization.sql'),
|
||||||
|
};
|
||||||
|
|
||||||
|
describe('HiveSQL Related To Authorization Tests', () => {
|
||||||
|
features.manageRoles.forEach((manageRole) => {
|
||||||
|
it(manageRole, () => {
|
||||||
|
expect(parser.validate(manageRole).length).toBe(0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
34
test/parser/hive/syntax/fixtures/authorization.sql
Normal file
34
test/parser/hive/syntax/fixtures/authorization.sql
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
-- SQL Standards Based Hive Authorization
|
||||||
|
-- Role Management Commands -- Set Role
|
||||||
|
SET ROLE `admin`;
|
||||||
|
|
||||||
|
SET ROLE ALL;
|
||||||
|
|
||||||
|
SET ROLE NONE;
|
||||||
|
|
||||||
|
-- Role Management Commands -- Grant Role
|
||||||
|
GRANT role_name TO USER user_name;
|
||||||
|
|
||||||
|
GRANT role_name, role_name TO USER user1, ROLE role2 WITH ADMIN OPTION ;
|
||||||
|
|
||||||
|
-- Role Management Commands -- Revoke Role
|
||||||
|
REVOKE role_name FROM USER `user`;
|
||||||
|
|
||||||
|
REVOKE ADMIN OPTION FOR role_name, role_name FROM USER `user`, ROLE `role`;
|
||||||
|
|
||||||
|
-- Managing Object Privileges -- Object Privilege Commands
|
||||||
|
GRANT
|
||||||
|
INSERT
|
||||||
|
ON table_or_view_name
|
||||||
|
TO USER `user`;
|
||||||
|
|
||||||
|
GRANT INSERT, SELECT, UPDATE, DELETE, ALL ON table_or_view_name1 TO USER `user`, ROLE `role` WITH GRANT OPTION;
|
||||||
|
|
||||||
|
REVOKE INSERT
|
||||||
|
ON table_or_view_name
|
||||||
|
FROM USER `user`;
|
||||||
|
|
||||||
|
REVOKE GRANT OPTION FOR ALL, ALTER, UPDATE, CREATE, DROP, INDEX, LOCK, SELECT, SHOW_DATABASE
|
||||||
|
ON table_or_view_name
|
||||||
|
FROM USER `user`, ROLE `role`;
|
||||||
|
|
@ -93,6 +93,8 @@ SHOW CURRENT ROLES;
|
|||||||
-- Show Role Grant
|
-- Show Role Grant
|
||||||
SHOW ROLE GRANT USER user1;
|
SHOW ROLE GRANT USER user1;
|
||||||
|
|
||||||
|
SHOW ROLE GRANT ROLE `role`;
|
||||||
|
|
||||||
-- Show Principals
|
-- Show Principals
|
||||||
SHOW PRINCIPALS role1;
|
SHOW PRINCIPALS role1;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user