use of org.apache.drill.common.exceptions.UserRemoteException in project drill by apache.
the class TestImpersonationMetadata method testCreateTableInWSWithNoPermissionsForQueryUser.
@Test
public void testCreateTableInWSWithNoPermissionsForQueryUser() throws Exception {
// Workspace dir owned by "processUser", workspace group is "group0" and "user2" is not part of "group0"
final String tableWS = "drillTestGrp0_755";
final String tableName = "table1";
UserRemoteException ex = null;
try {
updateClient(user2);
test("USE " + Joiner.on(".").join(MINIDFS_STORAGE_PLUGIN_NAME, tableWS));
test("CREATE TABLE " + tableName + " AS SELECT " + "c_custkey, c_nationkey FROM cp.`tpch/customer.parquet` ORDER BY c_custkey;");
} catch (UserRemoteException e) {
ex = e;
}
assertNotNull("UserRemoteException is expected", ex);
assertThat(ex.getMessage(), containsString("SYSTEM ERROR: RemoteException: Permission denied: user=drillTestUser2, access=WRITE, inode=\"/drillTestGrp0_755/"));
}
use of org.apache.drill.common.exceptions.UserRemoteException in project drill by apache.
the class TestImpersonationQueries method testDirectImpersonation_NoReadPermissions.
@Test
public void testDirectImpersonation_NoReadPermissions() throws Exception {
UserRemoteException ex = null;
try {
// Table lineitem is owned by "user0_1:group0_1" with permissions 750. Now try to read the table as "user2_1". We
// should expect a permission denied error as "user2_1" is not part of the "group0_1"
updateClient(org1Users[2]);
test(String.format("SELECT * FROM %s.lineitem ORDER BY l_orderkey LIMIT 1", getWSSchema(org1Users[0])));
} catch (UserRemoteException e) {
ex = e;
}
assertNotNull("UserRemoteException is expected", ex);
assertThat(ex.getMessage(), containsString("PERMISSION ERROR: " + String.format("Not authorized to read table [lineitem] in schema [%s.user0_1]", MINIDFS_STORAGE_PLUGIN_NAME)));
}
use of org.apache.drill.common.exceptions.UserRemoteException in project drill by apache.
the class TestDynamicUDFSupport method testDisableDynamicSupport.
@Test
public void testDisableDynamicSupport() throws Exception {
try {
test("alter system set `exec.udf.enable_dynamic_support` = false");
String[] actions = new String[] { "create", "drop" };
String query = "%s function using jar 'jar_name.jar'";
for (String action : actions) {
try {
test(query, action);
} catch (UserRemoteException e) {
assertThat(e.getMessage(), containsString("Dynamic UDFs support is disabled."));
}
}
} finally {
test("alter system reset `exec.udf.enable_dynamic_support`");
}
}
use of org.apache.drill.common.exceptions.UserRemoteException in project drill by apache.
the class TestDynamicUDFSupport method testLazyInit.
@Test
public void testLazyInit() throws Exception {
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>)"));
}
copyDefaultJarsToStagingArea();
test("create function using jar '%s'", default_binary_name);
testBuilder().sqlQuery("select custom_lower('A') as res from (values(1))").unOrdered().baselineColumns("res").baselineValues("a").go();
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());
}
use of org.apache.drill.common.exceptions.UserRemoteException in project drill by apache.
the class QueryResultHandler method resultArrived.
/**
* Maps internal low-level API protocol to {@link UserResultsListener}-level API protocol.
* handles data result messages
*/
public void resultArrived(ByteBuf pBody) throws RpcException {
final QueryResult queryResult = RpcBus.get(pBody, QueryResult.PARSER);
final QueryId queryId = queryResult.getQueryId();
final QueryState queryState = queryResult.getQueryState();
if (logger.isDebugEnabled()) {
logger.debug("resultArrived: queryState: {}, queryId = {}", queryState, QueryIdHelper.getQueryId(queryId));
}
assert queryResult.hasQueryState() : "received query result without QueryState";
final boolean isFailureResult = QueryState.FAILED == queryState;
// CANCELED queries are handled the same way as COMPLETED
final boolean isTerminalResult;
switch(queryState) {
case FAILED:
case CANCELED:
case COMPLETED:
isTerminalResult = true;
break;
default:
logger.error("Unexpected/unhandled QueryState " + queryState + " (for query " + queryId + ")");
isTerminalResult = false;
break;
}
assert isFailureResult || queryResult.getErrorCount() == 0 : "Error count for the query batch is non-zero but QueryState != FAILED";
UserResultsListener resultsListener = newUserResultsListener(queryId);
try {
if (isFailureResult) {
// Failure case--pass on via submissionFailed(...).
resultsListener.submissionFailed(new UserRemoteException(queryResult.getError(0)));
// Note: Listener is removed in finally below.
} else if (isTerminalResult) {
try {
resultsListener.queryCompleted(queryState);
} catch (Exception e) {
resultsListener.submissionFailed(UserException.systemError(e).build(logger));
}
} else {
logger.warn("queryState {} was ignored", queryState);
}
} finally {
if (isTerminalResult) {
// for it?
if ((!(resultsListener instanceof BufferingResultsListener) || ((BufferingResultsListener) resultsListener).output != null)) {
queryIdToResultsListenersMap.remove(queryId, resultsListener);
}
}
}
}
Aggregations