Search in sources :

Example 1 with CreateRole

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()))));
}
Also used : Identifier(io.prestosql.sql.tree.Identifier) QueryUtil.quotedIdentifier(io.prestosql.sql.QueryUtil.quotedIdentifier) PrincipalSpecification(io.prestosql.sql.tree.PrincipalSpecification) GrantorSpecification(io.prestosql.sql.tree.GrantorSpecification) CreateRole(io.prestosql.sql.tree.CreateRole) Test(org.testng.annotations.Test)

Aggregations

QueryUtil.quotedIdentifier (io.prestosql.sql.QueryUtil.quotedIdentifier)1 CreateRole (io.prestosql.sql.tree.CreateRole)1 GrantorSpecification (io.prestosql.sql.tree.GrantorSpecification)1 Identifier (io.prestosql.sql.tree.Identifier)1 PrincipalSpecification (io.prestosql.sql.tree.PrincipalSpecification)1 Test (org.testng.annotations.Test)1