Repository: incubator-zeppelin Updated Branches: refs/heads/master de5f55a3c -> 901102a72
[ZEPPELIN-915] New registration mechanism applied to JDBCInterpreter ### What is this PR for? This PR applies the new interpreter registration mechanism to the JDBCInterpreter. ### What type of PR is it? Improvement ### Todos * [x ] - Move interpreter registration properties from static block to interpreter-setting.json ### What is the Jira issue? https://issues.apache.org/jira/browse/ZEPPELIN-915 ### How should this be tested? 1. apply patch 2. rm -r interpreter/jdbc 3. rm conf/interpreter.json 4. mvn clean package -DskipTests -pl jdbc 5. bin/zeppelin-daemon.sh start 6. run some paragraph with simple sql queries ### Screenshots (if appropriate) ### Questions: * Does the licenses files need update? No * Is there breaking changes for older versions? No * Does this needs documentation? No Author: Ralph Geerkens <[email protected]> Closes #954 from ralphge/pr915 and squashes the following commits: 63617ef [Ralph Geerkens] [ZEPPELIN-915] New registration mechanism applied to JDBCInterpreter Project: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/commit/901102a7 Tree: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/tree/901102a7 Diff: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/diff/901102a7 Branch: refs/heads/master Commit: 901102a728147a89e9d133667b0136e740a8fe1c Parents: de5f55a Author: Ralph Geerkens <[email protected]> Authored: Thu Jun 2 23:10:54 2016 +0200 Committer: Jongyoul Lee <[email protected]> Committed: Tue Jun 7 23:02:48 2016 +0900 ---------------------------------------------------------------------- .../apache/zeppelin/jdbc/JDBCInterpreter.java | 15 -------- .../src/main/resources/interpreter-setting.json | 39 ++++++++++++++++++++ .../zeppelin/jdbc/JDBCInterpreterTest.java | 13 ++++++- 3 files changed, 51 insertions(+), 16 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/901102a7/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java ---------------------------------------------------------------------- diff --git a/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java b/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java index da1a69d..6495264 100644 --- a/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java +++ b/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java @@ -106,21 +106,6 @@ public class JDBCInterpreter extends Interpreter { private final Map<String, ArrayList<Connection>> propertyKeyUnusedConnectionListMap; private final Map<String, Connection> paragraphIdConnectionMap; - - static { - Interpreter.register( - "sql", - "jdbc", - JDBCInterpreter.class.getName(), - new InterpreterPropertyBuilder() - .add(DEFAULT_URL, "jdbc:postgresql://localhost:5432/", "The URL for JDBC.") - .add(DEFAULT_USER, "gpadmin", "The JDBC user name") - .add(DEFAULT_PASSWORD, "", - "The JDBC user password") - .add(DEFAULT_DRIVER, "org.postgresql.Driver", "JDBC Driver Name") - .add(COMMON_MAX_LINE, MAX_LINE_DEFAULT, - "Max number of SQL result to display.").build()); - } public JDBCInterpreter(Properties property) { super(property); http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/901102a7/jdbc/src/main/resources/interpreter-setting.json ---------------------------------------------------------------------- diff --git a/jdbc/src/main/resources/interpreter-setting.json b/jdbc/src/main/resources/interpreter-setting.json new file mode 100644 index 0000000..97b2c61 --- /dev/null +++ b/jdbc/src/main/resources/interpreter-setting.json @@ -0,0 +1,39 @@ +[ + { + "group": "jdbc", + "name": "sql", + "className": "org.apache.zeppelin.jdbc.JDBCInterpreter", + "properties": { + "default.url": { + "envName": null, + "propertyName": "default.url", + "defaultValue": "jdbc:postgresql://localhost:5432/", + "description": "The URL for JDBC." + }, + "default.user": { + "envName": null, + "propertyName": "default.user", + "defaultValue": "gpadmin", + "description": "The JDBC user name" + }, + "default.password": { + "envName": null, + "propertyName": "default.password", + "defaultValue": "", + "description": "The JDBC user password" + }, + "default.driver": { + "envName": null, + "propertyName": "default.driver", + "defaultValue": "org.postgresql.Driver", + "description": "JDBC Driver Name" + }, + "common.max_count": { + "envName": null, + "propertyName": "common.max_count", + "defaultValue": "1000", + "description": "Max number of SQL result to display." + } + } + } +] http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/901102a7/jdbc/src/test/java/org/apache/zeppelin/jdbc/JDBCInterpreterTest.java ---------------------------------------------------------------------- diff --git a/jdbc/src/test/java/org/apache/zeppelin/jdbc/JDBCInterpreterTest.java b/jdbc/src/test/java/org/apache/zeppelin/jdbc/JDBCInterpreterTest.java index 593d968..065f4ed 100644 --- a/jdbc/src/test/java/org/apache/zeppelin/jdbc/JDBCInterpreterTest.java +++ b/jdbc/src/test/java/org/apache/zeppelin/jdbc/JDBCInterpreterTest.java @@ -51,6 +51,17 @@ public class JDBCInterpreterTest extends BasicJDBCTestCaseAdapter { } return jdbcConnection; } + + public static Properties getJDBCTestProperties() { + Properties p = new Properties(); + p.setProperty("default.driver", "org.postgresql.Driver"); + p.setProperty("default.url", "jdbc:postgresql://localhost:5432/"); + p.setProperty("default.user", "gpadmin"); + p.setProperty("default.password", ""); + p.setProperty("common.max_count", "1000"); + + return p; + } @Before public void setUp() throws Exception { @@ -116,7 +127,7 @@ public class JDBCInterpreterTest extends BasicJDBCTestCaseAdapter { @Test public void testDefaultProperties() throws SQLException { - JDBCInterpreter jdbcInterpreter = new JDBCInterpreter(new Properties()); + JDBCInterpreter jdbcInterpreter = new JDBCInterpreter(getJDBCTestProperties()); assertEquals("org.postgresql.Driver", jdbcInterpreter.getProperty(DEFAULT_DRIVER)); assertEquals("jdbc:postgresql://localhost:5432/", jdbcInterpreter.getProperty(DEFAULT_URL));
