This is an automated email from the ASF dual-hosted git repository.

SbloodyS pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git


The following commit(s) were added to refs/heads/dev by this push:
     new 21968bcad8 [Feature-18725][Datasource] Support custom Kyuubi JDBC URLs 
(#18727)
21968bcad8 is described below

commit 21968bcad8a2524bfa0304d7473503a0feee010f
Author: silvermissile <[email protected]>
AuthorDate: Sat Oct 24 14:03:45 2026 +0800

    [Feature-18725][Datasource] Support custom Kyuubi JDBC URLs (#18727)
---
 docs/docs/en/guide/datasource/kyuubi.md            |  16 ++
 docs/docs/zh/guide/datasource/kyuubi.md            |  16 ++
 .../dolphinscheduler-datasource-kyuubi/pom.xml     |   6 +
 .../kyuubi/param/KyuubiConnectionParam.java        |   7 +
 .../kyuubi/param/KyuubiDataSourceParamDTO.java     |   7 +
 .../kyuubi/param/KyuubiDataSourceProcessor.java    |  63 ++++++-
 .../kyuubi/KyuubiPooledDataSourceClientTest.java   |  50 +++++
 .../param/KyuubiDataSourceProcessorTest.java       | 201 +++++++++++++++++++++
 .../src/locales/en_US/datasource.ts                |   7 +
 .../src/locales/zh_CN/datasource.ts                |   7 +
 .../src/service/modules/data-source/types.ts       |   1 +
 .../src/views/datasource/list/detail.tsx           |  43 ++++-
 .../src/views/datasource/list/types.ts             |   1 +
 .../src/views/datasource/list/use-detail.ts        |  13 +-
 .../src/views/datasource/list/use-form.ts          |  41 ++++-
 15 files changed, 466 insertions(+), 13 deletions(-)

diff --git a/docs/docs/en/guide/datasource/kyuubi.md 
b/docs/docs/en/guide/datasource/kyuubi.md
index 4be8304ff5..62c20a2b60 100644
--- a/docs/docs/en/guide/datasource/kyuubi.md
+++ b/docs/docs/en/guide/datasource/kyuubi.md
@@ -28,6 +28,22 @@ clientPrincipal: Kerberos principal for client authentication
 serverPrincipal: Kerberos principal configured by kyuubi.kinit.principal at 
the server side.
 ```
 
+## Custom JDBC URL
+
+Select **JDBC URL** in the Kyuubi connection configuration to enter a complete 
URL instead of host, port, database and JDBC parameter fields. Existing 
datasources continue to use **Standard configuration** and require no migration.
+
+```text
+jdbc:kyuubi://kyuubi-server:10009/default;socketTimeout=600000?kyuubi.engine.share.level=USER;kyuubi.engine.share.level.subdomain=example
+```
+
+Client properties follow `;`; session properties use a leading `?` or `#`. The 
Kyuubi driver parses the URL. Supported catalog, discovery, HTTP and 
authentication options depend on the installed driver and server versions; this 
feature does not upgrade either component.
+
+Enter the username and password in their existing fields. Do not include 
`user` or `password` properties in the URL. In URL mode, the host, port, 
database and other JDBC parameter fields are not used. Test the connection 
before saving. Switching back to standard configuration requires valid standard 
connection fields.
+
+The create, update and connection-test APIs accept the optional string 
`rawJdbcUrl`. It is persisted in the existing connection-parameters JSON; the 
runtime `jdbcUrl` is derived from it. A nonblank `rawJdbcUrl` takes precedence 
over legacy connection fields, and `other` is not appended or passed as driver 
properties. Missing or blank `rawJdbcUrl` retains the previous behavior. No 
database schema change is needed.
+
+Deploy the updated plugin to the API server and workers before using custom 
URLs. Datasources of type **HIVE** are unchanged, even when their endpoint is a 
Kyuubi server.
+
 ## Native Supported
 
 - No, read section example in 
[pseudo-cluster](../installation/pseudo-cluster.md) `Download Plugins 
Dependencies` section to activate this datasource.
diff --git a/docs/docs/zh/guide/datasource/kyuubi.md 
b/docs/docs/zh/guide/datasource/kyuubi.md
index dc47ff8b4d..1c3fb58272 100644
--- a/docs/docs/zh/guide/datasource/kyuubi.md
+++ b/docs/docs/zh/guide/datasource/kyuubi.md
@@ -24,6 +24,22 @@ clientPrincipal: 用户客户端验证的Kerberos principal
 serverPrincipal: 在服务端通过kyuubi.kinit.principal配置的Kerberos principal.
 ```
 
+## 自定义 JDBC URL
+
+在 Kyuubi 的“连接配置方式”中选择 **JDBC URL**,可直接填写完整连接字符串,替代主机、端口、数据库和 JDBC 
参数输入。已有数据源默认使用“常规配置”,升级后无需迁移。
+
+```text
+jdbc:kyuubi://kyuubi-server:10009/default;socketTimeout=600000?kyuubi.engine.share.level=USER;kyuubi.engine.share.level.subdomain=example
+```
+
+`;` 后为客户端参数,`?` 或 `#` 引入会话参数,由 Kyuubi 驱动解析。catalog、服务发现、HTTP 
和认证参数的支持范围取决于实际驱动与服务端版本;本功能不升级这些组件。
+
+用户名、密码继续在原字段填写,不要在 URL 中配置 `user` 或 `password`。URL 模式下,旧主机、端口、数据库和 JDBC 
参数输入不参与连接。建议测试连接后保存。切回常规配置时,需填写有效的原连接字段。
+
+创建、更新和连接测试 API 新增可选字符串 `rawJdbcUrl`,保存在原连接参数 JSON 中,运行时 `jdbcUrl` 
由其派生。非空值优先于旧连接字段,`other` 不再拼接或额外注入驱动。未提供或空白时保持旧行为,无需修改数据库表结构。
+
+使用完整 URL 前,需为 API 和 Worker 部署更新后的插件。`HIVE` 类型数据源保持原样,即使它实际连接 Kyuubi Server。
+
 ## 是否原生支持
 
 - 否,使用前需请参考 [pseudo-cluster](../installation/pseudo-cluster.md) 中的 "下载插件依赖" 
章节激活数据源。
diff --git 
a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-kyuubi/pom.xml 
b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-kyuubi/pom.xml
index 299d489fb2..11a58108aa 100644
--- 
a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-kyuubi/pom.xml
+++ 
b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-kyuubi/pom.xml
@@ -33,6 +33,12 @@
     </properties>
 
     <dependencies>
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-params</artifactId>
+            <scope>test</scope>
+        </dependency>
+
         <dependency>
             <groupId>org.apache.dolphinscheduler</groupId>
             <artifactId>dolphinscheduler-spi</artifactId>
diff --git 
a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-kyuubi/src/main/java/org/apache/dolphinscheduler/plugin/datasource/kyuubi/param/KyuubiConnectionParam.java
 
b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-kyuubi/src/main/java/org/apache/dolphinscheduler/plugin/datasource/kyuubi/param/KyuubiConnectionParam.java
index 9c9097f897..2d8b418a17 100644
--- 
a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-kyuubi/src/main/java/org/apache/dolphinscheduler/plugin/datasource/kyuubi/param/KyuubiConnectionParam.java
+++ 
b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-kyuubi/src/main/java/org/apache/dolphinscheduler/plugin/datasource/kyuubi/param/KyuubiConnectionParam.java
@@ -19,8 +19,15 @@ package 
org.apache.dolphinscheduler.plugin.datasource.kyuubi.param;
 
 import org.apache.dolphinscheduler.spi.datasource.BaseConnectionParam;
 
+import lombok.Getter;
+import lombok.Setter;
+
 public class KyuubiConnectionParam extends BaseConnectionParam {
 
+    @Getter
+    @Setter
+    private String rawJdbcUrl;
+
     @Override
     public String toString() {
         return "KyuubiConnectionParam{"
diff --git 
a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-kyuubi/src/main/java/org/apache/dolphinscheduler/plugin/datasource/kyuubi/param/KyuubiDataSourceParamDTO.java
 
b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-kyuubi/src/main/java/org/apache/dolphinscheduler/plugin/datasource/kyuubi/param/KyuubiDataSourceParamDTO.java
index e81151fcfd..c15e5bdfe9 100644
--- 
a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-kyuubi/src/main/java/org/apache/dolphinscheduler/plugin/datasource/kyuubi/param/KyuubiDataSourceParamDTO.java
+++ 
b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-kyuubi/src/main/java/org/apache/dolphinscheduler/plugin/datasource/kyuubi/param/KyuubiDataSourceParamDTO.java
@@ -20,8 +20,15 @@ package 
org.apache.dolphinscheduler.plugin.datasource.kyuubi.param;
 import 
org.apache.dolphinscheduler.plugin.datasource.api.datasource.BaseDataSourceParamDTO;
 import org.apache.dolphinscheduler.spi.enums.DbType;
 
+import lombok.Getter;
+import lombok.Setter;
+
 public class KyuubiDataSourceParamDTO extends BaseDataSourceParamDTO {
 
+    @Getter
+    @Setter
+    private String rawJdbcUrl;
+
     @Override
     public String toString() {
         return "KyuubiDataSourceParamDTO{"
diff --git 
a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-kyuubi/src/main/java/org/apache/dolphinscheduler/plugin/datasource/kyuubi/param/KyuubiDataSourceProcessor.java
 
b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-kyuubi/src/main/java/org/apache/dolphinscheduler/plugin/datasource/kyuubi/param/KyuubiDataSourceProcessor.java
index bbee215f42..e70b0fef08 100644
--- 
a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-kyuubi/src/main/java/org/apache/dolphinscheduler/plugin/datasource/kyuubi/param/KyuubiDataSourceProcessor.java
+++ 
b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-kyuubi/src/main/java/org/apache/dolphinscheduler/plugin/datasource/kyuubi/param/KyuubiDataSourceProcessor.java
@@ -30,18 +30,33 @@ import 
org.apache.dolphinscheduler.spi.datasource.ConnectionParam;
 import org.apache.dolphinscheduler.spi.enums.DbType;
 
 import org.apache.commons.collections4.MapUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.kyuubi.jdbc.hive.JdbcConnectionParams;
+import org.apache.kyuubi.jdbc.hive.JdbcUriParseException;
+import org.apache.kyuubi.jdbc.hive.Utils;
 
 import java.sql.Connection;
 import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
+import java.util.Properties;
 
 import com.google.auto.service.AutoService;
 
 @AutoService(DataSourceProcessor.class)
 public class KyuubiDataSourceProcessor extends AbstractDataSourceProcessor {
 
+    @Override
+    public void checkDatasourceParam(BaseDataSourceParamDTO datasourceParam) {
+        KyuubiDataSourceParamDTO kyuubiParam = (KyuubiDataSourceParamDTO) 
datasourceParam;
+        if (StringUtils.isNotBlank(kyuubiParam.getRawJdbcUrl())) {
+            parseRawJdbcUrl(kyuubiParam.getRawJdbcUrl().trim());
+        } else {
+            super.checkDatasourceParam(datasourceParam);
+        }
+    }
+
     @Override
     public BaseDataSourceParamDTO castDatasourceParamDTO(String paramJson) {
         return JSONUtils.parseObject(paramJson, 
KyuubiDataSourceParamDTO.class);
@@ -54,6 +69,10 @@ public class KyuubiDataSourceProcessor extends 
AbstractDataSourceProcessor {
         
kyuubiDataSourceParamDTO.setDatabase(kyuubiConnectionParam.getDatabase());
         kyuubiDataSourceParamDTO.setUserName(kyuubiConnectionParam.getUser());
         kyuubiDataSourceParamDTO.setOther(kyuubiConnectionParam.getOther());
+        if (StringUtils.isNotBlank(kyuubiConnectionParam.getRawJdbcUrl())) {
+            
kyuubiDataSourceParamDTO.setRawJdbcUrl(kyuubiConnectionParam.getRawJdbcUrl());
+            return kyuubiDataSourceParamDTO;
+        }
 
         String[] tmpArray = 
kyuubiConnectionParam.getAddress().split(Constants.DOUBLE_SLASH);
         StringBuilder hosts = new StringBuilder();
@@ -71,6 +90,21 @@ public class KyuubiDataSourceProcessor extends 
AbstractDataSourceProcessor {
     @Override
     public BaseConnectionParam createConnectionParams(BaseDataSourceParamDTO 
datasourceParam) {
         KyuubiDataSourceParamDTO kyuubiParam = (KyuubiDataSourceParamDTO) 
datasourceParam;
+        if (StringUtils.isNotBlank(kyuubiParam.getRawJdbcUrl())) {
+            String rawJdbcUrl = kyuubiParam.getRawJdbcUrl().trim();
+            JdbcConnectionParams parsed = parseRawJdbcUrl(rawJdbcUrl);
+            KyuubiConnectionParam connectionParam = new 
KyuubiConnectionParam();
+            connectionParam.setRawJdbcUrl(rawJdbcUrl);
+            connectionParam.setJdbcUrl(rawJdbcUrl);
+            connectionParam.setAddress(rawJdbcUrl.substring(0, 
rawJdbcUrl.indexOf("://") + 3)
+                    + parsed.getSuppliedURLAuthority());
+            connectionParam.setDatabase(parsed.getDbName());
+            connectionParam.setUser(kyuubiParam.getUserName());
+            
connectionParam.setPassword(PasswordUtils.encodePassword(kyuubiParam.getPassword()));
+            connectionParam.setDriverClassName(getDatasourceDriver());
+            connectionParam.setValidationQuery(getValidationQuery());
+            return connectionParam;
+        }
         StringBuilder address = new StringBuilder();
         address.append(DataSourceConstants.JDBC_KYUUBI);
         for (String zkHost : kyuubiParam.getHost().split(",")) {
@@ -92,8 +126,13 @@ public class KyuubiDataSourceProcessor extends 
AbstractDataSourceProcessor {
 
     @Override
     public ConnectionParam createConnectionParams(String connectionJson) {
-        return JSONUtils.parseObject(connectionJson, 
KyuubiConnectionParam.class);
-
+        KyuubiConnectionParam connectionParam = 
JSONUtils.parseObject(connectionJson, KyuubiConnectionParam.class);
+        if (StringUtils.isNotBlank(connectionParam.getRawJdbcUrl())) {
+            
connectionParam.setRawJdbcUrl(connectionParam.getRawJdbcUrl().trim());
+            connectionParam.setJdbcUrl(connectionParam.getRawJdbcUrl());
+            connectionParam.setOther(null);
+        }
+        return connectionParam;
     }
 
     @Override
@@ -109,6 +148,9 @@ public class KyuubiDataSourceProcessor extends 
AbstractDataSourceProcessor {
     @Override
     public String getJdbcUrl(ConnectionParam connectionParam) {
         KyuubiConnectionParam kyuubiConnectionParam = (KyuubiConnectionParam) 
connectionParam;
+        if (StringUtils.isNotBlank(kyuubiConnectionParam.getRawJdbcUrl())) {
+            return kyuubiConnectionParam.getRawJdbcUrl().trim();
+        }
         String jdbcUrl = kyuubiConnectionParam.getJdbcUrl();
 
         if (MapUtils.isNotEmpty(kyuubiConnectionParam.getOther())) {
@@ -139,6 +181,23 @@ public class KyuubiDataSourceProcessor extends 
AbstractDataSourceProcessor {
         return new KyuubiDataSourceProcessor();
     }
 
+    private JdbcConnectionParams parseRawJdbcUrl(String rawJdbcUrl) {
+        try {
+            // Extract components only: saving a datasource must not contact 
ZooKeeper or the server.
+            JdbcConnectionParams parsed = 
Utils.extractURLComponents(rawJdbcUrl, new Properties());
+            if 
(parsed.getSessionVars().containsKey(JdbcConnectionParams.AUTH_USER)
+                    || 
parsed.getSessionVars().containsKey(JdbcConnectionParams.AUTH_PASSWD)) {
+                throw new IllegalArgumentException(
+                        "Use the datasource username and password fields 
instead of URL credentials");
+            }
+            return parsed;
+        } catch (JdbcUriParseException | IllegalArgumentException e) {
+            // Driver parse errors may contain the URL, so do not propagate 
the original message/cause.
+            throw new IllegalArgumentException(
+                    "Invalid Kyuubi JDBC URL; use a supported URL without 
user/password properties");
+        }
+    }
+
     private String transformOther(Map<String, String> otherMap) {
         if (MapUtils.isEmpty(otherMap)) {
             return null;
diff --git 
a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-kyuubi/src/test/java/org/apache/dolphinscheduler/plugin/datasource/kyuubi/KyuubiPooledDataSourceClientTest.java
 
b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-kyuubi/src/test/java/org/apache/dolphinscheduler/plugin/datasource/kyuubi/KyuubiPooledDataSourceClientTest.java
index 438682d835..8d0080a777 100644
--- 
a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-kyuubi/src/test/java/org/apache/dolphinscheduler/plugin/datasource/kyuubi/KyuubiPooledDataSourceClientTest.java
+++ 
b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-kyuubi/src/test/java/org/apache/dolphinscheduler/plugin/datasource/kyuubi/KyuubiPooledDataSourceClientTest.java
@@ -17,8 +17,14 @@
 
 package org.apache.dolphinscheduler.plugin.datasource.kyuubi;
 
+import 
org.apache.dolphinscheduler.plugin.datasource.kyuubi.param.KyuubiConnectionParam;
+import 
org.apache.dolphinscheduler.plugin.datasource.kyuubi.param.KyuubiDataSourceParamDTO;
+import 
org.apache.dolphinscheduler.plugin.datasource.kyuubi.param.KyuubiDataSourceProcessor;
+import org.apache.dolphinscheduler.spi.enums.DbType;
+
 import java.sql.Connection;
 import java.sql.SQLException;
+import java.util.Collections;
 
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
@@ -41,4 +47,48 @@ public class KyuubiPooledDataSourceClientTest {
 
     }
 
+    @Test
+    public void testRawUrlPoolDoesNotReceiveLegacyProperties() {
+        KyuubiDataSourceParamDTO dto = new KyuubiDataSourceParamDTO();
+        
dto.setRawJdbcUrl("jdbc:kyuubi://localhost:10009/default?kyuubi.engine.share.level=USER");
+        dto.setOther(Collections.singletonMap("stale", 
"must-not-be-injected"));
+        KyuubiConnectionParam param =
+                (KyuubiConnectionParam) new 
KyuubiDataSourceProcessor().createConnectionParams(dto);
+        try (InspectableClient client = new InspectableClient(param)) {
+            Assertions.assertEquals(dto.getRawJdbcUrl(), 
client.dataSourceUrl());
+            Assertions.assertFalse(client.hasProperty("stale"));
+        }
+    }
+
+    @Test
+    public void testLegacyPoolStillReceivesOtherProperties() {
+        KyuubiDataSourceParamDTO dto = new KyuubiDataSourceParamDTO();
+        dto.setHost("localhost");
+        dto.setPort(10009);
+        dto.setDatabase("default");
+        dto.setOther(Collections.singletonMap("socketTimeout", "600000"));
+        KyuubiConnectionParam param =
+                (KyuubiConnectionParam) new 
KyuubiDataSourceProcessor().createConnectionParams(dto);
+        try (InspectableClient client = new InspectableClient(param)) {
+            
Assertions.assertEquals("jdbc:kyuubi://localhost:10009/default;socketTimeout=600000",
+                    client.dataSourceUrl());
+            Assertions.assertTrue(client.hasProperty("socketTimeout"));
+        }
+    }
+
+    private static class InspectableClient extends 
KyuubiPooledDataSourceClient {
+
+        InspectableClient(KyuubiConnectionParam param) {
+            super(param, DbType.KYUUBI);
+        }
+
+        String dataSourceUrl() {
+            return dataSource.getJdbcUrl();
+        }
+
+        boolean hasProperty(String key) {
+            return dataSource.getDataSourceProperties().containsKey(key);
+        }
+    }
+
 }
diff --git 
a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-kyuubi/src/test/java/org/apache/dolphinscheduler/plugin/datasource/kyuubi/param/KyuubiDataSourceProcessorTest.java
 
b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-kyuubi/src/test/java/org/apache/dolphinscheduler/plugin/datasource/kyuubi/param/KyuubiDataSourceProcessorTest.java
index c97a86848b..cc2c954b15 100644
--- 
a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-kyuubi/src/test/java/org/apache/dolphinscheduler/plugin/datasource/kyuubi/param/KyuubiDataSourceProcessorTest.java
+++ 
b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-kyuubi/src/test/java/org/apache/dolphinscheduler/plugin/datasource/kyuubi/param/KyuubiDataSourceProcessorTest.java
@@ -25,12 +25,24 @@ import 
org.apache.dolphinscheduler.plugin.datasource.api.utils.PasswordUtils;
 import org.apache.dolphinscheduler.spi.datasource.ConnectionParam;
 import org.apache.dolphinscheduler.spi.enums.DbType;
 
+import org.apache.kyuubi.jdbc.KyuubiHiveDriver;
+import org.apache.kyuubi.jdbc.hive.JdbcConnectionParams;
+import org.apache.kyuubi.jdbc.hive.Utils;
+
+import java.sql.Connection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Properties;
 
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.NullAndEmptySource;
+import org.junit.jupiter.params.provider.ValueSource;
+import org.mockito.ArgumentCaptor;
+import org.mockito.MockedConstruction;
 import org.mockito.MockedStatic;
 import org.mockito.Mockito;
 import org.mockito.junit.jupiter.MockitoExtension;
@@ -169,4 +181,193 @@ public class KyuubiDataSourceProcessorTest {
         Assertions.assertNotNull(kyuubiDataSourceParamDTO.toString());
     }
 
+    @ParameterizedTest
+    @ValueSource(strings = {
+            
"jdbc:kyuubi://localhost:10009/default;socketTimeout=600000?kyuubi.engine.share.level=USER;spark.app.name=raw-test",
+            
"jdbc:kyuubi://localhost:10009/default#kyuubi.engine.share.level=USER",
+            
"jdbc:hive2://localhost:10009/spark_catalog/default?x=a=b#marker=test",
+            
"jdbc:kyuubi://localhost:10009/default;transportMode=http;httpPath=cliservice",
+            
"jdbc:kyuubi://zk-a:2181,zk-b:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=kyuubi",
+            "jdbc:kyuubi://[::1]:10009/default?marker=hello%20world",
+            "jdbc:kyuubi://localhost:10009/default"
+    })
+    public void testRawJdbcUrlRoundTrip(String rawJdbcUrl) {
+        String requestJson = 
"{\"type\":\"KYUUBI\",\"userName\":\"test\",\"password\":\"secret\",\"rawJdbcUrl\":"
+                + JSONUtils.toJsonString(rawJdbcUrl) + "}";
+        KyuubiDataSourceParamDTO dto =
+                (KyuubiDataSourceParamDTO) 
kyuubiDatasourceProcessor.castDatasourceParamDTO(requestJson);
+        kyuubiDatasourceProcessor.checkDatasourceParam(dto);
+        KyuubiConnectionParam created = (KyuubiConnectionParam) 
kyuubiDatasourceProcessor.createConnectionParams(dto);
+        Assertions.assertEquals(rawJdbcUrl, created.getRawJdbcUrl());
+        Assertions.assertEquals(rawJdbcUrl, created.getJdbcUrl());
+        Assertions.assertNull(created.getOther());
+        String storedJson = JSONUtils.toJsonString(created);
+        KyuubiConnectionParam restored =
+                (KyuubiConnectionParam) 
kyuubiDatasourceProcessor.createConnectionParams(storedJson);
+        Assertions.assertEquals(rawJdbcUrl, 
kyuubiDatasourceProcessor.getJdbcUrl(restored));
+        KyuubiDataSourceParamDTO editable =
+                (KyuubiDataSourceParamDTO) 
kyuubiDatasourceProcessor.createDatasourceParamDTO(storedJson);
+        Assertions.assertEquals(rawJdbcUrl, editable.getRawJdbcUrl());
+        editable.setPassword("secret");
+        kyuubiDatasourceProcessor.checkDatasourceParam(editable);
+        Assertions.assertEquals(rawJdbcUrl, 
kyuubiDatasourceProcessor.getJdbcUrl(
+                kyuubiDatasourceProcessor.createConnectionParams(editable)));
+    }
+
+    @ParameterizedTest
+    @NullAndEmptySource
+    @ValueSource(strings = {" ", "  \t"})
+    public void testOldRequestAndBlankRawUrlRemainCompatible(String 
rawJdbcUrl) {
+        KyuubiDataSourceParamDTO dto = legacyDto();
+        dto.setRawJdbcUrl(rawJdbcUrl);
+        kyuubiDatasourceProcessor.checkDatasourceParam(dto);
+        KyuubiConnectionParam param = (KyuubiConnectionParam) 
kyuubiDatasourceProcessor.createConnectionParams(dto);
+        Assertions.assertNull(param.getRawJdbcUrl());
+        
Assertions.assertEquals("jdbc:kyuubi://localhost:10009/default;socketTimeout=600000",
+                kyuubiDatasourceProcessor.getJdbcUrl(param));
+        KyuubiDataSourceParamDTO editable =
+                (KyuubiDataSourceParamDTO) 
kyuubiDatasourceProcessor.createDatasourceParamDTO(
+                        JSONUtils.toJsonString(param));
+        Assertions.assertNull(editable.getRawJdbcUrl());
+        Assertions.assertEquals(dto.getHost(), editable.getHost());
+        Assertions.assertEquals(dto.getPort(), editable.getPort());
+        Assertions.assertEquals(dto.getOther(), editable.getOther());
+    }
+
+    @Test
+    public void testOldStoredJsonAndUnchangedEdit() {
+        String oldJson = 
"{\"user\":\"test\",\"password\":\"secret\",\"address\":\"jdbc:kyuubi://localhost:10009\","
+                + 
"\"database\":\"default\",\"jdbcUrl\":\"jdbc:kyuubi://localhost:10009/default\","
+                + "\"other\":{\"socketTimeout\":\"600000\"}}";
+        KyuubiConnectionParam original =
+                (KyuubiConnectionParam) 
kyuubiDatasourceProcessor.createConnectionParams(oldJson);
+        KyuubiDataSourceParamDTO editable =
+                (KyuubiDataSourceParamDTO) 
kyuubiDatasourceProcessor.createDatasourceParamDTO(oldJson);
+        editable.setPassword("secret");
+        editable.setName("renamed-only");
+        KyuubiConnectionParam saved =
+                (KyuubiConnectionParam) 
kyuubiDatasourceProcessor.createConnectionParams(editable);
+        Assertions.assertEquals(kyuubiDatasourceProcessor.getJdbcUrl(original),
+                kyuubiDatasourceProcessor.getJdbcUrl(saved));
+        Assertions.assertEquals(original.getOther(), saved.getOther());
+        Assertions.assertEquals(original.getPassword(), saved.getPassword());
+        Assertions.assertNull(saved.getRawJdbcUrl());
+    }
+
+    @Test
+    public void testRawUrlOverridesStaleLegacyInput() {
+        KyuubiDataSourceParamDTO dto = legacyDto();
+        String url = 
"jdbc:kyuubi://new-host:10010/catalog/new_schema?kyuubi.engine.share.level=USER";
+        dto.setRawJdbcUrl("  " + url + "  ");
+        dto.setHost("not a valid old host");
+        dto.setOther(Collections.singletonMap("invalid#oldKey", "ignored"));
+        kyuubiDatasourceProcessor.checkDatasourceParam(dto);
+        KyuubiConnectionParam param = (KyuubiConnectionParam) 
kyuubiDatasourceProcessor.createConnectionParams(dto);
+        Assertions.assertEquals(url, param.getRawJdbcUrl());
+        Assertions.assertEquals(url, param.getJdbcUrl());
+        Assertions.assertEquals("new_schema", param.getDatabase());
+        Assertions.assertEquals("jdbc:kyuubi://new-host:10010", 
param.getAddress());
+        Assertions.assertNull(param.getOther());
+    }
+
+    @Test
+    public void testStoredRawUrlIsAuthoritativeForRuntimeAndCache() {
+        String storedJson = 
"{\"rawJdbcUrl\":\"jdbc:kyuubi://new-host:10009/default#marker=new\","
+                + 
"\"jdbcUrl\":\"jdbc:kyuubi://old-host:10009/default\",\"other\":{\"marker\":\"stale\"}}";
+        KyuubiConnectionParam param =
+                (KyuubiConnectionParam) 
kyuubiDatasourceProcessor.createConnectionParams(storedJson);
+        Assertions.assertEquals(param.getRawJdbcUrl(), param.getJdbcUrl());
+        Assertions.assertEquals(param.getRawJdbcUrl(), 
kyuubiDatasourceProcessor.getJdbcUrl(param));
+        Assertions.assertNull(param.getOther());
+        String cacheKey = 
kyuubiDatasourceProcessor.getDatasourceUniqueId(param, DbType.KYUUBI);
+        Assertions.assertTrue(cacheKey.contains("new-host"));
+        Assertions.assertFalse(cacheKey.contains("old-host"));
+    }
+
+    @ParameterizedTest
+    @ValueSource(strings = {"?", "#"})
+    public void testActualDriverReceivesSessionProperties(String separator) 
throws Exception {
+        KyuubiDataSourceParamDTO dto = new KyuubiDataSourceParamDTO();
+        
dto.setRawJdbcUrl("jdbc:kyuubi://localhost:10009/default;socketTimeout=600000"
+                + separator + 
"kyuubi.engine.share.level=USER;spark.app.name=raw-test");
+        String url = 
kyuubiDatasourceProcessor.getJdbcUrl(kyuubiDatasourceProcessor.createConnectionParams(dto));
+        JdbcConnectionParams parsed = Utils.extractURLComponents(url, new 
Properties());
+        Map<String, String> sessionProperties = "?".equals(separator) ? 
parsed.getHiveConfs() : parsed.getHiveVars();
+        Assertions.assertEquals("600000", 
parsed.getSessionVars().get("socketTimeout"));
+        Assertions.assertEquals("USER", 
sessionProperties.get("kyuubi.engine.share.level"));
+        Assertions.assertEquals("raw-test", 
sessionProperties.get("spark.app.name"));
+    }
+
+    @ParameterizedTest
+    @ValueSource(strings = {
+            "jdbc:mysql://localhost:3306/default",
+            "not a JDBC URL",
+            "jdbc:kyuubi://localhost:10009/default?invalid space=value",
+            
"jdbc:kyuubi://localhost:10009/default;user=test;password=do-not-print",
+            "jdbc:kyuubi://localhost:10009/default;password=do-not-print"
+    })
+    public void testInvalidRawUrlWithoutLeakingInput(String url) {
+        KyuubiDataSourceParamDTO dto = new KyuubiDataSourceParamDTO();
+        dto.setRawJdbcUrl(url);
+        IllegalArgumentException error = 
Assertions.assertThrows(IllegalArgumentException.class,
+                () -> kyuubiDatasourceProcessor.checkDatasourceParam(dto));
+        Assertions.assertFalse(error.getMessage().contains(url));
+        Assertions.assertFalse(error.getMessage().contains("do-not-print"));
+        Assertions.assertNull(error.getCause());
+    }
+
+    @Test
+    public void testDifferentRawRoutingUrlsHaveDifferentPools() {
+        KyuubiDataSourceParamDTO dto = legacyDto();
+        
dto.setRawJdbcUrl("jdbc:kyuubi://localhost:10009/default?kyuubi.engine.share.level.subdomain=a");
+        ConnectionParam first = 
kyuubiDatasourceProcessor.createConnectionParams(dto);
+        
dto.setRawJdbcUrl("jdbc:kyuubi://localhost:10009/default?kyuubi.engine.share.level.subdomain=b");
+        ConnectionParam second = 
kyuubiDatasourceProcessor.createConnectionParams(dto);
+        
Assertions.assertNotEquals(kyuubiDatasourceProcessor.getDatasourceUniqueId(first,
 DbType.KYUUBI),
+                kyuubiDatasourceProcessor.getDatasourceUniqueId(second, 
DbType.KYUUBI));
+    }
+
+    @Test
+    public void testSwitchFromRawUrlBackToLegacy() {
+        KyuubiDataSourceParamDTO dto = legacyDto();
+        
dto.setRawJdbcUrl("jdbc:kyuubi://different-host:10009/default#marker=raw");
+        KyuubiConnectionParam raw = (KyuubiConnectionParam) 
kyuubiDatasourceProcessor.createConnectionParams(dto);
+        Assertions.assertNotNull(raw.getRawJdbcUrl());
+        dto.setRawJdbcUrl(null);
+        KyuubiConnectionParam standard = (KyuubiConnectionParam) 
kyuubiDatasourceProcessor.createConnectionParams(dto);
+        Assertions.assertNull(standard.getRawJdbcUrl());
+        
Assertions.assertEquals("jdbc:kyuubi://localhost:10009/default;socketTimeout=600000",
+                kyuubiDatasourceProcessor.getJdbcUrl(standard));
+    }
+
+    @Test
+    public void testDirectConnectionPassesRawUrlAndSeparateCredentials() 
throws Exception {
+        KyuubiDataSourceParamDTO dto = legacyDto();
+        
dto.setRawJdbcUrl("jdbc:kyuubi://localhost:10009/default#kyuubi.engine.share.level=USER");
+        Connection connection = Mockito.mock(Connection.class);
+        try (
+                MockedConstruction<KyuubiHiveDriver> drivers = 
Mockito.mockConstruction(KyuubiHiveDriver.class,
+                        (driver, context) -> Mockito
+                                .when(driver.connect(Mockito.anyString(), 
Mockito.any(Properties.class)))
+                                .thenReturn(connection))) {
+            Assertions.assertSame(connection, 
kyuubiDatasourceProcessor.getConnection(
+                    kyuubiDatasourceProcessor.createConnectionParams(dto)));
+            ArgumentCaptor<Properties> properties = 
ArgumentCaptor.forClass(Properties.class);
+            
Mockito.verify(drivers.constructed().get(0)).connect(Mockito.eq(dto.getRawJdbcUrl()),
 properties.capture());
+            Assertions.assertEquals(dto.getUserName(), 
properties.getValue().getProperty("user"));
+            Assertions.assertEquals(dto.getPassword(), 
properties.getValue().getProperty("password"));
+        }
+    }
+
+    private KyuubiDataSourceParamDTO legacyDto() {
+        KyuubiDataSourceParamDTO dto = new KyuubiDataSourceParamDTO();
+        dto.setHost("localhost");
+        dto.setPort(10009);
+        dto.setDatabase("default");
+        dto.setUserName("test");
+        dto.setPassword("secret");
+        dto.setOther(Collections.singletonMap("socketTimeout", "600000"));
+        return dto;
+    }
+
 }
diff --git a/dolphinscheduler-ui/src/locales/en_US/datasource.ts 
b/dolphinscheduler-ui/src/locales/en_US/datasource.ts
index 645edc7f7d..6ea9364731 100644
--- a/dolphinscheduler-ui/src/locales/en_US/datasource.ts
+++ b/dolphinscheduler-ui/src/locales/en_US/datasource.ts
@@ -54,6 +54,13 @@ export default {
   oracle_sid: 'SID',
   compatible_mode: 'Compatible Mode',
   compatible_mode_tips: 'Please enter compatible mode',
+  kyuubi_keep_password_tips:
+    'Leave blank to keep the saved password; re-enter it to test the edited 
connection.',
+  connection_configuration: 'Connection configuration',
+  standard_configuration: 'Standard configuration',
+  raw_jdbc_url_required: 'Enter a complete JDBC URL',
+  raw_jdbc_url_tips:
+    'jdbc:kyuubi://host:port/schema;clientProperties?sessionProperties — enter 
credentials in the username and password fields below.',
   jdbc_connect_parameters: 'jdbc connect parameters',
   principal_tips: 'Please enter Principal',
   krb5_conf_tips:
diff --git a/dolphinscheduler-ui/src/locales/zh_CN/datasource.ts 
b/dolphinscheduler-ui/src/locales/zh_CN/datasource.ts
index b3a68ec3d8..25059c7d7f 100644
--- a/dolphinscheduler-ui/src/locales/zh_CN/datasource.ts
+++ b/dolphinscheduler-ui/src/locales/zh_CN/datasource.ts
@@ -54,6 +54,13 @@ export default {
   oracle_sid: 'SID',
   compatible_mode: '兼容模式',
   compatible_mode_tips: '请输入兼容模式',
+  kyuubi_keep_password_tips:
+    '留空保留原密码;测试编辑后的连接时请重新输入密码。',
+  connection_configuration: '连接配置方式',
+  standard_configuration: '常规配置',
+  raw_jdbc_url_required: '请输入完整 JDBC URL',
+  raw_jdbc_url_tips:
+    'jdbc:kyuubi://host:port/schema;客户端参数?会话参数;用户名和密码在下方填写。',
   jdbc_connect_parameters: 'jdbc连接参数',
   principal_tips: '请输入Principal',
   krb5_conf_tips: '请输入kerberos认证参数 java.security.krb5.conf',
diff --git a/dolphinscheduler-ui/src/service/modules/data-source/types.ts 
b/dolphinscheduler-ui/src/service/modules/data-source/types.ts
index cd6badccb4..5bac47e3d9 100644
--- a/dolphinscheduler-ui/src/service/modules/data-source/types.ts
+++ b/dolphinscheduler-ui/src/service/modules/data-source/types.ts
@@ -89,6 +89,7 @@ interface IDataSource {
   database?: string
   connectType?: string
   other?: object
+  rawJdbcUrl?: string
   restEndpoint?: string
   kubeConfig?: string
   namespace?: string
diff --git a/dolphinscheduler-ui/src/views/datasource/list/detail.tsx 
b/dolphinscheduler-ui/src/views/datasource/list/detail.tsx
index 6f12176f79..d1532a3751 100644
--- a/dolphinscheduler-ui/src/views/datasource/list/detail.tsx
+++ b/dolphinscheduler-ui/src/views/datasource/list/detail.tsx
@@ -181,6 +181,8 @@ const DetailModal = defineComponent({
       onSubmit,
       handleSourceModalOpen
     } = this
+    const useRawJdbcUrl =
+      detailForm.type === 'KYUUBI' && detailForm.connectionMode === 'url'
     return (
       <Modal
         class='dialog-create-data-source'
@@ -244,8 +246,35 @@ const DetailModal = defineComponent({
                     placeholder={t('datasource.description_tips')}
                   />
                 </NFormItem>
+                {detailForm.type === 'KYUUBI' && (
+                  <NFormItem label={t('datasource.connection_configuration')}>
+                    <NRadioGroup v-model={[detailForm.connectionMode, 
'value']}>
+                      <NSpace>
+                        <NRadio value='standard'>
+                          {t('datasource.standard_configuration')}
+                        </NRadio>
+                        <NRadio value='url'>JDBC URL</NRadio>
+                      </NSpace>
+                    </NRadioGroup>
+                  </NFormItem>
+                )}
+                {useRawJdbcUrl && (
+                  <NFormItem
+                    label='JDBC URL'
+                    path='rawJdbcUrl'
+                    show-require-mark
+                  >
+                    <NInput
+                      class='input-raw-jdbc-url'
+                      v-model={[detailForm.rawJdbcUrl, 'value']}
+                      type='textarea'
+                      autosize={{ minRows: 3, maxRows: 6 }}
+                      placeholder={t('datasource.raw_jdbc_url_tips')}
+                    />
+                  </NFormItem>
+                )}
                 <NFormItem
-                  v-show={showHost}
+                  v-show={showHost && !useRawJdbcUrl}
                   label={t('datasource.ip')}
                   path='host'
                   show-require-mark
@@ -334,7 +363,7 @@ const DetailModal = defineComponent({
                   />
                 </NFormItem>
                 <NFormItem
-                  v-show={showPort}
+                  v-show={showPort && !useRawJdbcUrl}
                   label={t('datasource.port')}
                   path='port'
                   show-require-mark={
@@ -639,7 +668,11 @@ const DetailModal = defineComponent({
                     class='input-password'
                     v-model={[detailForm.password, 'value']}
                     type='password'
-                    placeholder={t('datasource.user_password_tips')}
+                    placeholder={t(
+                      id && detailForm.type === 'KYUUBI'
+                        ? 'datasource.kyuubi_keep_password_tips'
+                        : 'datasource.user_password_tips'
+                    )}
                   />
                 </NFormItem>
                 <NFormItem
@@ -657,7 +690,7 @@ const DetailModal = defineComponent({
                   />
                 </NFormItem>
                 <NFormItem
-                  v-show={showDataBaseName}
+                  v-show={showDataBaseName && !useRawJdbcUrl}
                   label={t('datasource.database_name')}
                   path='database'
                   show-require-mark={requiredDataBase}
@@ -719,7 +752,7 @@ const DetailModal = defineComponent({
                   />
                 </NFormItem>
                 <NFormItem
-                  v-show={showJDBCConnectParameters}
+                  v-show={showJDBCConnectParameters && !useRawJdbcUrl}
                   label={t('datasource.jdbc_connect_parameters')}
                   path='other'
                 >
diff --git a/dolphinscheduler-ui/src/views/datasource/list/types.ts 
b/dolphinscheduler-ui/src/views/datasource/list/types.ts
index a3dc8b3c40..5c34848e9a 100644
--- a/dolphinscheduler-ui/src/views/datasource/list/types.ts
+++ b/dolphinscheduler-ui/src/views/datasource/list/types.ts
@@ -24,6 +24,7 @@ import type { SelectBaseOption } from 
'naive-ui/es/select/src/interface'
 
 interface IDataSourceDetail extends Omit<IDataSource, 'other'> {
   other?: string
+  connectionMode?: 'standard' | 'url'
 }
 
 interface IDataBaseOption extends SelectBaseOption {
diff --git a/dolphinscheduler-ui/src/views/datasource/list/use-detail.ts 
b/dolphinscheduler-ui/src/views/datasource/list/use-detail.ts
index 3f533d00e7..e750628495 100644
--- a/dolphinscheduler-ui/src/views/datasource/list/use-detail.ts
+++ b/dolphinscheduler-ui/src/views/datasource/list/use-detail.ts
@@ -37,7 +37,18 @@ export function useDetail(getFieldsValue: Function) {
   let PREV_NAME: string
 
   const formatParams = (): IDataSource => {
-    const values = getFieldsValue()
+    const { connectionMode, rawJdbcUrl, ...values } = getFieldsValue()
+    if (values.type === 'KYUUBI' && connectionMode === 'url') {
+      return {
+        type: values.type,
+        id: values.id,
+        name: values.name,
+        note: values.note,
+        userName: values.userName,
+        password: values.password,
+        rawJdbcUrl: rawJdbcUrl.trim()
+      }
+    }
     return {
       ...values,
       other: values.other ? JSON.parse(values.other) : null
diff --git a/dolphinscheduler-ui/src/views/datasource/list/use-form.ts 
b/dolphinscheduler-ui/src/views/datasource/list/use-form.ts
index d291e39402..31f7135081 100644
--- a/dolphinscheduler-ui/src/views/datasource/list/use-form.ts
+++ b/dolphinscheduler-ui/src/views/datasource/list/use-form.ts
@@ -48,6 +48,8 @@ export function useForm(id?: number) {
     database: '',
     connectType: '',
     other: '',
+    rawJdbcUrl: '',
+    connectionMode: 'standard',
     endpoint: '',
     MSIClientId: '',
     dbUser: '',
@@ -87,7 +89,7 @@ export function useForm(id?: number) {
       host: {
         trigger: ['input'],
         validator() {
-          if (!state.detailForm.host && state.showHost) {
+          if (!isRawJdbcUrl() && !state.detailForm.host && state.showHost) {
             return new Error(t('datasource.ip_tips'))
           }
         }
@@ -95,7 +97,10 @@ export function useForm(id?: number) {
       port: {
         trigger: ['input'],
         validator() {
-          if (state.showMode && state.detailForm.mode === 'IAM-accessKey') {
+          if (
+            isRawJdbcUrl() ||
+            (state.showMode && state.detailForm.mode === 'IAM-accessKey')
+          ) {
             return
           }
           if (!state.detailForm.port && state.showPort) {
@@ -143,7 +148,11 @@ export function useForm(id?: number) {
       database: {
         trigger: ['input'],
         validator() {
-          if (!state.detailForm.database && state.requiredDataBase) {
+          if (
+            !isRawJdbcUrl() &&
+            !state.detailForm.database &&
+            state.requiredDataBase
+          ) {
             return new Error(t('datasource.database_name_tips'))
           }
         }
@@ -164,10 +173,22 @@ export function useForm(id?: number) {
           }
         }
       },
+      rawJdbcUrl: {
+        trigger: ['input', 'blur'],
+        validator() {
+          if (isRawJdbcUrl() && !state.detailForm.rawJdbcUrl?.trim()) {
+            return new Error(t('datasource.raw_jdbc_url_required'))
+          }
+        }
+      },
       other: {
         trigger: ['input', 'blur'],
         validator() {
-          if (state.detailForm.other && !utils.isJson(state.detailForm.other)) 
{
+          if (
+            !isRawJdbcUrl() &&
+            state.detailForm.other &&
+            !utils.isJson(state.detailForm.other)
+          ) {
             return new Error(t('datasource.jdbc_format_tips'))
           }
         }
@@ -238,6 +259,10 @@ export function useForm(id?: number) {
     ]
   })
 
+  const isRawJdbcUrl = () =>
+    state.detailForm.type === 'KYUUBI' &&
+    state.detailForm.connectionMode === 'url'
+
   const changeType = async (type: IDataBase, options: IDataBaseOption) => {
     state.detailForm.port = options.previousPort || options.defaultPort
     state.detailForm.type = type
@@ -344,7 +369,13 @@ export function useForm(id?: number) {
     state.detailForm = {
       ...state.detailForm,
       ...values,
-      other: values.other ? JSON.stringify(values.other) : values.other
+      ...(values.type === 'KYUUBI' && values.id ? { password: '' } : {}),
+      other: values.other ? JSON.stringify(values.other) : values.other,
+      rawJdbcUrl: values.rawJdbcUrl || '',
+      connectionMode:
+        values.type === 'KYUUBI' && values.rawJdbcUrl?.trim()
+          ? 'url'
+          : 'standard'
     }
   }
 

Reply via email to