use of io.prestosql.sql.tree.CreateRole in project hetu-core by openlookeng.
the class TestSqlParser method testCreateRole.
@Test
public void testCreateRole() {
assertStatement("CREATE ROLE role", new CreateRole(new Identifier("role"), Optional.empty()));
assertStatement("CREATE ROLE role1 WITH ADMIN admin", new CreateRole(new Identifier("role1"), Optional.of(new GrantorSpecification(GrantorSpecification.Type.PRINCIPAL, Optional.of(new PrincipalSpecification(PrincipalSpecification.Type.UNSPECIFIED, new Identifier("admin")))))));
assertStatement("CREATE ROLE \"role\" WITH ADMIN \"admin\"", new CreateRole(new Identifier("role"), Optional.of(new GrantorSpecification(GrantorSpecification.Type.PRINCIPAL, Optional.of(new PrincipalSpecification(PrincipalSpecification.Type.UNSPECIFIED, new Identifier("admin")))))));
assertStatement("CREATE ROLE \"ro le\" WITH ADMIN \"ad min\"", new CreateRole(new Identifier("ro le"), Optional.of(new GrantorSpecification(GrantorSpecification.Type.PRINCIPAL, Optional.of(new PrincipalSpecification(PrincipalSpecification.Type.UNSPECIFIED, new Identifier("ad min")))))));
assertStatement("CREATE ROLE \"!@#$%^&*'\" WITH ADMIN \"ад\"\"мін\"", new CreateRole(new Identifier("!@#$%^&*'"), Optional.of(new GrantorSpecification(GrantorSpecification.Type.PRINCIPAL, Optional.of(new PrincipalSpecification(PrincipalSpecification.Type.UNSPECIFIED, new Identifier("ад\"мін")))))));
assertStatement("CREATE ROLE role2 WITH ADMIN USER admin1", new CreateRole(new Identifier("role2"), Optional.of(new GrantorSpecification(GrantorSpecification.Type.PRINCIPAL, Optional.of(new PrincipalSpecification(PrincipalSpecification.Type.USER, new Identifier("admin1")))))));
assertStatement("CREATE ROLE role2 WITH ADMIN ROLE role1", new CreateRole(new Identifier("role2"), Optional.of(new GrantorSpecification(GrantorSpecification.Type.PRINCIPAL, Optional.of(new PrincipalSpecification(PrincipalSpecification.Type.ROLE, new Identifier("role1")))))));
assertStatement("CREATE ROLE role2 WITH ADMIN CURRENT_USER", new CreateRole(new Identifier("role2"), Optional.of(new GrantorSpecification(GrantorSpecification.Type.CURRENT_USER, Optional.empty()))));
assertStatement("CREATE ROLE role2 WITH ADMIN CURRENT_ROLE", new CreateRole(new Identifier("role2"), Optional.of(new GrantorSpecification(GrantorSpecification.Type.CURRENT_ROLE, Optional.empty()))));
}
Aggregations