Skip to content

[ZEPPELIN-1988] add property "precode" to JDBCInterpreter#2078

Closed
tinkoff-dwh wants to merge 6 commits into
apache:masterfrom
tinkoff-dwh:ZEPPELIN-1988
Closed

[ZEPPELIN-1988] add property "precode" to JDBCInterpreter#2078
tinkoff-dwh wants to merge 6 commits into
apache:masterfrom
tinkoff-dwh:ZEPPELIN-1988

Conversation

@tinkoff-dwh
Copy link
Copy Markdown
Contributor

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

@tinkoff-dwh
Copy link
Copy Markdown
Contributor Author

CI failed, errors in unrelated tests
https://travis-ci.org/tinkoff-dwh/zeppelin/builds/205735485

@andrykrp
Copy link
Copy Markdown

LGTM

@sotnich
Copy link
Copy Markdown

sotnich commented Feb 28, 2017

Looks Good To Me

Comment thread docs/interpreter/jdbc.md Outdated
<td>jceks credential key</td>
</tr>
<tr>
<td>zeppelin.interpreter.precode</td>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is specifically for the jdbc interpreter? if so, suggest name zeppelin.jdbc.precode or zeppelin.jdbc.sql.precode

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in planning for the future add this property to another interpreters (PySpark, SparkR)

Copy link
Copy Markdown
Member

@jongyoul jongyoul Feb 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree @felixcheung's opinion. If you want to extend this feature for the future, you can modify it when you do it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix it

statement.close();
}
} catch (SQLException e) {
logger.error("Cannot create precode statement", e);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is going to log but ignore the error - is this what we want here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I want the main code will run anyway. Although it may be worth it to generate an error

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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";
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this should go here if this is only for one interpreter?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in planning for the future add this property to another interpreters (PySpark, SparkR)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix it

String precode = getProperty(ZEPPELIN_PRECODE_PROPERTY_KEY);
if (StringUtils.isNotEmpty(precode)) {
logger.info("Run SQL precode '{}'", precode);
try {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Connection and Statement are AutoCloseable. Isn't it better to use try-with-resources?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix it

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.*;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this kind of change.

@tinkoff-dwh
Copy link
Copy Markdown
Contributor Author


private void executePrecode(Connection connection) throws SQLException {
String precode = getProperty(ZEPPELIN_JDBC_PRECODE_KEY);
if (StringUtils.isNotEmpty(precode)) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (StringUtils.isNotBlank(precode)) { precode = StringUtils.trim(precode); ....

@tinkoff-dwh
Copy link
Copy Markdown
Contributor Author

@masyan
Copy link
Copy Markdown
Contributor

masyan commented Mar 3, 2017

+1

@felixcheung
Copy link
Copy Markdown
Member

do you know why isn't the test status reflected here?

@felixcheung
Copy link
Copy Markdown
Member

I thought you might want to trim the input precode string too, as pointed out #2078 (comment).

since it's a nit, LGTM,
merging if no more comment

@felixcheung
Copy link
Copy Markdown
Member

@Leemoonsoo let me know if you want to hold this when we are discussing in #2096.

@Leemoonsoo
Copy link
Copy Markdown
Member

@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.

@felixcheung
Copy link
Copy Markdown
Member

merged to master.

@asfgit asfgit closed this in ebd5e1e Mar 7, 2017
@felixcheung
Copy link
Copy Markdown
Member

@tinkoff-dwh what's your User ID in Apache JIRA? We could assign this issue to you

@tinkoff-dwh
Copy link
Copy Markdown
Contributor Author

tinkoff-dwh commented Mar 7, 2017

@felixcheung tinkoff-dwh

@tinkoff-dwh tinkoff-dwh deleted the ZEPPELIN-1988 branch March 7, 2017 07:45
prabhjyotsingh pushed a commit to prabhjyotsingh/zeppelin that referenced this pull request Sep 1, 2017
### 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
prabhjyotsingh pushed a commit to prabhjyotsingh/zeppelin that referenced this pull request Oct 23, 2017
### 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants