Search in sources :

Example 1 with SqlSplitter

use of org.apache.zeppelin.interpreter.util.SqlSplitter in project zeppelin by apache.

the class JDBCInterpreter method open.

@Override
public void open() {
    super.open();
    for (String propertyKey : properties.stringPropertyNames()) {
        LOGGER.debug("propertyKey: {}", propertyKey);
        String[] keyValue = propertyKey.split("\\.", 2);
        if (2 == keyValue.length) {
            LOGGER.debug("key: {}, value: {}", keyValue[0], keyValue[1]);
            Properties prefixProperties;
            if (basePropertiesMap.containsKey(keyValue[0])) {
                prefixProperties = basePropertiesMap.get(keyValue[0]);
            } else {
                prefixProperties = new Properties();
                basePropertiesMap.put(keyValue[0].trim(), prefixProperties);
            }
            prefixProperties.put(keyValue[1].trim(), getProperty(propertyKey));
        }
    }
    Set<String> removeKeySet = new HashSet<>();
    for (String key : basePropertiesMap.keySet()) {
        if (!COMMON_KEY.equals(key)) {
            Properties properties = basePropertiesMap.get(key);
            if (!properties.containsKey(DRIVER_KEY) || !properties.containsKey(URL_KEY)) {
                LOGGER.error("{} will be ignored. {}.{} and {}.{} is mandatory.", key, DRIVER_KEY, key, key, URL_KEY);
                removeKeySet.add(key);
            }
        }
    }
    for (String key : removeKeySet) {
        basePropertiesMap.remove(key);
    }
    LOGGER.debug("JDBC PropertiesMap: {}", basePropertiesMap);
    setMaxLineResults();
    setMaxRows();
    // TODO(zjffdu) Set different sql splitter for different sql dialects.
    this.sqlSplitter = new SqlSplitter();
}
Also used : SqlSplitter(org.apache.zeppelin.interpreter.util.SqlSplitter) Properties(java.util.Properties) HashSet(java.util.HashSet)

Example 2 with SqlSplitter

use of org.apache.zeppelin.interpreter.util.SqlSplitter in project zeppelin by apache.

the class FlinkSqlInterpreter method open.

@Override
public void open() throws InterpreterException {
    this.sqlCommandParser = new SqlCommandParser(flinkInterpreter.getFlinkShims(), tbenv);
    this.sqlSplitter = new SqlSplitter();
    JobListener jobListener = new JobListener() {

        @Override
        public void onJobSubmitted(@Nullable JobClient jobClient, @Nullable Throwable throwable) {
            if (lock.isHeldByCurrentThread()) {
                lock.unlock();
                LOGGER.info("UnLock JobSubmitLock");
            }
        }

        @Override
        public void onJobExecuted(@Nullable JobExecutionResult jobExecutionResult, @Nullable Throwable throwable) {
        }
    };
    flinkInterpreter.getExecutionEnvironment().getJavaEnv().registerJobListener(jobListener);
    flinkInterpreter.getStreamExecutionEnvironment().getJavaEnv().registerJobListener(jobListener);
    this.defaultSqlParallelism = flinkInterpreter.getDefaultSqlParallelism();
    this.tableConfigOptions = flinkInterpreter.getFlinkShims().extractTableConfigOptions();
}
Also used : SqlSplitter(org.apache.zeppelin.interpreter.util.SqlSplitter) JobExecutionResult(org.apache.flink.api.common.JobExecutionResult) SqlCommandParser(org.apache.zeppelin.flink.sql.SqlCommandParser) JobListener(org.apache.flink.core.execution.JobListener) JobClient(org.apache.flink.core.execution.JobClient) Nullable(javax.annotation.Nullable)

Example 3 with SqlSplitter

use of org.apache.zeppelin.interpreter.util.SqlSplitter in project zeppelin by apache.

the class SparkSqlInterpreter method open.

@Override
public void open() throws InterpreterException {
    this.sparkInterpreter = getInterpreterInTheSameSessionByClassName(SparkInterpreter.class);
    this.sqlSplitter = new SqlSplitter();
}
Also used : SqlSplitter(org.apache.zeppelin.interpreter.util.SqlSplitter)

Aggregations

SqlSplitter (org.apache.zeppelin.interpreter.util.SqlSplitter)3 HashSet (java.util.HashSet)1 Properties (java.util.Properties)1 Nullable (javax.annotation.Nullable)1 JobExecutionResult (org.apache.flink.api.common.JobExecutionResult)1 JobClient (org.apache.flink.core.execution.JobClient)1 JobListener (org.apache.flink.core.execution.JobListener)1 SqlCommandParser (org.apache.zeppelin.flink.sql.SqlCommandParser)1