Search in sources :

Example 1 with SetRole

use of com.facebook.presto.sql.tree.SetRole in project presto by prestodb.

the class TestSqlParser method testSetRole.

@Test
public void testSetRole() throws Exception {
    assertStatement("SET ROLE ALL", new SetRole(SetRole.Type.ALL, Optional.empty()));
    assertStatement("SET ROLE NONE", new SetRole(SetRole.Type.NONE, Optional.empty()));
    assertStatement("SET ROLE role", new SetRole(SetRole.Type.ROLE, Optional.of(new Identifier("role"))));
    assertStatement("SET ROLE \"role\"", new SetRole(SetRole.Type.ROLE, Optional.of(new Identifier("role"))));
}
Also used : SetRole(com.facebook.presto.sql.tree.SetRole) Identifier(com.facebook.presto.sql.tree.Identifier) QueryUtil.quotedIdentifier(com.facebook.presto.sql.QueryUtil.quotedIdentifier) Test(org.testng.annotations.Test)

Example 2 with SetRole

use of com.facebook.presto.sql.tree.SetRole in project presto by prestodb.

the class TestSetRoleTask method assertSetRole.

private void assertSetRole(String statement, Map<String, SelectedRole> expected) {
    SetRole setRole = (SetRole) parser.createStatement(statement);
    Session session = testSessionBuilder().setCatalog(CATALOG_NAME).build();
    QueryStateMachine stateMachine = createQueryStateMachine(statement, session, false, transactionManager, executor, metadata);
    SetRoleTask setRoleTask = new SetRoleTask();
    setRoleTask.execute(setRole, transactionManager, metadata, accessControl, stateMachine, ImmutableList.of());
    QueryInfo queryInfo = stateMachine.getQueryInfo(Optional.empty());
    assertEquals(queryInfo.getSetRoles(), expected);
}
Also used : SetRole(com.facebook.presto.sql.tree.SetRole) TaskTestUtils.createQueryStateMachine(com.facebook.presto.execution.TaskTestUtils.createQueryStateMachine) Session(com.facebook.presto.Session)

Aggregations

SetRole (com.facebook.presto.sql.tree.SetRole)2 Session (com.facebook.presto.Session)1 TaskTestUtils.createQueryStateMachine (com.facebook.presto.execution.TaskTestUtils.createQueryStateMachine)1 QueryUtil.quotedIdentifier (com.facebook.presto.sql.QueryUtil.quotedIdentifier)1 Identifier (com.facebook.presto.sql.tree.Identifier)1 Test (org.testng.annotations.Test)1