[ZEPPELIN-1988] add property "precode" to JDBCInterpreter#2078
[ZEPPELIN-1988] add property "precode" to JDBCInterpreter#2078tinkoff-dwh wants to merge 6 commits into
Conversation
|
CI failed, errors in unrelated tests |
|
LGTM |
|
Looks Good To Me |
| <td>jceks credential key</td> | ||
| </tr> | ||
| <tr> | ||
| <td>zeppelin.interpreter.precode</td> |
There was a problem hiding this comment.
this is specifically for the jdbc interpreter? if so, suggest name zeppelin.jdbc.precode or zeppelin.jdbc.sql.precode
There was a problem hiding this comment.
in planning for the future add this property to another interpreters (PySpark, SparkR)
There was a problem hiding this comment.
I agree @felixcheung's opinion. If you want to extend this feature for the future, you can modify it when you do it.
| statement.close(); | ||
| } | ||
| } catch (SQLException e) { | ||
| logger.error("Cannot create precode statement", e); |
There was a problem hiding this comment.
this is going to log but ignore the error - is this what we want here?
There was a problem hiding this comment.
Yes, I want the main code will run anyway. Although it may be worth it to generate an error
There was a problem hiding this comment.
agree, for the user it is more logical to see the error, fix it
|
|
||
| public static final String ZEPPELIN_INTERPRETER_HOST = "zeppelin.interpreter.host"; | ||
|
|
||
| public static final String ZEPPELIN_PRECODE_PROPERTY_KEY = "zeppelin.interpreter.precode"; |
There was a problem hiding this comment.
I'm not sure this should go here if this is only for one interpreter?
There was a problem hiding this comment.
in planning for the future add this property to another interpreters (PySpark, SparkR)
| String precode = getProperty(ZEPPELIN_PRECODE_PROPERTY_KEY); | ||
| if (StringUtils.isNotEmpty(precode)) { | ||
| logger.info("Run SQL precode '{}'", precode); | ||
| try { |
There was a problem hiding this comment.
Connection and Statement are AutoCloseable. Isn't it better to use try-with-resources?
| import org.apache.hadoop.security.alias.CredentialProvider; | ||
| import org.apache.hadoop.security.alias.CredentialProviderFactory; | ||
| import org.apache.thrift.transport.TTransportException; | ||
| import org.apache.zeppelin.interpreter.*; |
|
@jongyoul @DrIgor @felixcheung Thx for review. |
|
|
||
| private void executePrecode(Connection connection) throws SQLException { | ||
| String precode = getProperty(ZEPPELIN_JDBC_PRECODE_KEY); | ||
| if (StringUtils.isNotEmpty(precode)) { |
There was a problem hiding this comment.
if (StringUtils.isNotBlank(precode)) { precode = StringUtils.trim(precode); ....
|
+1 |
|
do you know why isn't the test status reflected here? |
|
I thought you might want to trim the input precode string too, as pointed out #2078 (comment). since it's a nit, LGTM, |
|
@Leemoonsoo let me know if you want to hold this when we are discussing in #2096. |
|
@felixcheung I think we can merge this one first. A way we're discuss in #2096 may replace the this PR we don't have the implementation yet. |
|
merged to master. |
|
@tinkoff-dwh what's your User ID in Apache JIRA? We could assign this issue to you |
|
@felixcheung tinkoff-dwh |
### What is this PR for? Adds property "precode". Value of property contains SQL which executes while opening connection. ### What type of PR is it? Improvement ### What is the Jira issue? https://issues.apache.org/jira/browse/ZEPPELIN-1988 ### How should this be tested? 1) Set property zeppelin.interpreter.precode =` set search_path='test, public' ` 2) Execute `%jdbc show search_path` ### Questions: * Does the licenses files need update? no * Is there breaking changes for older versions? no * Does this needs documentation? no Author: Tinkoff DWH <tinkoff.dwh@gmail.com> Closes apache#2078 from tinkoff-dwh/ZEPPELIN-1988 and squashes the following commits: cd46cce [Tinkoff DWH] [ZEPPELIN-1988] trim precode 42ffcb7 [Tinkoff DWH] [ZEPPELIN-1988] fix condition 7636b3f [Tinkoff DWH] Merge remote-tracking branch 'origin/master' into ZEPPELIN-1988 66d6ae4 [Tinkoff DWH] [ZEPPELIN-1988] fixes of review items 9d37bc4 [Tinkoff DWH] [ZEPPELIN-1988] fix ba3477a [Tinkoff DWH] [ZEPPELIN-1988] add property "precode" to JDBCInterpreter
### What is this PR for? Adds property "precode". Value of property contains SQL which executes while opening connection. ### What type of PR is it? Improvement ### What is the Jira issue? https://issues.apache.org/jira/browse/ZEPPELIN-1988 ### How should this be tested? 1) Set property zeppelin.interpreter.precode =` set search_path='test, public' ` 2) Execute `%jdbc show search_path` ### Questions: * Does the licenses files need update? no * Is there breaking changes for older versions? no * Does this needs documentation? no Author: Tinkoff DWH <tinkoff.dwh@gmail.com> Closes apache#2078 from tinkoff-dwh/ZEPPELIN-1988 and squashes the following commits: cd46cce [Tinkoff DWH] [ZEPPELIN-1988] trim precode 42ffcb7 [Tinkoff DWH] [ZEPPELIN-1988] fix condition 7636b3f [Tinkoff DWH] Merge remote-tracking branch 'origin/master' into ZEPPELIN-1988 66d6ae4 [Tinkoff DWH] [ZEPPELIN-1988] fixes of review items 9d37bc4 [Tinkoff DWH] [ZEPPELIN-1988] fix ba3477a [Tinkoff DWH] [ZEPPELIN-1988] add property "precode" to JDBCInterpreter
What is this PR for?
Adds property "precode". Value of property contains SQL which executes while opening connection.
What type of PR is it?
Improvement
What is the Jira issue?
https://issues.apache.org/jira/browse/ZEPPELIN-1988
How should this be tested?
set search_path='test, public'%jdbc show search_pathQuestions: