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);
}
use of org.apache.drill.exec.server.options.OptionValue in project drill by apache.
the class Drillbit method javaPropertiesToSystemOptions.
private void javaPropertiesToSystemOptions() {
// get the system options property
final String allSystemProps = System.getProperty(SYSTEM_OPTIONS_NAME);
if ((allSystemProps == null) || allSystemProps.isEmpty()) {
return;
}
final OptionManager optionManager = getContext().getOptionManager();
// parse out the properties, validate, and then set them
final String[] systemProps = allSystemProps.split(",");
for (final String systemProp : systemProps) {
final String[] keyValue = systemProp.split("=");
if (keyValue.length != 2) {
throwInvalidSystemOption(systemProp, "does not contain a key=value assignment");
}
final String optionName = keyValue[0].trim();
if (optionName.isEmpty()) {
throwInvalidSystemOption(systemProp, "does not contain a key before the assignment");
}
final String optionString = stripQuotes(keyValue[1].trim(), systemProp);
if (optionString.isEmpty()) {
throwInvalidSystemOption(systemProp, "does not contain a value after the assignment");
}
final OptionValue defaultValue = optionManager.getOption(optionName);
if (defaultValue == null) {
throwInvalidSystemOption(systemProp, "does not specify a valid option name");
}
if (defaultValue.type != OptionType.SYSTEM) {
throwInvalidSystemOption(systemProp, "does not specify a SYSTEM option ");
}
final OptionValue optionValue = OptionValue.createOption(defaultValue.kind, OptionType.SYSTEM, optionName, optionString);
optionManager.setOption(optionValue);
}
}
use of org.apache.drill.exec.server.options.OptionValue in project drill by apache.
the class TestConvertFunctions method testConvertFromConvertToInt.
// DRILL-3854
@Test
public void testConvertFromConvertToInt() throws Exception {
final OptionValue srOption = QueryTestUtil.setupScalarReplacementOption(bits[0], ScalarReplacementOption.OFF);
try {
final String newTblName = "testConvertFromConvertToInt_tbl";
final String ctasQuery = String.format("CREATE TABLE %s.%s as \n" + "SELECT convert_to(r_regionkey, 'INT') as ct \n" + "FROM cp.`tpch/region.parquet`", TEMP_SCHEMA, newTblName);
final String query = String.format("SELECT convert_from(ct, 'INT') as cf \n" + "FROM %s.%s \n" + "ORDER BY ct", TEMP_SCHEMA, newTblName);
test("alter session set `planner.slice_target` = 1");
test(ctasQuery);
testBuilder().sqlQuery(query).ordered().baselineColumns("cf").baselineValues(0).baselineValues(1).baselineValues(2).baselineValues(3).baselineValues(4).build().run();
} finally {
// restore the system option
QueryTestUtil.restoreScalarReplacementOption(bits[0], srOption);
test("alter session set `planner.slice_target` = " + ExecConstants.SLICE_TARGET_DEFAULT);
}
}
Aggregations