-
Notifications
You must be signed in to change notification settings - Fork 249
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
Conversation
gateway-shell/src/main/java/org/apache/knox/gateway/shell/jdbc/KnoxLine.java
Outdated
Show resolved
Hide resolved
gateway-shell/src/main/java/org/apache/knox/gateway/shell/KnoxSession.java
Outdated
Show resolved
Hide resolved
gateway-shell/src/main/java/org/apache/knox/gateway/shell/jdbc/KnoxLine.java
Show resolved
Hide resolved
@@ -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); |
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.
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.
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.
Nice. Thanks.
(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.