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;
}
}
use of org.apache.drill.common.exceptions.UserRemoteException in project drill by apache.
the class TestCTTAS method testCreateWhenTemporaryTableExistsWithoutSchema.
@Test(expected = UserRemoteException.class)
public void testCreateWhenTemporaryTableExistsWithoutSchema() throws Exception {
String temporaryTableName = "temporary_table_exists_without_schema";
try {
test("create TEMPORARY table %s as select 'A' as c1 from (values(1))", temporaryTableName);
test("create TEMPORARY table %s as select 'A' as c1 from (values(1))", 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;
}
}
use of org.apache.drill.common.exceptions.UserRemoteException in project drill by apache.
the class TestDynamicUDFSupport method testDropFunction.
@Test
public void testDropFunction() throws Exception {
copyDefaultJarsToStagingArea();
test("create function using jar '%s'", default_binary_name);
test("select custom_lower('A') from (values(1))");
Path localUdfDirPath = Deencapsulation.getField(getDrillbitContext().getFunctionImplementationRegistry(), "localUdfDir");
File localUdfDir = new File(localUdfDirPath.toUri().getPath());
assertTrue("Binary should exist in local udf directory", new File(localUdfDir, default_binary_name).exists());
assertTrue("Source should exist in local udf directory", new File(localUdfDir, default_source_name).exists());
String summary = "The following UDFs in jar %s have been unregistered:\n" + "[custom_lower(VARCHAR-REQUIRED)]";
testBuilder().sqlQuery("drop function using jar '%s'", default_binary_name).unOrdered().baselineColumns("ok", "summary").baselineValues(true, String.format(summary, default_binary_name)).go();
try {
test("select custom_lower('A') from (values(1))");
} catch (UserRemoteException e) {
assertThat(e.getMessage(), containsString("No match found for function signature custom_lower(<CHARACTER>)"));
}
RemoteFunctionRegistry remoteFunctionRegistry = getDrillbitContext().getRemoteFunctionRegistry();
assertEquals("Remote registry should be empty", remoteFunctionRegistry.getRegistry(new DataChangeVersion()).getJarList().size(), 0);
FileSystem fs = remoteFunctionRegistry.getFs();
assertFalse("Binary should not be present in registry area", fs.exists(new Path(remoteFunctionRegistry.getRegistryArea(), default_binary_name)));
assertFalse("Source should not be present in registry area", fs.exists(new Path(remoteFunctionRegistry.getRegistryArea(), default_source_name)));
assertFalse("Binary should not be present in local udf directory", new File(localUdfDir, default_binary_name).exists());
assertFalse("Source should not be present in local udf directory", new File(localUdfDir, default_source_name).exists());
}
use of org.apache.drill.common.exceptions.UserRemoteException in project drill by apache.
the class TestDynamicUDFSupport method testLazyInitNoReload.
@Test
public void testLazyInitNoReload() throws Exception {
FunctionImplementationRegistry functionImplementationRegistry = spyFunctionImplementationRegistry();
copyDefaultJarsToStagingArea();
test("create function using jar '%s'", default_binary_name);
doAnswer(new Answer<Boolean>() {
@Override
public Boolean answer(InvocationOnMock invocation) throws Throwable {
boolean result = (boolean) invocation.callRealMethod();
assertTrue("syncWithRemoteRegistry() should return true", result);
return true;
}
}).doAnswer(new Answer() {
@Override
public Boolean answer(InvocationOnMock invocation) throws Throwable {
boolean result = (boolean) invocation.callRealMethod();
assertFalse("syncWithRemoteRegistry() should return false", result);
return false;
}
}).when(functionImplementationRegistry).syncWithRemoteRegistry(anyLong());
test("select custom_lower('A') from (values(1))");
try {
test("select unknown_lower('A') from (values(1))");
} catch (UserRemoteException e) {
assertThat(e.getMessage(), containsString("No match found for function signature unknown_lower(<CHARACTER>)"));
}
verify(functionImplementationRegistry, times(2)).syncWithRemoteRegistry(anyLong());
LocalFunctionRegistry localFunctionRegistry = Deencapsulation.getField(functionImplementationRegistry, "localFunctionRegistry");
assertEquals("Sync function registry version should match", 1L, localFunctionRegistry.getVersion());
}
use of org.apache.drill.common.exceptions.UserRemoteException in project drill by apache.
the class TestHiveStorage method testIncorrectHeaderFooterProperty.
// DRILL-3688
@Test
public void testIncorrectHeaderFooterProperty() throws Exception {
Map<String, String> testData = ImmutableMap.<String, String>builder().put("hive.skipper.kv_incorrect_skip_header", "skip.header.line.count").put("hive.skipper.kv_incorrect_skip_footer", "skip.footer.line.count").build();
String query = "select * from %s";
String exceptionMessage = "Hive table property %s value 'A' is non-numeric";
for (Map.Entry<String, String> entry : testData.entrySet()) {
try {
test(String.format(query, entry.getKey()));
} catch (UserRemoteException e) {
assertThat(e.getMessage(), containsString(String.format(exceptionMessage, entry.getValue())));
}
}
}
Aggregations