Skip to content
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

KNOX-1742 - Simple SQL Client in KnoxShell for access to JDBC sources #241

Merged
merged 4 commits into from
Jan 21, 2020

Conversation

lmccay
Copy link
Contributor

@lmccay lmccay commented Jan 20, 2020

(It is very important that you created an Apache Knox JIRA for this change and that the PR title/commit message includes the Apache Knox JIRA ID!)

What changes were proposed in this pull request?

Adding a simple SQL client/shell to KnoxShell for accessing JDBC data sources such as HiveServer2 and others. Rather than providing connection details on the command line for the data source, this shell leverages the DataSource persistence introduced in KNOX-2128.

Enter the SQL client, list datasources, select datasources and execute SQL query:

lmccay@strange:~/Projects/releases/knoxshell-1.4.0-SNAPSHOT$ bin/knoxshell.sh knoxline


| | ___ __ _____ | ()_ __ ___
| |/ / '_ \ / _ \ / / | | '_ \ / _
| <| | | | () > <| | | | | | __/
|
|__| ||___//__||| |_|\__|
powered by Apache Knox

knoxline> :ds
Name : secgov : jdbc:hive2://sme-secgov-de-01.sme-secg.a465-9q4k.cloudera.site:8443/;ssl=true;transportMode=http;httpPath=sme-secgov-de-01/cdp-proxy-api/hive
Name : anatva : jdbc:hive2://de-anatva-master0.sandbox.a465-9q4k.cloudera.site/;ssl=true;transportMode=http;httpPath=de-anatva/cdp-proxy-api/hive
Name : derby1 : jdbc:derby:codejava/webdb1
knoxline> :ds select derby1
knoxline> select * from book
select * from book
BOOK
+------------+--------------------+
| BOOK_ID | TITLE |
+------------+--------------------+
| 1 | Effective Java |
| 2 | Core Java |
| 3 | Core Apache Knox |
+------------+--------------------+

Rows: 3

knoxline> ^CClosing any open connections ...

How was this patch tested?

Manual testing of this feature and unit testing run to ensure no regressions.

Please review Knox Contributing Process before opening a pull request.

@lmccay lmccay requested a review from risdenk January 20, 2020 16:45
@lmccay lmccay requested a review from risdenk January 21, 2020 16:12
@@ -593,7 +593,26 @@ public String toString() {
String s = JsonUtils.renderAsJsonString(map);
String home = System.getProperty("user.home");
try {
write(new File(home + File.separator + ".knoxshell" + File.separator + fileName), s);
write(new File(
home + File.separator + ".knoxshell" + File.separator + fileName), s);
Copy link
Contributor

@risdenk risdenk Jan 21, 2020

Choose a reason for hiding this comment

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

Just a note for future reference:

This could be Paths.get(home, ".knoxshell", fileName).toFile() or just use the Path directly instead of manually constructing a File object.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice. Thanks.

@lmccay lmccay merged commit 36ee8ab into apache:master Jan 21, 2020
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.

3 participants