Skip to content

Commit 4bd259a

Browse files
committed
[KYUUBI #6036] JDBC driver conditional sets fetchSize on opening session
# 🔍 Description ## Issue References 🔗 I get reported by a user that using Kyuubi JDBC driver 1.8.0 to access Spark Thrift Server 2.4 (with Hive 1.2.1) with getting an error on opening the session even with `clientProtocol=7` ``` org.apache.hive.service.cli.HiveSQLException: java.lang.IllegalArgumentException: hive configuration hive.server2.thrift.resultset.default.fetch.size does not exists. at org.apache.hive.service.cli.session.HiveSessionImpl.configureSession(HiveSessionImpl.java:220) at org.apache.hive.service.cli.session.HiveSessionImpl.open(HiveSessionImpl.java:154) at org.apache.hive.service.cli.session.SessionManager.openSession(SessionManager.java:258) ... 13 more ``` ## Describe Your Solution 🔧 When `hive.conf.validation` is `true` (it also is the default value), an IllegalArgumentException will be thrown if the provided configurations start with `hive.` and can not be recognized by the server. One solution is to disable `hive.conf.validation` on the server side, but we can also address it by avoiding passing this configuration if we know that the server does not support it. HIVE-14901 (2.3.0, HIVE_CLI_SERVICE_PROTOCOL_V10) introduces `hive.server2.thrift.resultset.default.fetch.size`, so we can set this configuration only when protocol >= HIVE_CLI_SERVICE_PROTOCOL_V10 ## Types of changes 🔖 - [ ] Bugfix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) ## Test Plan 🧪 Verified locally by connecting to HS2 2.1.1 and HS2 2.3.9 #### Behavior Without This Pull Request ⚰️ IllegalArgumentException throws when using `jdbc:hive2://localhost:10000/default;clientProtocol=8` to connect HS2 2.1.1 Everything is OK when using `jdbc:hive2://localhost:10000/default` to connect HS2 2.3.9 #### Behavior With This Pull Request 🎉 Everything is OK when using `jdbc:hive2://localhost:10000/default;clientProtocol=8` to connect HS2 2.1.1 Everything is OK when using `jdbc:hive2://localhost:10000/default` to connect HS2 2.3.9 --- # Checklist 📝 - [x] This patch was not authored or co-authored using [Generative Tooling](https://www.apache.org/legal/generative-tooling.html) **Be nice. Be informative.** Closes #6036 from pan3793/jdbc-fetchsize. Closes #6036 7ea91f1 [Cheng Pan] nit e6ea829 [Cheng Pan] fix 1dbecbb [Cheng Pan] JDBC driver conditional sets fetchSize on opening session Authored-by: Cheng Pan <chengpan@apache.org> Signed-off-by: Cheng Pan <chengpan@apache.org>
1 parent 208354c commit 4bd259a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/KyuubiConnection.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -723,10 +723,6 @@ private void openSession() throws SQLException {
723723
}
724724
// switch the database
725725
openConf.put("use:database", connParams.getDbName());
726-
// set the fetchSize
727-
openConf.put(
728-
"set:hiveconf:hive.server2.thrift.resultset.default.fetch.size",
729-
Integer.toString(fetchSize));
730726
if (wmPool != null) {
731727
openConf.put("set:hivevar:wmpool", wmPool);
732728
}
@@ -751,6 +747,12 @@ private void openSession() throws SQLException {
751747
clientProtocolStr, CLIENT_PROTOCOL_VERSION));
752748
}
753749
openReq.setClient_protocol(clientProtocol);
750+
// HIVE-14901: set the fetchSize
751+
if (clientProtocol.compareTo(TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V10) >= 0) {
752+
openConf.put(
753+
"set:hiveconf:hive.server2.thrift.resultset.default.fetch.size",
754+
Integer.toString(fetchSize));
755+
}
754756
try {
755757
openConf.put("kyuubi.client.ipAddress", InetAddress.getLocalHost().getHostAddress());
756758
} catch (UnknownHostException e) {

0 commit comments

Comments
 (0)