Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

fix(jdbc): detect Inceptor as Hive

t8y2b3c4c9a91274
diff --git a/apps/desktop/src/lib/__tests__/database/jdbcDialect.spec.ts b/apps/desktop/src/lib/__tests__/database/jdbcDialect.spec.ts
index 439ae34e50..018e16e189 100644
--- a/apps/desktop/src/lib/__tests__/database/jdbcDialect.spec.ts
+++ b/apps/desktop/src/lib/__tests__/database/jdbcDialect.spec.ts
@@ -139,6 +139,42 @@ describe("jdbc dialect inference", () => {
expect(inferJdbcDialect(damengConnection)).toBe("dameng");
});
+
+ it("uses Hive tree and execution semantics for Inceptor JDBC metadata", () => {
+ const connection = {
+ db_type: "jdbc" as const,
+ connection_string: "jdbc:hive2://inceptor.example.com:10000/default",
+ database_info: { productName: "Apache Hive", driverName: "Inceptor JDBC 8.37.3" },
+ };
+
+ expect(inferJdbcDialect(connection)).toBe("hive");
+ expect(effectiveDatabaseTypeForConnection(connection)).toBe("hive");
+ expect(connectionUsesDatabaseObjectTreeMode(connection)).toBe(false);
+ expect(connectionObjectTreeNodeSchema(connection, "CS")).toBe("CS");
+ expect(connectionQueryExecutionSchema(connection, "CS", undefined, false)).toBe("CS");
+ });
+
+ it.each([
+ { driver_profile: "inceptor" },
+ { driver_label: "Inceptor JDBC 8.37.3" },
+ { jdbc_driver_class: "io.transwarp.inceptor.jdbc.InceptorDriver" },
+ { jdbc_driver_paths: ["C:\\drivers\\InceptorJDBC.jar"] },
+ { database_info: { driverName: "Inceptor JDBC 8.37.3" } },
+ { database_info: { serverComment: "Transwarp Inceptor Server" } },
+ ])("detects Inceptor from explicit JDBC identity %#", (identity) => {
+ expect(inferJdbcDialect({ db_type: "jdbc", ...identity })).toBe("hive");
+ });
+
+ it("recognizes Apache Hive metadata without changing generic hive2 or MySQL inference", () => {
+ expect(inferJdbcDialect({ db_type: "jdbc", database_info: { productName: "Apache Hive" } })).toBe("hive");
+ expect(inferJdbcDialect({ db_type: "jdbc", driver_label: "Kyuubi JDBC", connection_string: "jdbc:hive2://kyuubi.example.com/default" })).toBe("mysql");
+ expect(inferJdbcDialect({ db_type: "jdbc", connection_string: "jdbc:hive2://hiveserver.example.com/default" })).toBe("mysql");
+ expect(inferJdbcDialect({ db_type: "jdbc", connection_string: "jdbc:mysql://mysql.example.com/app" })).toBe("mysql");
+ });
+
+ it("prefers explicit Kyuubi identity over Apache Hive product metadata", () => {
+ expect(inferJdbcDialect({ db_type: "jdbc", driver_label: "Kyuubi JDBC", database_info: { productName: "Apache Hive" } })).toBe("mysql");
+ });
});
describe("GaussDB connection mode", () => {
diff --git a/apps/desktop/src/lib/database/jdbcDialect.ts b/apps/desktop/src/lib/database/jdbcDialect.ts
index d471843440..801e0e6563 100644
--- a/apps/desktop/src/lib/database/jdbcDialect.ts
+++ b/apps/desktop/src/lib/database/jdbcDialect.ts
@@ -18,8 +18,9 @@ const JDBC_DIALECT_MATCHERS: Array<{ type: DatabaseType; patterns: RegExp[] }> =
{ type: "starrocks", patterns: [/starrocks/i] },
{ type: "doris", patterns: [/doris/i] },
{ type: "goldendb", patterns: [/jdbc:goldendb:/i, /goldendb/i] },
- { type: "hive", patterns: [/org\.apache\.hive\.jdbc\.HiveDriver/i, /hive-jdbc/i] },
- { type: "mysql", patterns: [/jdbc:mysql:/i, /mysql/i, /mariadb/i, /kyuubi/i, /hive2/i] },
+ { type: "mysql", patterns: [/kyuubi/i] },
+ { type: "hive", patterns: [/inceptor/i, /\bapache\s+hive\b/i, /org\.apache\.hive\.jdbc\.HiveDriver/i, /hive-jdbc/i] },
+ { type: "mysql", patterns: [/jdbc:mysql:/i, /mysql/i, /mariadb/i, /hive2/i] },
{ type: "gaussdb", patterns: [/jdbc:gaussdb:/i, /com\.huawei\.gaussdb/i, /gaussdb/i] },
{ type: "dameng", patterns: [/jdbc:dm:/i, /dm\.jdbc\.driver/i, /dameng/i] },
{ type: "opengauss", patterns: [/jdbc:opengauss:/i, /org\.opengauss/i, /opengauss/i] },