Repository: zeppelin Updated Branches: refs/heads/branch-0.7 ab806e0ce -> e5ab00043
User Impersonation fails on setting hive_conf_list in hive interpreter (JDBC) ### What is this PR for? This is how a sample `jdbc:hive2://<host1>:<port1>,<host2>:<port2>/dbName;initFile=<file>;sess_var_list?hive_conf_list#hive_var_list` looks like. And when "hive_conf_list" is set then, User Impersonation which is passed via "sess_var_list" fails. Ref: https://cwiki.apache.org/confluence/display/Hive/HiveServer2+Clients#HiveServer2Clients-ConnectionURLFormat ### What type of PR is it? [Bug Fix] ### What is the Jira issue? * [ZEPPELIN-2023](https://issues.apache.org/jira/browse/ZEPPELIN-2023) ### How should this be tested? Try setting tez.queue.name=someQueueName so the JDBC url, like following ``` jdbc:hive2://sameple-custer-3.novalocal:2181,sameple-custer-2.novalocal:2181,sameple-custer-4.novalocal:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2?tez.queue.name=someQueueName ```` and now execute some query like ``` select count(*) from table_name ``` and check resource manager UI, this should show up on the designated queue with the webUi logged-in user. ### Screenshots (if appropriate) ### Questions: * Does the licenses files need update? N/A * Is there breaking changes for older versions? N/A * Does this needs documentation? N/A Author: Prabhjyot Singh <[email protected]> Closes #1953 from prabhjyotsingh/ZEPPELIN-2023 and squashes the following commits: e646e2b [Prabhjyot Singh] add proxy.user=user before "?" (cherry picked from commit f689e26e51dabe4dc0aae0fdabdfd4255cbb8811) Signed-off-by: Prabhjyot Singh <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/e5ab0004 Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/e5ab0004 Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/e5ab0004 Branch: refs/heads/branch-0.7 Commit: e5ab0004370d8d309bbbaceede0f0392543160b1 Parents: ab806e0 Author: Prabhjyot Singh <[email protected]> Authored: Fri Jan 27 14:17:21 2017 +0530 Committer: Prabhjyot Singh <[email protected]> Committed: Wed Feb 1 08:29:41 2017 +0530 ---------------------------------------------------------------------- .../java/org/apache/zeppelin/jdbc/JDBCInterpreter.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/zeppelin/blob/e5ab0004/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java ---------------------------------------------------------------------- diff --git a/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java b/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java index 8d6577e..bc33696 100644 --- a/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java +++ b/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java @@ -376,8 +376,14 @@ public class JDBCInterpreter extends Interpreter { connection = getConnectionFromPool(url, user, propertyKey, properties); } else { if ("hive".equalsIgnoreCase(propertyKey)) { - connection = getConnectionFromPool(url + ";hive.server2.proxy.user=" + user, - user, propertyKey, properties); + StringBuilder connectionUrl = new StringBuilder(url); + Integer lastIndexOfUrl = connectionUrl.indexOf("?"); + if (lastIndexOfUrl == -1) { + lastIndexOfUrl = connectionUrl.length(); + } + connectionUrl.insert(lastIndexOfUrl, ";hive.server2.proxy.user=" + user + ";"); + connection = getConnectionFromPool(connectionUrl.toString(), + user, propertyKey, properties); } else { UserGroupInformation ugi = null; try {
