use of org.apache.drill.exec.server.options.OptionValue in project drill by apache.
the class TestConvertFunctions method testBigIntVarCharReturnTripConvertLogical_ScalarReplaceON.
// TODO(DRILL-2326) temporary until we fix the scalar replacement bug for this case
@Test
// Because this test sometimes fails, sometimes succeeds
@Ignore
public void testBigIntVarCharReturnTripConvertLogical_ScalarReplaceON() throws Exception {
final OptionValue srOption = QueryTestUtil.setupScalarReplacementOption(bits[0], ScalarReplacementOption.ON);
boolean caughtException = false;
try {
// this used to fail (with a JUnit assertion) until we fix the SR bug
// Something in DRILL-5116 seemed to fix this problem, so the test now
// succeeds - sometimes.
testBigIntVarCharReturnTripConvertLogical();
} catch (RpcException e) {
caughtException = true;
} finally {
QueryTestUtil.restoreScalarReplacementOption(bits[0], srOption);
}
// Yes: sometimes this works, sometimes it does not...
assertTrue(!caughtException || caughtException);
}
use of org.apache.drill.exec.server.options.OptionValue in project drill by apache.
the class UserSession method setSessionOption.
/**
* Set the option of a session level.
* Note: Option's kind is automatically detected if such option exists.
*
* @param name option name
* @param value option value
*/
public void setSessionOption(String name, String value) {
OptionValue.Kind optionKind = SystemOptionManager.getValidator(name).getKind();
OptionValue optionValue = OptionValue.createOption(optionKind, OptionValue.OptionType.SESSION, name, value);
sessionOptions.setOption(optionValue);
}
use of org.apache.drill.exec.server.options.OptionValue in project drill by apache.
the class SetOptionHandler method getPlan.
@Override
public PhysicalPlan getPlan(SqlNode sqlNode) throws ValidationException, ForemanSetupException {
final SqlSetOption option = unwrap(sqlNode, SqlSetOption.class);
final SqlNode value = option.getValue();
if (value != null && !(value instanceof SqlLiteral)) {
throw UserException.validationError().message("Drill does not support assigning non-literal values in SET statements.").build(logger);
}
final String scope = option.getScope();
final OptionValue.OptionType type;
if (scope == null) {
// No scope mentioned assumed SESSION
type = OptionType.SESSION;
} else {
switch(scope.toLowerCase()) {
case "session":
type = OptionType.SESSION;
break;
case "system":
type = OptionType.SYSTEM;
break;
default:
throw UserException.validationError().message("Invalid OPTION scope %s. Scope must be SESSION or SYSTEM.", scope).build(logger);
}
}
final OptionManager options = context.getOptions();
if (type == OptionType.SYSTEM) {
// administrative privileges.
if (context.isUserAuthenticationEnabled() && !ImpersonationUtil.hasAdminPrivileges(context.getQueryUserName(), options.getOption(ExecConstants.ADMIN_USERS_VALIDATOR), options.getOption(ExecConstants.ADMIN_USER_GROUPS_VALIDATOR))) {
throw UserException.permissionError().message("Not authorized to change SYSTEM options.").build(logger);
}
}
// Currently, we convert multi-part identifier to a string.
final String name = option.getName().toString();
if (value != null) {
// SET option
final OptionValue optionValue = createOptionValue(name, type, (SqlLiteral) value);
options.setOption(optionValue);
} else {
// RESET option
if ("ALL".equalsIgnoreCase(name)) {
options.deleteAllOptions(type);
} else {
options.deleteOption(name, type);
}
}
return DirectPlan.createDirectPlan(context, true, String.format("%s updated.", name));
}
use of org.apache.drill.exec.server.options.OptionValue in project drill by apache.
the class OptionIterator method next.
@Override
public OptionValueWrapper next() {
final OptionValue value = mergedOptions.next();
final Status status;
if (value.type == OptionType.BOOT) {
status = Status.BOOT;
} else {
final OptionValue def = SystemOptionManager.getValidator(value.name).getDefault();
if (value.equalsIgnoreType(def)) {
status = Status.DEFAULT;
} else {
status = Status.CHANGED;
}
}
return new OptionValueWrapper(value.name, value.kind, value.type, value.num_val, value.string_val, value.bool_val, value.float_val, status);
}
use of org.apache.drill.exec.server.options.OptionValue in project drill by apache.
the class ControlsInjectionUtil method setControls.
public static void setControls(final UserSession session, final String controls) {
validateControlsString(controls);
final OptionValue opValue = OptionValue.createString(OptionValue.OptionType.SESSION, DRILLBIT_CONTROL_INJECTIONS, controls);
final OptionManager options = session.getOptions();
try {
DRILLBIT_CONTROLS_VALIDATOR.validate(opValue, null);
options.setOption(opValue);
} catch (final Exception e) {
fail("Could not set controls options: " + e.getMessage());
}
// to simulate that a query completed
incrementer.increment(session);
}
Aggregations