Search in sources :

Example 6 with OptionValue

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);
}
Also used : OptionValue(org.apache.drill.exec.server.options.OptionValue) OptionManager(org.apache.drill.exec.server.options.OptionManager) RpcException(org.apache.drill.exec.rpc.RpcException)

Example 7 with OptionValue

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);
    }
}
Also used : OptionValue(org.apache.drill.exec.server.options.OptionValue) OptionManager(org.apache.drill.exec.server.options.OptionManager)

Example 8 with 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);
    }
}
Also used : OptionValue(org.apache.drill.exec.server.options.OptionValue) Test(org.junit.Test)

Aggregations

OptionValue (org.apache.drill.exec.server.options.OptionValue)8 OptionManager (org.apache.drill.exec.server.options.OptionManager)4 RpcException (org.apache.drill.exec.rpc.RpcException)2 Test (org.junit.Test)2 SqlLiteral (org.apache.calcite.sql.SqlLiteral)1 SqlNode (org.apache.calcite.sql.SqlNode)1 SqlSetOption (org.apache.calcite.sql.SqlSetOption)1 NlsString (org.apache.calcite.util.NlsString)1 DrillbitContext (org.apache.drill.exec.server.DrillbitContext)1 OptionType (org.apache.drill.exec.server.options.OptionValue.OptionType)1 Ignore (org.junit.Ignore)1