Search in sources :

Example 1 with UserRemoteException

use of org.apache.drill.common.exceptions.UserRemoteException in project drill by apache.

the class TestImpersonationQueries method testMultiLevelImpersonationJoinOneSideExceedsMaxUserHops.

@Test
public void testMultiLevelImpersonationJoinOneSideExceedsMaxUserHops() throws Exception {
    UserRemoteException ex = null;
    try {
        updateClient(org1Users[4]);
        test(String.format("SELECT * from %s.u4_lineitem l JOIN %s.u4_orders o ON l.l_orderkey = o.o_orderkey LIMIT 1;", getWSSchema(org1Users[4]), getWSSchema(org2Users[4])));
    } catch (UserRemoteException e) {
        ex = e;
    }
    assertNotNull("UserRemoteException is expected", ex);
    assertThat(ex.getMessage(), containsString("Cannot issue token for view expansion as issuing the token exceeds the maximum allowed number " + "of user hops (3) in chained impersonation"));
}
Also used : UserRemoteException(org.apache.drill.common.exceptions.UserRemoteException) Test(org.junit.Test)

Example 2 with UserRemoteException

use of org.apache.drill.common.exceptions.UserRemoteException in project drill by apache.

the class TestCTTAS method testTemporaryTablesInViewDefinitions.

@Test(expected = UserRemoteException.class)
public void testTemporaryTablesInViewDefinitions() throws Exception {
    String temporaryTableName = "temporary_table_for_view_definition";
    test("create TEMPORARY table %s as select 'A' as c1 from (values(1))", temporaryTableName);
    try {
        test("create view %s.view_with_temp_table as select * from %s", TEMP_SCHEMA, temporaryTableName);
    } catch (UserRemoteException e) {
        assertThat(e.getMessage(), containsString(String.format("VALIDATION ERROR: Temporary tables usage is disallowed. Used temporary table name: [%s]", temporaryTableName)));
        throw e;
    }
}
Also used : UserRemoteException(org.apache.drill.common.exceptions.UserRemoteException) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 3 with UserRemoteException

use of org.apache.drill.common.exceptions.UserRemoteException in project drill by apache.

the class TestCTTAS method testDropTemporaryTableAsViewWithException.

@Test(expected = UserRemoteException.class)
public void testDropTemporaryTableAsViewWithException() throws Exception {
    String temporaryTableName = "temporary_table_to_drop_like_view_with_exception";
    test("create TEMPORARY table %s as select 'A' as c1 from (values(1))", temporaryTableName);
    try {
        test("drop view %s.%s", TEMP_SCHEMA, temporaryTableName);
    } catch (UserRemoteException e) {
        assertThat(e.getMessage(), containsString(String.format("VALIDATION ERROR: Unknown view [%s] in schema [%s]", temporaryTableName, TEMP_SCHEMA)));
        throw e;
    }
}
Also used : UserRemoteException(org.apache.drill.common.exceptions.UserRemoteException) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 4 with UserRemoteException

use of org.apache.drill.common.exceptions.UserRemoteException in project drill by apache.

the class TestCTTAS method testCreateWhenPersistentTableExists.

@Test(expected = UserRemoteException.class)
public void testCreateWhenPersistentTableExists() throws Exception {
    String persistentTableName = "persistent_table_exists";
    try {
        test("create table %s.%s as select 'A' as c1 from (values(1))", TEMP_SCHEMA, persistentTableName);
        test("create TEMPORARY table %s as select 'A' as c1 from (values(1))", persistentTableName);
    } catch (UserRemoteException e) {
        assertThat(e.getMessage(), containsString(String.format("VALIDATION ERROR: A table or view with given name [%s]" + " already exists in schema [%s]", persistentTableName, TEMP_SCHEMA)));
        throw e;
    }
}
Also used : UserRemoteException(org.apache.drill.common.exceptions.UserRemoteException) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 5 with UserRemoteException

use of org.apache.drill.common.exceptions.UserRemoteException in project drill by apache.

the class TestCTTAS method testTemporaryTablesInViewExpansionLogic.

@Test(expected = UserRemoteException.class)
public void testTemporaryTablesInViewExpansionLogic() throws Exception {
    String tableName = "table_for_expansion_logic_test";
    String viewName = "view_for_expansion_logic_test";
    test("use %s", TEMP_SCHEMA);
    test("create table %s as select 'TABLE' as c1 from (values(1))", tableName);
    test("create view %s as select * from %s", viewName, tableName);
    testBuilder().sqlQuery("select * from %s", viewName).unOrdered().baselineColumns("c1").baselineValues("TABLE").go();
    test("drop table %s", tableName);
    test("create temporary table %s as select 'TEMP' as c1 from (values(1))", tableName);
    try {
        test("select * from %s", viewName);
    } catch (UserRemoteException e) {
        assertThat(e.getMessage(), containsString(String.format("VALIDATION ERROR: Temporary tables usage is disallowed. Used temporary table name: [%s]", tableName)));
        throw e;
    }
}
Also used : UserRemoteException(org.apache.drill.common.exceptions.UserRemoteException) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Aggregations

UserRemoteException (org.apache.drill.common.exceptions.UserRemoteException)25 Test (org.junit.Test)22 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)15 File (java.io.File)2 QueryId (org.apache.drill.exec.proto.UserBitShared.QueryId)2 QueryState (org.apache.drill.exec.proto.UserBitShared.QueryResult.QueryState)2 Path (org.apache.hadoop.fs.Path)2 Matchers.anyString (org.mockito.Matchers.anyString)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 Map (java.util.Map)1 UserException (org.apache.drill.common.exceptions.UserException)1 FunctionImplementationRegistry (org.apache.drill.exec.expr.fn.FunctionImplementationRegistry)1 LocalFunctionRegistry (org.apache.drill.exec.expr.fn.registry.LocalFunctionRegistry)1 RemoteFunctionRegistry (org.apache.drill.exec.expr.fn.registry.RemoteFunctionRegistry)1 QueryResult (org.apache.drill.exec.proto.UserBitShared.QueryResult)1 RpcException (org.apache.drill.exec.rpc.RpcException)1 DataChangeVersion (org.apache.drill.exec.store.sys.store.DataChangeVersion)1 FileSystem (org.apache.hadoop.fs.FileSystem)1 StringContains.containsString (org.hamcrest.core.StringContains.containsString)1 Mockito.doAnswer (org.mockito.Mockito.doAnswer)1