mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
generic interpreter for jdbc
This commit is contained in:
parent
669897d466
commit
53d0a81389
13 changed files with 168 additions and 96 deletions
|
|
@ -67,6 +67,9 @@ if [[ -d "${ZEPPELIN_HOME}/zeppelin-server/target/classes" ]]; then
|
|||
ZEPPELIN_CLASSPATH+=":${ZEPPELIN_HOME}/zeppelin-server/target/classes"
|
||||
fi
|
||||
|
||||
# Add jdbc connector jar
|
||||
ZEPPELIN_CLASSPATH+=":${ZEPPELIN_HOME}/jdbc/jdbc/postgresql-9.4-1204.jdbc4.jar"
|
||||
|
||||
addJarInDir "${ZEPPELIN_HOME}"
|
||||
addJarInDir "${ZEPPELIN_HOME}/lib"
|
||||
addJarInDir "${ZEPPELIN_HOME}/zeppelin-interpreter/target/lib"
|
||||
|
|
|
|||
78
cassandra/.cache-main
Normal file
78
cassandra/.cache-main
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
format version: 5
|
||||
output mode:
|
||||
1 items
|
||||
0 -> multiple
|
||||
output directories:
|
||||
2 items
|
||||
/home/victorgarcia/my-repo/contributions/incubator-zeppelin/cassandra/src/main/java -> /home/victorgarcia/my-repo/contributions/incubator-zeppelin/cassandra/target/classes
|
||||
/home/victorgarcia/my-repo/contributions/incubator-zeppelin/cassandra/src/main/resources -> /home/victorgarcia/my-repo/contributions/incubator-zeppelin/cassandra/target/classes
|
||||
compile options:
|
||||
6 items
|
||||
0 -> -javabootclasspath
|
||||
1 -> /usr/lib/jvm/java-7-oracle/jre/lib/resources.jar:/usr/lib/jvm/java-7-oracle/jre/lib/rt.jar:/usr/lib/jvm/java-7-oracle/jre/lib/jsse.jar:/usr/lib/jvm/java-7-oracle/jre/lib/jce.jar:/usr/lib/jvm/java-7-oracle/jre/lib/charsets.jar:/usr/lib/jvm/java-7-oracle/jre/lib/jfr.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/dnsns.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/sunpkcs11.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/localedata.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/sunec.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/zipfs.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/sunjce_provider.jar
|
||||
2 -> -javaextdirs
|
||||
3 ->
|
||||
4 -> -bootclasspath
|
||||
5 -> /home/victorgarcia/eclipse/plugins/org.scala-lang.scala-library_2.11.6.v20150224-172222-092690e7bf.jar
|
||||
javac options:
|
||||
0 items
|
||||
compiler version:
|
||||
1 items
|
||||
0 -> 2.11.6
|
||||
compile order:
|
||||
1 items
|
||||
0 -> Mixed
|
||||
name hashing:
|
||||
1 items
|
||||
0 -> false
|
||||
products:
|
||||
0 items
|
||||
binary dependencies:
|
||||
0 items
|
||||
direct source dependencies:
|
||||
0 items
|
||||
direct external dependencies:
|
||||
0 items
|
||||
public inherited source dependencies:
|
||||
0 items
|
||||
public inherited external dependencies:
|
||||
0 items
|
||||
member reference internal dependencies:
|
||||
0 items
|
||||
member reference external dependencies:
|
||||
0 items
|
||||
inheritance internal dependencies:
|
||||
0 items
|
||||
inheritance external dependencies:
|
||||
0 items
|
||||
class names:
|
||||
0 items
|
||||
used names:
|
||||
0 items
|
||||
product stamps:
|
||||
0 items
|
||||
source stamps:
|
||||
2 items
|
||||
/home/victorgarcia/my-repo/contributions/incubator-zeppelin/cassandra/src/main/java/org/apache/zeppelin/cassandra/CassandraInterpreter.java -> hash(ebc3aeeb8ab1d5afe8019f818850956e219e4216)
|
||||
/home/victorgarcia/my-repo/contributions/incubator-zeppelin/cassandra/src/main/java/org/apache/zeppelin/cassandra/ParsingException.java -> hash(0a9561e3330c86993c59a34224e04d4504dd4328)
|
||||
binary stamps:
|
||||
0 items
|
||||
class names:
|
||||
0 items
|
||||
internal apis:
|
||||
2 items
|
||||
/home/victorgarcia/my-repo/contributions/incubator-zeppelin/cassandra/src/main/java/org/apache/zeppelin/cassandra/CassandraInter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dAASTGphdmEvbGFuZy9TdHJpbmc7TAAPc291cmNlRGlyZWN0b3J5cQB+ABp4cHQAVC9ob21lL3ZpY3RvcmdhcmNpYS9teS1yZXBvL2NvbnRyaWJ1dGlvbnMvaW5jdWJhdG9yLXplcHBlbGluL2Nhc3NhbmRyYS90YXJnZXQvY2xhc3Nlc3QAUy9ob21lL3ZpY3RvcmdhcmNpYS9teS1yZXBvL2NvbnRyaWJ1dGlvbnMvaW5jdWJhdG9yLXplcHBlbGluL2Nhc3NhbmRyYS9zcmMvbWFpbi9qYXZhc3EAfgAZdABUL2hvbWUvdmljdG9yZ2FyY2lhL215LXJlcG8vY29udHJpYnV0aW9ucy9pbmN1YmF0b3ItemVwcGVsaW4vY2Fzc2FuZHJhL3RhcmdldC9jbGFzc2VzdABYL2hvbWUvdmljdG9yZ2FyY2lhL215LXJlcG8vY29udHJpYnV0aW9ucy9pbmN1YmF0b3ItemVwcGVsaW4vY2Fzc2FuZHJhL3NyYy9tYWluL3Jlc291cmNlc3VyAAJbQqzzF/gGCFTgAgAAeHAAAAAU68Ou64qx1a/oAZ+BiFCVbiGeQhY=
|
||||
/home/victorgarcia/my-repo/contributions/incubator-zeppelin/cassandra/src/main/java/org/apache/zeppelin/cassandra/ParsingException.java ->
|
||||
rO0ABXNyABB4c2J0aS5hcGkuU291cmNlFlpwRASfbtoCAAZJAAdhcGlIYXNoWgAIaGFzTWFjcm9MABhfaW50ZXJuYWxPbmx5X25hbWVIYXNoZXN0ACRMeHNidGkvYXBpL19pbnRlcm5hbE9ubHlfTmFtZUhhc2hlcztMAANhcGl0ABVMeHNidGkvYXBpL1NvdXJjZUFQSTtMAAtjb21waWxhdGlvbnQAF0x4c2J0aS9hcGkvQ29tcGlsYXRpb247WwAEaGFzaHQAAltCeHC4IVHqAHNyACJ4c2J0aS5hcGkuX2ludGVybmFsT25seV9OYW1lSGFzaGVzVNq+mfrU7EwCAAJbAA9pbXBsaWNpdE1lbWJlcnN0ACNbTHhzYnRpL2FwaS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JhL3RhcmdldC9jbGFzc2VzdABYL2hvbWUvdmljdG9yZ2FyY2lhL215LXJlcG8vY29udHJpYnV0aW9ucy9pbmN1YmF0b3ItemVwcGVsaW4vY2Fzc2FuZHJhL3NyYy9tYWluL3Jlc291cmNlc3VyAAJbQqzzF/gGCFTgAgAAeHAAAAAUCpVh4zMMhpk8WaNCJOBNRQTdQyg=
|
||||
external apis:
|
||||
0 items
|
||||
source infos:
|
||||
2 items
|
||||
/home/victorgarcia/my-repo/contributions/incubator-zeppelin/cassandra/src/main/java/org/apache/zeppelin/cassandra/CassandraInterpreter.java ->
|
||||
AAAAAAAAAAA=
|
||||
/home/victorgarcia/my-repo/contributions/incubator-zeppelin/cassandra/src/main/java/org/apache/zeppelin/cassandra/ParsingException.java ->
|
||||
AAAAAAAAAAA=
|
||||
compilations:
|
||||
1 items
|
||||
0 -> rO0ABXNyABV4c2J0aS5hcGkuQ29tcGlsYXRpb27t+uDDauigQgIAAkoACXN0YXJ0VGltZVsAB291dHB1dHN0ABpbTHhzYnRpL2FwaS9PdXRwdXRTZXR0aW5nO3hwAAABUJAlr3h1cgAaW0x4c2J0aS5hcGkuT3V0cHV0U2V0dGluZzt/asLzp4elQgIAAHhwAAAAAnNyABd4c2J0aS5hcGkuT3V0cHV0U2V0dGluZ3rZmkd0+x17AgACTAAPb3V0cHV0RGlyZWN0b3J5dAASTGphdmEvbGFuZy9TdHJpbmc7TAAPc291cmNlRGlyZWN0b3J5cQB+AAZ4cHQAVC9ob21lL3ZpY3RvcmdhcmNpYS9teS1yZXBvL2NvbnRyaWJ1dGlvbnMvaW5jdWJhdG9yLXplcHBlbGluL2Nhc3NhbmRyYS90YXJnZXQvY2xhc3Nlc3QAUy9ob21lL3ZpY3RvcmdhcmNpYS9teS1yZXBvL2NvbnRyaWJ1dGlvbnMvaW5jdWJhdG9yLXplcHBlbGluL2Nhc3NhbmRyYS9zcmMvbWFpbi9qYXZhc3EAfgAFdABUL2hvbWUvdmljdG9yZ2FyY2lhL215LXJlcG8vY29udHJpYnV0aW9ucy9pbmN1YmF0b3ItemVwcGVsaW4vY2Fzc2FuZHJhL3RhcmdldC9jbGFzc2VzdABYL2hvbWUvdmljdG9yZ2FyY2lhL215LXJlcG8vY29udHJpYnV0aW9ucy9pbmN1YmF0b3ItemVwcGVsaW4vY2Fzc2FuZHJhL3NyYy9tYWluL3Jlc291cmNlcw==
|
||||
|
|
@ -85,7 +85,7 @@
|
|||
|
||||
<property>
|
||||
<name>zeppelin.interpreters</name>
|
||||
<value>org.apache.zeppelin.spark.SparkInterpreter,org.apache.zeppelin.spark.PySparkInterpreter,org.apache.zeppelin.spark.SparkSqlInterpreter,org.apache.zeppelin.spark.DepInterpreter,org.apache.zeppelin.markdown.Markdown,org.apache.zeppelin.angular.AngularInterpreter,org.apache.zeppelin.shell.ShellInterpreter,org.apache.zeppelin.hive.HiveInterpreter,org.apache.zeppelin.tajo.TajoInterpreter,org.apache.zeppelin.flink.FlinkInterpreter,org.apache.zeppelin.lens.LensInterpreter,org.apache.zeppelin.ignite.IgniteInterpreter,org.apache.zeppelin.ignite.IgniteSqlInterpreter,org.apache.zeppelin.cassandra.CassandraInterpreter,org.apache.zeppelin.geode.GeodeOqlInterpreter,org.apache.zeppelin.postgresql.PostgreSqlInterpreter,org.apache.zeppelin.phoenix.PhoenixInterpreter,org.apache.zeppelin.kylin.KylinInterpreter</value>
|
||||
<value>org.apache.zeppelin.spark.SparkInterpreter,org.apache.zeppelin.spark.PySparkInterpreter,org.apache.zeppelin.spark.SparkSqlInterpreter,org.apache.zeppelin.spark.DepInterpreter,org.apache.zeppelin.markdown.Markdown,org.apache.zeppelin.angular.AngularInterpreter,org.apache.zeppelin.shell.ShellInterpreter,org.apache.zeppelin.hive.HiveInterpreter,org.apache.zeppelin.tajo.TajoInterpreter,org.apache.zeppelin.flink.FlinkInterpreter,org.apache.zeppelin.lens.LensInterpreter,org.apache.zeppelin.ignite.IgniteInterpreter,org.apache.zeppelin.ignite.IgniteSqlInterpreter,org.apache.zeppelin.cassandra.CassandraInterpreter,org.apache.zeppelin.geode.GeodeOqlInterpreter,org.apache.zeppelin.jdbc.JDBCInterpreter,org.apache.zeppelin.phoenix.PhoenixInterpreter,org.apache.zeppelin.kylin.KylinInterpreter</value>
|
||||
<description>Comma separated interpreter configurations. First interpreter become a default</description>
|
||||
</property>
|
||||
|
||||
|
|
|
|||
|
|
@ -27,16 +27,12 @@
|
|||
</parent>
|
||||
|
||||
<groupId>org.apache.zeppelin</groupId>
|
||||
<artifactId>zeppelin-postgresql</artifactId>
|
||||
<artifactId>zeppelin-jdbc</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>0.6.0-incubating-SNAPSHOT</version>
|
||||
<name>Zeppelin: PostgreSQL interpreter</name>
|
||||
<name>Zeppelin: JDBC interpreter</name>
|
||||
<url>http://www.apache.org</url>
|
||||
|
||||
<properties>
|
||||
<postgresql.version>9.4-1201-jdbc41</postgresql.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.zeppelin</groupId>
|
||||
|
|
@ -54,13 +50,7 @@
|
|||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<version>${postgresql.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
|
|
@ -126,7 +116,7 @@
|
|||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.directory}/../../interpreter/psql</outputDirectory>
|
||||
<outputDirectory>${project.build.directory}/../../interpreter/jdbc</outputDirectory>
|
||||
<overWriteReleases>false</overWriteReleases>
|
||||
<overWriteSnapshots>false</overWriteSnapshots>
|
||||
<overWriteIfNewer>true</overWriteIfNewer>
|
||||
|
|
@ -140,7 +130,7 @@
|
|||
<goal>copy</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.directory}/../../interpreter/psql</outputDirectory>
|
||||
<outputDirectory>${project.build.directory}/../../interpreter/jdbc</outputDirectory>
|
||||
<overWriteReleases>false</overWriteReleases>
|
||||
<overWriteSnapshots>false</overWriteSnapshots>
|
||||
<overWriteIfNewer>true</overWriteIfNewer>
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package org.apache.zeppelin.postgresql;
|
||||
package org.apache.zeppelin.jdbc;
|
||||
|
||||
import static org.apache.commons.lang.StringUtils.containsIgnoreCase;
|
||||
|
||||
|
|
@ -67,9 +67,9 @@ import com.google.common.collect.Sets.SetView;
|
|||
*
|
||||
* For SQL auto-completion use the (Ctrl+.) shortcut.
|
||||
*/
|
||||
public class PostgreSqlInterpreter extends Interpreter {
|
||||
public class JDBCInterpreter extends Interpreter {
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(PostgreSqlInterpreter.class);
|
||||
private Logger logger = LoggerFactory.getLogger(JDBCInterpreter.class);
|
||||
|
||||
private static final char WhITESPACE = ' ';
|
||||
private static final char NEWLINE = '\n';
|
||||
|
|
@ -84,25 +84,25 @@ public class PostgreSqlInterpreter extends Interpreter {
|
|||
static final String DEFAULT_JDBC_DRIVER_NAME = "org.postgresql.Driver";
|
||||
static final String DEFAULT_MAX_RESULT = "1000";
|
||||
|
||||
static final String POSTGRESQL_SERVER_URL = "postgresql.url";
|
||||
static final String POSTGRESQL_SERVER_USER = "postgresql.user";
|
||||
static final String POSTGRESQL_SERVER_PASSWORD = "postgresql.password";
|
||||
static final String POSTGRESQL_SERVER_DRIVER_NAME = "postgresql.driver.name";
|
||||
static final String POSTGRESQL_SERVER_MAX_RESULT = "postgresql.max.result";
|
||||
static final String JDBC_SERVER_URL = "psql.url";
|
||||
static final String JDBC_SERVER_USER = "psql.user";
|
||||
static final String JDBC_SERVER_PASSWORD = "psql.password";
|
||||
static final String JDBC_SERVER_DRIVER_NAME = "psql.driver.name";
|
||||
static final String JDBC_SERVER_MAX_RESULT = "psql.max.result";
|
||||
static final String EMPTY_COLUMN_VALUE = "";
|
||||
|
||||
static {
|
||||
Interpreter.register(
|
||||
"sql",
|
||||
"psql",
|
||||
PostgreSqlInterpreter.class.getName(),
|
||||
JDBCInterpreter.class.getName(),
|
||||
new InterpreterPropertyBuilder()
|
||||
.add(POSTGRESQL_SERVER_URL, DEFAULT_JDBC_URL, "The URL for PostgreSQL.")
|
||||
.add(POSTGRESQL_SERVER_USER, DEFAULT_JDBC_USER_NAME, "The PostgreSQL user name")
|
||||
.add(POSTGRESQL_SERVER_PASSWORD, DEFAULT_JDBC_USER_PASSWORD,
|
||||
.add(JDBC_SERVER_URL, DEFAULT_JDBC_URL, "The URL for PostgreSQL.")
|
||||
.add(JDBC_SERVER_USER, DEFAULT_JDBC_USER_NAME, "The PostgreSQL user name")
|
||||
.add(JDBC_SERVER_PASSWORD, DEFAULT_JDBC_USER_PASSWORD,
|
||||
"The PostgreSQL user password")
|
||||
.add(POSTGRESQL_SERVER_DRIVER_NAME, DEFAULT_JDBC_DRIVER_NAME, "JDBC Driver Name")
|
||||
.add(POSTGRESQL_SERVER_MAX_RESULT, DEFAULT_MAX_RESULT,
|
||||
.add(JDBC_SERVER_DRIVER_NAME, DEFAULT_JDBC_DRIVER_NAME, "JDBC Driver Name")
|
||||
.add(JDBC_SERVER_MAX_RESULT, DEFAULT_MAX_RESULT,
|
||||
"Max number of SQL result to display.").build());
|
||||
}
|
||||
|
||||
|
|
@ -122,7 +122,7 @@ public class PostgreSqlInterpreter extends Interpreter {
|
|||
|
||||
private static final List<String> NO_COMPLETION = new ArrayList<String>();
|
||||
|
||||
public PostgreSqlInterpreter(Properties property) {
|
||||
public JDBCInterpreter(Properties property) {
|
||||
super(property);
|
||||
}
|
||||
|
||||
|
|
@ -135,12 +135,11 @@ public class PostgreSqlInterpreter extends Interpreter {
|
|||
close();
|
||||
|
||||
try {
|
||||
|
||||
String driverName = getProperty(POSTGRESQL_SERVER_DRIVER_NAME);
|
||||
String url = getProperty(POSTGRESQL_SERVER_URL);
|
||||
String user = getProperty(POSTGRESQL_SERVER_USER);
|
||||
String password = getProperty(POSTGRESQL_SERVER_PASSWORD);
|
||||
maxResult = Integer.valueOf(getProperty(POSTGRESQL_SERVER_MAX_RESULT));
|
||||
String driverName = getProperty(JDBC_SERVER_DRIVER_NAME);
|
||||
String url = getProperty(JDBC_SERVER_URL);
|
||||
String user = getProperty(JDBC_SERVER_USER);
|
||||
String password = getProperty(JDBC_SERVER_PASSWORD);
|
||||
maxResult = Integer.valueOf(getProperty(JDBC_SERVER_MAX_RESULT));
|
||||
|
||||
Class.forName(driverName);
|
||||
|
||||
|
|
@ -316,7 +315,7 @@ public class PostgreSqlInterpreter extends Interpreter {
|
|||
@Override
|
||||
public Scheduler getScheduler() {
|
||||
return SchedulerFactory.singleton().createOrGetFIFOScheduler(
|
||||
PostgreSqlInterpreter.class.getName() + this.hashCode());
|
||||
JDBCInterpreter.class.getName() + this.hashCode());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package org.apache.zeppelin.postgresql;
|
||||
package org.apache.zeppelin.jdbc;
|
||||
|
||||
/*
|
||||
* This source file is based on code taken from SQLLine 1.0.2 See SQLLine notice in LICENSE
|
||||
|
|
@ -12,18 +12,18 @@
|
|||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package org.apache.zeppelin.postgresql;
|
||||
package org.apache.zeppelin.jdbc;
|
||||
|
||||
import static org.apache.zeppelin.postgresql.PostgreSqlInterpreter.DEFAULT_JDBC_DRIVER_NAME;
|
||||
import static org.apache.zeppelin.postgresql.PostgreSqlInterpreter.DEFAULT_JDBC_URL;
|
||||
import static org.apache.zeppelin.postgresql.PostgreSqlInterpreter.DEFAULT_JDBC_USER_NAME;
|
||||
import static org.apache.zeppelin.postgresql.PostgreSqlInterpreter.DEFAULT_JDBC_USER_PASSWORD;
|
||||
import static org.apache.zeppelin.postgresql.PostgreSqlInterpreter.DEFAULT_MAX_RESULT;
|
||||
import static org.apache.zeppelin.postgresql.PostgreSqlInterpreter.POSTGRESQL_SERVER_DRIVER_NAME;
|
||||
import static org.apache.zeppelin.postgresql.PostgreSqlInterpreter.POSTGRESQL_SERVER_MAX_RESULT;
|
||||
import static org.apache.zeppelin.postgresql.PostgreSqlInterpreter.POSTGRESQL_SERVER_PASSWORD;
|
||||
import static org.apache.zeppelin.postgresql.PostgreSqlInterpreter.POSTGRESQL_SERVER_URL;
|
||||
import static org.apache.zeppelin.postgresql.PostgreSqlInterpreter.POSTGRESQL_SERVER_USER;
|
||||
import static org.apache.zeppelin.jdbc.JDBCInterpreter.DEFAULT_JDBC_DRIVER_NAME;
|
||||
import static org.apache.zeppelin.jdbc.JDBCInterpreter.DEFAULT_JDBC_URL;
|
||||
import static org.apache.zeppelin.jdbc.JDBCInterpreter.DEFAULT_JDBC_USER_NAME;
|
||||
import static org.apache.zeppelin.jdbc.JDBCInterpreter.DEFAULT_JDBC_USER_PASSWORD;
|
||||
import static org.apache.zeppelin.jdbc.JDBCInterpreter.DEFAULT_MAX_RESULT;
|
||||
import static org.apache.zeppelin.jdbc.JDBCInterpreter.JDBC_SERVER_DRIVER_NAME;
|
||||
import static org.apache.zeppelin.jdbc.JDBCInterpreter.JDBC_SERVER_MAX_RESULT;
|
||||
import static org.apache.zeppelin.jdbc.JDBCInterpreter.JDBC_SERVER_PASSWORD;
|
||||
import static org.apache.zeppelin.jdbc.JDBCInterpreter.JDBC_SERVER_URL;
|
||||
import static org.apache.zeppelin.jdbc.JDBCInterpreter.JDBC_SERVER_USER;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.mockito.Mockito.spy;
|
||||
|
|
@ -35,6 +35,7 @@ import java.sql.SQLException;
|
|||
import java.util.Properties;
|
||||
|
||||
import org.apache.zeppelin.interpreter.InterpreterResult;
|
||||
import org.apache.zeppelin.jdbc.JDBCInterpreter;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
|
|
@ -46,9 +47,9 @@ import com.mockrunner.mock.jdbc.MockResultSet;
|
|||
/**
|
||||
* PostgreSQL interpreter unit tests
|
||||
*/
|
||||
public class PostgreSqlInterpreterTest extends BasicJDBCTestCaseAdapter {
|
||||
public class JDBCInterpreterTest extends BasicJDBCTestCaseAdapter {
|
||||
|
||||
private PostgreSqlInterpreter psqlInterpreter = null;
|
||||
private JDBCInterpreter jdbcInterpreter = null;
|
||||
private MockResultSet result = null;
|
||||
|
||||
@Before
|
||||
|
|
@ -60,50 +61,50 @@ public class PostgreSqlInterpreterTest extends BasicJDBCTestCaseAdapter {
|
|||
statementHandler.prepareGlobalResultSet(result);
|
||||
|
||||
Properties properties = new Properties();
|
||||
properties.put(POSTGRESQL_SERVER_DRIVER_NAME, DEFAULT_JDBC_DRIVER_NAME);
|
||||
properties.put(POSTGRESQL_SERVER_URL, DEFAULT_JDBC_URL);
|
||||
properties.put(POSTGRESQL_SERVER_USER, DEFAULT_JDBC_USER_NAME);
|
||||
properties.put(POSTGRESQL_SERVER_PASSWORD, DEFAULT_JDBC_USER_PASSWORD);
|
||||
properties.put(POSTGRESQL_SERVER_MAX_RESULT, DEFAULT_MAX_RESULT);
|
||||
properties.put(JDBC_SERVER_DRIVER_NAME, DEFAULT_JDBC_DRIVER_NAME);
|
||||
properties.put(JDBC_SERVER_URL, DEFAULT_JDBC_URL);
|
||||
properties.put(JDBC_SERVER_USER, DEFAULT_JDBC_USER_NAME);
|
||||
properties.put(JDBC_SERVER_PASSWORD, DEFAULT_JDBC_USER_PASSWORD);
|
||||
properties.put(JDBC_SERVER_MAX_RESULT, DEFAULT_MAX_RESULT);
|
||||
|
||||
psqlInterpreter = spy(new PostgreSqlInterpreter(properties));
|
||||
when(psqlInterpreter.getJdbcConnection()).thenReturn(connection);
|
||||
jdbcInterpreter = spy(new JDBCInterpreter(properties));
|
||||
when(jdbcInterpreter.getJdbcConnection()).thenReturn(connection);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOpenCommandIndempotency() throws SQLException {
|
||||
// Ensure that an attempt to open new connection will clean any remaining connections
|
||||
psqlInterpreter.open();
|
||||
psqlInterpreter.open();
|
||||
psqlInterpreter.open();
|
||||
jdbcInterpreter.open();
|
||||
jdbcInterpreter.open();
|
||||
jdbcInterpreter.open();
|
||||
|
||||
verify(psqlInterpreter, times(3)).open();
|
||||
verify(psqlInterpreter, times(3)).close();
|
||||
verify(jdbcInterpreter, times(3)).open();
|
||||
verify(jdbcInterpreter, times(3)).close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultProperties() throws SQLException {
|
||||
|
||||
PostgreSqlInterpreter psqlInterpreter = new PostgreSqlInterpreter(new Properties());
|
||||
JDBCInterpreter jdbcInterpreter = new JDBCInterpreter(new Properties());
|
||||
|
||||
assertEquals(DEFAULT_JDBC_DRIVER_NAME,
|
||||
psqlInterpreter.getProperty(POSTGRESQL_SERVER_DRIVER_NAME));
|
||||
assertEquals(DEFAULT_JDBC_URL, psqlInterpreter.getProperty(POSTGRESQL_SERVER_URL));
|
||||
assertEquals(DEFAULT_JDBC_USER_NAME, psqlInterpreter.getProperty(POSTGRESQL_SERVER_USER));
|
||||
jdbcInterpreter.getProperty(JDBC_SERVER_DRIVER_NAME));
|
||||
assertEquals(DEFAULT_JDBC_URL, jdbcInterpreter.getProperty(JDBC_SERVER_URL));
|
||||
assertEquals(DEFAULT_JDBC_USER_NAME, jdbcInterpreter.getProperty(JDBC_SERVER_USER));
|
||||
assertEquals(DEFAULT_JDBC_USER_PASSWORD,
|
||||
psqlInterpreter.getProperty(POSTGRESQL_SERVER_PASSWORD));
|
||||
assertEquals(DEFAULT_MAX_RESULT, psqlInterpreter.getProperty(POSTGRESQL_SERVER_MAX_RESULT));
|
||||
jdbcInterpreter.getProperty(JDBC_SERVER_PASSWORD));
|
||||
assertEquals(DEFAULT_MAX_RESULT, jdbcInterpreter.getProperty(JDBC_SERVER_MAX_RESULT));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConnectionClose() throws SQLException {
|
||||
|
||||
PostgreSqlInterpreter psqlInterpreter = spy(new PostgreSqlInterpreter(new Properties()));
|
||||
JDBCInterpreter jdbcInterpreter = spy(new JDBCInterpreter(new Properties()));
|
||||
|
||||
when(psqlInterpreter.getJdbcConnection()).thenReturn(
|
||||
when(jdbcInterpreter.getJdbcConnection()).thenReturn(
|
||||
getJDBCMockObjectFactory().getMockConnection());
|
||||
|
||||
psqlInterpreter.close();
|
||||
jdbcInterpreter.close();
|
||||
|
||||
verifyAllResultSetsClosed();
|
||||
verifyAllStatementsClosed();
|
||||
|
|
@ -113,30 +114,30 @@ public class PostgreSqlInterpreterTest extends BasicJDBCTestCaseAdapter {
|
|||
@Test
|
||||
public void testStatementCancel() throws SQLException {
|
||||
|
||||
PostgreSqlInterpreter psqlInterpreter = spy(new PostgreSqlInterpreter(new Properties()));
|
||||
JDBCInterpreter jdbcInterpreter = spy(new JDBCInterpreter(new Properties()));
|
||||
|
||||
when(psqlInterpreter.getJdbcConnection()).thenReturn(
|
||||
when(jdbcInterpreter.getJdbcConnection()).thenReturn(
|
||||
getJDBCMockObjectFactory().getMockConnection());
|
||||
|
||||
psqlInterpreter.cancel(null);
|
||||
jdbcInterpreter.cancel(null);
|
||||
|
||||
verifyAllResultSetsClosed();
|
||||
verifyAllStatementsClosed();
|
||||
assertFalse("Cancel operation should not close the connection", psqlInterpreter
|
||||
assertFalse("Cancel operation should not close the connection", jdbcInterpreter
|
||||
.getJdbcConnection().isClosed());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullColumnResult() throws SQLException {
|
||||
|
||||
when(psqlInterpreter.getMaxResult()).thenReturn(1000);
|
||||
when(jdbcInterpreter.getMaxResult()).thenReturn(1000);
|
||||
|
||||
String sqlQuery = "select * from t";
|
||||
|
||||
result.addColumn("col1", new String[] {"val11", null});
|
||||
result.addColumn("col2", new String[] {null, "val22"});
|
||||
|
||||
InterpreterResult interpreterResult = psqlInterpreter.interpret(sqlQuery, null);
|
||||
InterpreterResult interpreterResult = jdbcInterpreter.interpret(sqlQuery, null);
|
||||
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, interpreterResult.code());
|
||||
assertEquals(InterpreterResult.Type.TABLE, interpreterResult.type());
|
||||
|
|
@ -150,14 +151,14 @@ public class PostgreSqlInterpreterTest extends BasicJDBCTestCaseAdapter {
|
|||
@Test
|
||||
public void testSelectQuery() throws SQLException {
|
||||
|
||||
when(psqlInterpreter.getMaxResult()).thenReturn(1000);
|
||||
when(jdbcInterpreter.getMaxResult()).thenReturn(1000);
|
||||
|
||||
String sqlQuery = "select * from t";
|
||||
|
||||
result.addColumn("col1", new String[] {"val11", "val12"});
|
||||
result.addColumn("col2", new String[] {"val21", "val22"});
|
||||
|
||||
InterpreterResult interpreterResult = psqlInterpreter.interpret(sqlQuery, null);
|
||||
InterpreterResult interpreterResult = jdbcInterpreter.interpret(sqlQuery, null);
|
||||
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, interpreterResult.code());
|
||||
assertEquals(InterpreterResult.Type.TABLE, interpreterResult.type());
|
||||
|
|
@ -171,14 +172,14 @@ public class PostgreSqlInterpreterTest extends BasicJDBCTestCaseAdapter {
|
|||
@Test
|
||||
public void testSelectQueryMaxResult() throws SQLException {
|
||||
|
||||
when(psqlInterpreter.getMaxResult()).thenReturn(1);
|
||||
when(jdbcInterpreter.getMaxResult()).thenReturn(1);
|
||||
|
||||
String sqlQuery = "select * from t";
|
||||
|
||||
result.addColumn("col1", new String[] {"val11", "val12"});
|
||||
result.addColumn("col2", new String[] {"val21", "val22"});
|
||||
|
||||
InterpreterResult interpreterResult = psqlInterpreter.interpret(sqlQuery, null);
|
||||
InterpreterResult interpreterResult = jdbcInterpreter.interpret(sqlQuery, null);
|
||||
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, interpreterResult.code());
|
||||
assertEquals(InterpreterResult.Type.TABLE, interpreterResult.type());
|
||||
|
|
@ -192,14 +193,14 @@ public class PostgreSqlInterpreterTest extends BasicJDBCTestCaseAdapter {
|
|||
@Test
|
||||
public void testSelectQueryWithSpecialCharacters() throws SQLException {
|
||||
|
||||
when(psqlInterpreter.getMaxResult()).thenReturn(1000);
|
||||
when(jdbcInterpreter.getMaxResult()).thenReturn(1000);
|
||||
|
||||
String sqlQuery = "select * from t";
|
||||
|
||||
result.addColumn("co\tl1", new String[] {"val11", "va\tl1\n2"});
|
||||
result.addColumn("co\nl2", new String[] {"v\nal21", "val\t22"});
|
||||
|
||||
InterpreterResult interpreterResult = psqlInterpreter.interpret(sqlQuery, null);
|
||||
InterpreterResult interpreterResult = jdbcInterpreter.interpret(sqlQuery, null);
|
||||
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, interpreterResult.code());
|
||||
assertEquals(InterpreterResult.Type.TABLE, interpreterResult.type());
|
||||
|
|
@ -213,13 +214,13 @@ public class PostgreSqlInterpreterTest extends BasicJDBCTestCaseAdapter {
|
|||
@Test
|
||||
public void testExplainQuery() throws SQLException {
|
||||
|
||||
when(psqlInterpreter.getMaxResult()).thenReturn(1000);
|
||||
when(jdbcInterpreter.getMaxResult()).thenReturn(1000);
|
||||
|
||||
String sqlQuery = "explain select * from t";
|
||||
|
||||
result.addColumn("col1", new String[] {"val11", "val12"});
|
||||
|
||||
InterpreterResult interpreterResult = psqlInterpreter.interpret(sqlQuery, null);
|
||||
InterpreterResult interpreterResult = jdbcInterpreter.interpret(sqlQuery, null);
|
||||
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, interpreterResult.code());
|
||||
assertEquals(InterpreterResult.Type.TEXT, interpreterResult.type());
|
||||
|
|
@ -233,13 +234,13 @@ public class PostgreSqlInterpreterTest extends BasicJDBCTestCaseAdapter {
|
|||
@Test
|
||||
public void testExplainQueryWithSpecialCharachters() throws SQLException {
|
||||
|
||||
when(psqlInterpreter.getMaxResult()).thenReturn(1000);
|
||||
when(jdbcInterpreter.getMaxResult()).thenReturn(1000);
|
||||
|
||||
String sqlQuery = "explain select * from t";
|
||||
|
||||
result.addColumn("co\tl\n1", new String[] {"va\nl11", "va\tl\n12"});
|
||||
|
||||
InterpreterResult interpreterResult = psqlInterpreter.interpret(sqlQuery, null);
|
||||
InterpreterResult interpreterResult = jdbcInterpreter.interpret(sqlQuery, null);
|
||||
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, interpreterResult.code());
|
||||
assertEquals(InterpreterResult.Type.TEXT, interpreterResult.type());
|
||||
|
|
@ -252,9 +253,9 @@ public class PostgreSqlInterpreterTest extends BasicJDBCTestCaseAdapter {
|
|||
|
||||
@Test
|
||||
public void testAutoCompletion() throws SQLException {
|
||||
psqlInterpreter.open();
|
||||
assertEquals(1, psqlInterpreter.completion("SEL", 0).size());
|
||||
assertEquals("SELECT ", psqlInterpreter.completion("SEL", 0).iterator().next());
|
||||
assertEquals(0, psqlInterpreter.completion("SEL", 100).size());
|
||||
jdbcInterpreter.open();
|
||||
assertEquals(1, jdbcInterpreter.completion("SEL", 0).size());
|
||||
assertEquals("SELECT ", jdbcInterpreter.completion("SEL", 0).iterator().next());
|
||||
assertEquals(0, jdbcInterpreter.completion("SEL", 100).size());
|
||||
}
|
||||
}
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package org.apache.zeppelin.postgresql;
|
||||
package org.apache.zeppelin.jdbc;
|
||||
|
||||
import static com.google.common.collect.Sets.newHashSet;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
|
@ -26,6 +26,7 @@ import java.util.Set;
|
|||
|
||||
import jline.console.completer.Completer;
|
||||
|
||||
import org.apache.zeppelin.jdbc.SqlCompleter;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
2
pom.xml
2
pom.xml
|
|
@ -94,7 +94,7 @@
|
|||
<module>hive</module>
|
||||
<module>phoenix</module>
|
||||
<module>geode</module>
|
||||
<module>postgresql</module>
|
||||
<module>jdbc</module>
|
||||
<module>tajo</module>
|
||||
<module>flink</module>
|
||||
<module>ignite</module>
|
||||
|
|
|
|||
|
|
@ -409,7 +409,7 @@ public class ZeppelinConfiguration extends XMLConfiguration {
|
|||
+ "org.apache.zeppelin.lens.LensInterpreter,"
|
||||
+ "org.apache.zeppelin.cassandra.CassandraInterpreter,"
|
||||
+ "org.apache.zeppelin.geode.GeodeOqlInterpreter,"
|
||||
+ "org.apache.zeppelin.postgresql.PostgreSqlInterpreter,"
|
||||
+ "org.apache.zeppelin.jdbc.JDBCInterpreter,"
|
||||
+ "org.apache.zeppelin.kylin.KylinInterpreter"),
|
||||
ZEPPELIN_INTERPRETER_DIR("zeppelin.interpreter.dir", "interpreter"),
|
||||
ZEPPELIN_INTERPRETER_CONNECT_TIMEOUT("zeppelin.interpreter.connect.timeout", 30000),
|
||||
|
|
|
|||
Loading…
Reference in a new issue