This is an automated email from the ASF dual-hosted git repository. stoty pushed a commit to branch 5.1 in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/5.1 by this push: new 1d709fd2f7 PHOENIX-7097 Allow specifying full JDBC URL string in psql/PhoenixRuntime and sqllline.py 1d709fd2f7 is described below commit 1d709fd2f7b545a75690ec56387571ac5424acca 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 bc1cab1cfc..e454ab7fbd 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 ' + \ '" -Dlog4j.configuration=file:' + os.path.join(phoenix_utils.current_dir, "log4j.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 fb25078200..d824cc0031 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 @@ -306,7 +306,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;