You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by st...@apache.org on 2023/11/07 09:51:01 UTC
(phoenix) branch master updated: PHOENIX-7097 Allow specifying full JDBC URL string in psql/PhoenixRuntime and sqllline.py
This is an automated email from the ASF dual-hosted git repository.
stoty pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/master by this push:
new 17fac6a4d1 PHOENIX-7097 Allow specifying full JDBC URL string in psql/PhoenixRuntime and sqllline.py
17fac6a4d1 is described below
commit 17fac6a4d1850150580dec9d54c9f6d59701056b
Author: Istvan Toth <st...@apache.org>
AuthorDate: Sat Nov 4 06:48:50 2023 +0100
PHOENIX-7097 Allow specifying full JDBC URL string in psql/PhoenixRuntime and sqllline.py
---
bin/sqlline.py | 9 +++++++--
.../src/main/java/org/apache/phoenix/util/PhoenixRuntime.java | 7 ++++++-
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/bin/sqlline.py b/bin/sqlline.py
index 62f0814c9f..72b06bdab7 100755
--- a/bin/sqlline.py
+++ b/bin/sqlline.py
@@ -50,7 +50,7 @@ phoenix_utils.setPath()
parser = argparse.ArgumentParser(description='Launches the Apache Phoenix Client.')
# Positional argument 'zookeepers' is optional. The PhoenixDriver will automatically populate
# this if it's not provided by the user (so, we want to leave a default value of empty)
-parser.add_argument('zookeepers', nargs='?', help='The ZooKeeper quorum string', default='')
+parser.add_argument('zookeepers', nargs='?', help='The ZooKeeper quorum string or full JDBC URL', default='')
# Positional argument 'sqlfile' is optional
parser.add_argument('sqlfile', nargs='?', help='A file of SQL commands to execute', default='')
parser.add_argument('--noconnect', help='Start without making a connection',
@@ -64,6 +64,11 @@ phoenix_utils.common_sqlline_args(parser)
args=parser.parse_args()
zookeeper = tryDecode(args.zookeepers)
+if zookeeper.startswith('jdbc:phoenix'):
+ jdbc_url = zookeeper
+else:
+ # We do want to use the default "jdbc:phoenix:" URL if no URL was specified
+ jdbc_url = 'jdbc:phoenix:' + zookeeper
sqlfile = tryDecode(args.sqlfile)
# HBase configuration folder path (where hbase-site.xml reside) for
@@ -128,7 +133,7 @@ java_cmd = java + ' $PHOENIX_OPTS ' + \
'" -Dlog4j2.configurationFile=file:' + os.path.join(phoenix_utils.current_dir, "log4j2.properties") + \
disable_jna + \
" sqlline.SqlLine -d org.apache.phoenix.jdbc.PhoenixDriver" + \
- (not args.noconnect and " -u jdbc:phoenix:" + phoenix_utils.shell_quote([zookeeper]) or "") + \
+ (not args.noconnect and " -u " + phoenix_utils.shell_quote([jdbc_url]) or "") + \
" -n none -p none --color=" + \
(args.color and "true" or "false") + \
" --fastConnect=" + (args.fastconnect and "true" or "false") + \
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/PhoenixRuntime.java b/phoenix-core/src/main/java/org/apache/phoenix/util/PhoenixRuntime.java
index 04be259c4c..d4448a786c 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/PhoenixRuntime.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/PhoenixRuntime.java
@@ -312,7 +312,12 @@ public class PhoenixRuntime {
public static void main(String [] args) {
ExecutionCommand execCmd = ExecutionCommand.parseArgs(args);
- String jdbcUrl = JDBC_PROTOCOL + JDBC_PROTOCOL_SEPARATOR + execCmd.getConnectionString();
+ String jdbcUrl;
+ if (execCmd.getConnectionString().startsWith(JDBC_PROTOCOL)) {
+ jdbcUrl = execCmd.getConnectionString();
+ } else {
+ jdbcUrl = JDBC_PROTOCOL + JDBC_PROTOCOL_SEPARATOR + execCmd.getConnectionString();
+ }
int exitStatus = 0;