-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[ZEPPELIN-2245] separate precode into JDBCInterpreter #2121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -118,6 +118,11 @@ The JDBC interpreter properties are defined by default like below. | |
| <td>gpadmin</td> | ||
| <td>The JDBC user name</td> | ||
| </tr> | ||
| <tr> | ||
| <td>default.precode</td> | ||
| <td></td> | ||
| <td>Some SQL which executes while opening connection</td> | ||
| </tr> | ||
| </table> | ||
|
|
||
| If you want to connect other databases such as `Mysql`, `Redshift` and `Hive`, you need to edit the property values. | ||
|
|
@@ -167,10 +172,6 @@ There are more JDBC interpreter properties you can specify like below. | |
| <td>default.jceks.credentialKey</td> | ||
| <td>jceks credential key</td> | ||
| </tr> | ||
| <tr> | ||
| <td>zeppelin.jdbc.precode</td> | ||
| <td>Some SQL which executes while opening connection</td> | ||
| </tr> | ||
| </table> | ||
|
|
||
| You can also add more properties by using this [method](http://docs.oracle.com/javase/7/docs/api/java/sql/DriverManager.html#getConnection%28java.lang.String,%20java.util.Properties%29). | ||
|
|
@@ -221,6 +222,75 @@ SELECT name, country, performer | |
| FROM demo.performers | ||
| WHERE name='{{"{{performer=Sheryl Crow|Doof|Fanfarlo|Los Paranoia"}}}}' | ||
| ``` | ||
| ### Usage *precode* | ||
| You can set *precode* for each data source. Code runs once while opening the connection. | ||
|
|
||
| ##### Properties | ||
| An example settings of interpreter for the two data sources, each of which has its *precode* parameter. | ||
|
|
||
| <table class="table-configuration"> | ||
| <tr> | ||
| <th>Property Name</th> | ||
| <th>Value</th> | ||
| </tr> | ||
| <tr> | ||
| <td>default.driver</td> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm, should it have/use
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe just omit them in this example?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, here is set two data sources, each one with a precode |
||
| <td>org.postgresql.Driver</td> | ||
| </tr> | ||
| <tr> | ||
| <td>default.password</td> | ||
| <td>1</td> | ||
| </tr> | ||
| <tr> | ||
| <td>default.url</td> | ||
| <td>jdbc:postgresql://localhost:5432/</td> | ||
| </tr> | ||
| <tr> | ||
| <td>default.user</td> | ||
| <td>postgres</td> | ||
| </tr> | ||
| <tr> | ||
| <td>default.precode</td> | ||
| <td>set search_path='test_path'</td> | ||
| </tr> | ||
| <tr> | ||
| <td>mysql.driver</td> | ||
| <td>com.mysql.jdbc.Driver</td> | ||
| </tr> | ||
| <tr> | ||
| <td>mysql.password</td> | ||
| <td>1</td> | ||
| </tr> | ||
| <tr> | ||
| <td>mysql.url</td> | ||
| <td>jdbc:mysql://localhost:3306/</td> | ||
| </tr> | ||
| <tr> | ||
| <td>mysql.user</td> | ||
| <td>root</td> | ||
| </tr> | ||
| <tr> | ||
| <td>mysql.precode</td> | ||
| <td>set @v=12</td> | ||
| </tr> | ||
| </table> | ||
|
|
||
| ##### Usage | ||
| Test of execution *precode* for each data source. | ||
|
|
||
| ```sql | ||
| %jdbc | ||
| show search_path | ||
| ``` | ||
| Returns value of `search_path` which is set in the *default.precode*. | ||
|
|
||
|
|
||
| ```sql | ||
| %jdbc(mysql) | ||
| select @v | ||
| ``` | ||
| Returns value of `v` which is set in the *mysql.precode*. | ||
|
|
||
|
|
||
| ## Examples | ||
| Here are some examples you can refer to. Including the below connectors, you can connect every databases as long as it can be configured with it's JDBC driver. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you add an example of using this?
perhaps in
## Binding JDBC interpter to notebook? Or another place you findThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added example