diff --git a/drill/pom.xml b/drill/pom.xml new file mode 100644 index 00000000000..61f8afed21f --- /dev/null +++ b/drill/pom.xml @@ -0,0 +1,152 @@ + + + + + 4.0.0 + + + zeppelin + org.apache.zeppelin + 0.6.0-incubating-SNAPSHOT + + + org.apache.zeppelin + zeppelin-drill + jar + 0.6.0-incubating-SNAPSHOT + Zeppelin: Drill interpreter + http://www.apache.org + + + 1.1.0 + + + + + + mapr-releases + http://repository.mapr.com/maven/ + false + true + + + + + + org.apache.zeppelin + zeppelin-interpreter + ${project.version} + provided + + + + org.apache.commons + commons-exec + 1.1 + + + + org.slf4j + slf4j-api + + + + org.slf4j + slf4j-log4j12 + + + + org.apache.drill.exec + drill-jdbc + ${drill.drill.version} + + + junit + junit + test + + + + + + + org.apache.maven.plugins + maven-deploy-plugin + 2.7 + + true + + + + + maven-enforcer-plugin + 1.3.1 + + + enforce + none + + + + + + maven-dependency-plugin + 2.8 + + + copy-dependencies + package + + copy-dependencies + + + ${project.build.directory}/../../interpreter/drill + false + false + true + runtime + + + + copy-artifact + package + + copy + + + ${project.build.directory}/../../interpreter/drill + false + false + true + runtime + + + ${project.groupId} + ${project.artifactId} + ${project.version} + ${project.packaging} + + + + + + + + + + diff --git a/drill/src/main/java/org/apache/zeppelin/drill/DrillInterpreter.java b/drill/src/main/java/org/apache/zeppelin/drill/DrillInterpreter.java new file mode 100644 index 00000000000..f7fed768499 --- /dev/null +++ b/drill/src/main/java/org/apache/zeppelin/drill/DrillInterpreter.java @@ -0,0 +1,203 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.zeppelin.drill; + +import java.sql.*; +import java.util.List; +import java.util.Properties; + +import org.apache.zeppelin.interpreter.*; +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.apache.zeppelin.interpreter.InterpreterResult.Code; +import org.apache.zeppelin.scheduler.Scheduler; +import org.apache.zeppelin.scheduler.SchedulerFactory; + +/** + * Drill interpreter for Zeppelin. + */ +public class DrillInterpreter extends Interpreter { + Logger logger = LoggerFactory.getLogger(DrillInterpreter.class); + int commandTimeOut = 600000; + + static final String DRILL_URL = "drill.drill.url"; + static final String DRILL_USER = "drill.drill.user"; + static final String DRILL_PASSWORD = "drill.drill.password"; + + static { + Interpreter.register( + "drill", + "drill", + DrillInterpreter.class.getName(), + new InterpreterPropertyBuilder() + .add(DRILL_URL, "jdbc:drill:", "The URL for Drill Instance.") + .add(DRILL_USER, "mapr", "The Drill user") + .add(DRILL_PASSWORD, "", "The password for the Drill user").build()); + } + + public DrillInterpreter(Properties property) { + super(property); + } + + Connection jdbcConnection; + Exception exceptionOnConnect; + + //Test only method + public Connection getJdbcConnection() + throws SQLException { + String url = getProperty(DRILL_URL); + String user = getProperty(DRILL_USER); + String password = getProperty(DRILL_PASSWORD); + + return DriverManager.getConnection(url, user, password); + } + + @Override + public void open() { + logger.info("Jdbc open connection called!"); + try { + String driverName = "org.apache.drill.jdbc.Driver"; + Class.forName(driverName); + } catch (ClassNotFoundException e) { + logger.error("Cannot load JDBC driver class", e); + exceptionOnConnect = e; + return; + } + try { + jdbcConnection = getJdbcConnection(); + exceptionOnConnect = null; + logger.info("Successfully created JDBC connection"); + } + catch (SQLException e) { + logger.error("Cannot open JDBC connection", e); + exceptionOnConnect = e; + } + } + + @Override + public void close() { + try { + if (jdbcConnection != null) { + jdbcConnection.close(); + } + } + catch (SQLException e) { + logger.error("Cannot close connection", e); + } + finally { + jdbcConnection = null; + exceptionOnConnect = null; + } + } + + Statement currentStatement; + private InterpreterResult executeSql(String sql) { + try { + if (exceptionOnConnect != null) { + return new InterpreterResult(Code.ERROR, exceptionOnConnect.getMessage()); + } + currentStatement = jdbcConnection.createStatement(); + StringBuilder msg = null; + if (StringUtils.containsIgnoreCase(sql, "EXPLAIN ")) { + //return the explain as text, make this visual explain later + msg = new StringBuilder(); + } + else { + msg = new StringBuilder("%table "); + } + ResultSet res = currentStatement.executeQuery(sql); + try { + ResultSetMetaData md = res.getMetaData(); + for (int i = 1; i < md.getColumnCount() + 1; i++) { + if (i == 1) { + msg.append(md.getColumnName(i)); + } else { + msg.append("\t" + md.getColumnName(i)); + } + } + msg.append("\n"); + while (res.next()) { + for (int i = 1; i < md.getColumnCount() + 1; i++) { + msg.append(res.getString(i) + "\t"); + } + msg.append("\n"); + } + } + finally { + try { + res.close(); + currentStatement.close(); + } + finally { + currentStatement = null; + } + } + + InterpreterResult rett = new InterpreterResult(Code.SUCCESS, msg.toString()); + return rett; + } + catch (SQLException ex) { + logger.error("Can not run " + sql, ex); + return new InterpreterResult(Code.ERROR, ex.getMessage()); + } + } + + @Override + public InterpreterResult interpret(String cmd, InterpreterContext contextInterpreter) { + logger.info("Run SQL command '" + cmd + "'"); + return executeSql(cmd); + } + + @Override + public void cancel(InterpreterContext context) { + if (currentStatement != null) { + try { + currentStatement.cancel(); + } + catch (SQLException ex) { + } + finally { + currentStatement = null; + } + } + } + + @Override + public FormType getFormType() { + return FormType.SIMPLE; + } + + @Override + public int getProgress(InterpreterContext context) { + return 0; + } + + @Override + public Scheduler getScheduler() { + return SchedulerFactory.singleton().createOrGetFIFOScheduler( + DrillInterpreter.class.getName() + this.hashCode()); + } + + @Override + public List completion(String buf, int cursor) { + return null; + } + +} diff --git a/pom.xml b/pom.xml index a48440509c9..80c8864a6f5 100644 --- a/pom.xml +++ b/pom.xml @@ -93,6 +93,7 @@ hive tajo flink + drill ignite lens zeppelin-web @@ -111,6 +112,17 @@ 512m + + + + mapr-releases + http://repository.mapr.com/maven/ + false + true + + + + diff --git a/spark/pom.xml b/spark/pom.xml index 9b82acbedd5..6091a1069eb 100644 --- a/spark/pom.xml +++ b/spark/pom.xml @@ -668,15 +668,48 @@ - mapr3 + hadoop-2.7 + + 2.7.0 + 2.5.0 + 0.9.3 + hadoop2 + + + + + mapr5 false - 1.0.3-mapr-3.0.3 - 2.3.0-mapr-4.0.0-FCS - 0.7.1 + 2.7.0-mapr-1506 + 2.7.0-mapr-1506 + 0.98.12-mapr-1506 + 3.4.5-mapr-1503 + + + org.apache.curator + curator-recipes + 2.4.0 + + + org.apache.zookeeper + zookeeper + + + + + org.apache.zookeeper + zookeeper + 3.4.5-mapr-1503 + + @@ -685,9 +718,10 @@ false - 2.3.0-mapr-4.0.0-FCS - 2.3.0-mapr-4.0.0-FCS - 0.7.1 + 2.4.1-mapr-1408 + 2.4.1-mapr-1408 + 0.98.9-mapr-1503 + 3.4.5-mapr-1503 @@ -704,7 +738,7 @@ org.apache.zookeeper zookeeper - 3.4.5-mapr-1406 + 3.4.5-mapr-1503