Search in sources :

Example 16 with UserRemoteException

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

the class TestDirectoryExplorerUDFs method testConstantFoldingOff.

@Test
public void testConstantFoldingOff() throws Exception {
    try {
        test("set `planner.enable_constant_folding` = false;");
        String query = "select * from dfs.`" + path + "/*/*.csv` where dir0 = %s('dfs.root','" + path + "')";
        for (ConstantFoldingTestConfig config : tests) {
            try {
                test(String.format(query, config.funcName));
            } catch (UserRemoteException e) {
                assertThat(e.getMessage(), containsString("Directory explorers [MAXDIR, IMAXDIR, MINDIR, IMINDIR] functions can not be used " + "when planner.enable_constant_folding option is set to false"));
            }
        }
    } finally {
        test("set `planner.enable_constant_folding` = true;");
    }
}
Also used : UserRemoteException(org.apache.drill.common.exceptions.UserRemoteException) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 17 with UserRemoteException

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

the class TestCTTAS method testCreatePersistentTableWhenTemporaryTableExists.

@Test(expected = UserRemoteException.class)
public void testCreatePersistentTableWhenTemporaryTableExists() throws Exception {
    String temporaryTableName = "temporary_table_exists_before_persistent";
    try {
        test("create TEMPORARY table %s as select 'A' as c1 from (values(1))", temporaryTableName);
        test("create table %s.%s as select 'A' as c1 from (values(1))", TEMP_SCHEMA, temporaryTableName);
    } catch (UserRemoteException e) {
        assertThat(e.getMessage(), containsString(String.format("VALIDATION ERROR: A table or view with given name [%s]" + " already exists 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 18 with UserRemoteException

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

the class TestCTTAS method testCreateWhenViewExists.

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

Example 19 with UserRemoteException

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

the class TestCTTAS method testCreationOutsideOfDefaultTemporaryWorkspace.

@Test(expected = UserRemoteException.class)
public void testCreationOutsideOfDefaultTemporaryWorkspace() throws Exception {
    try {
        String temporaryTableName = "temporary_table_outside_of_default_workspace";
        test("create TEMPORARY table %s.%s as select 'A' as c1 from (values(1))", temp2_schema, temporaryTableName);
    } catch (UserRemoteException e) {
        assertThat(e.getMessage(), containsString(String.format("VALIDATION ERROR: Temporary tables are not allowed to be created / dropped " + "outside of default temporary workspace [%s].", TEMP_SCHEMA)));
        throw e;
    }
}
Also used : UserRemoteException(org.apache.drill.common.exceptions.UserRemoteException) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 20 with UserRemoteException

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

the class TestCTTAS method testCreateWhenTemporaryTableExistsWithSchema.

@Test(expected = UserRemoteException.class)
public void testCreateWhenTemporaryTableExistsWithSchema() throws Exception {
    String temporaryTableName = "temporary_table_exists_with_schema";
    try {
        test("create TEMPORARY table %s.%s as select 'A' as c1 from (values(1))", TEMP_SCHEMA, temporaryTableName);
        test("create TEMPORARY table %s.%s as select 'A' as c1 from (values(1))", TEMP_SCHEMA, temporaryTableName);
    } catch (UserRemoteException e) {
        assertThat(e.getMessage(), containsString(String.format("VALIDATION ERROR: A table or view with given name [%s]" + " already exists 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)

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