fix(transfer): support gbase jdbc connections

This commit is contained in:
zipg authored and GitHub committed 2026-08-31 14:03:54 +08:00
1 parent 0c8b796c8c
commit d459628141
9 files changed
+240 -13

No files matched your search

@@ -189,6 +189,40 @@ describe("jdbc dialect inference", () => {
expect(inferJdbcDialect(damengConnection)).toBe("dameng");
});
it("detects GBase JDBC connections for transfer dialect selection", () => {
const gbaseConnection = {
db_type: "jdbc" as const,
connection_string: "jdbc:gbase://localhost:5258/dbx_test",
jdbc_driver_class: "cn.gbase.Driver",
};
expect(inferJdbcDialect(gbaseConnection)).toBe("gbase");
expect(effectiveDatabaseTypeForConnection(gbaseConnection)).toBe("gbase");
// GBase 8s is Informix-based and must stay on generic jdbc (no MySQL-family transfer dialect).
const gbase8sByUrl = {
db_type: "jdbc" as const,
connection_string: "jdbc:gbasedbt-sqli://localhost:9088/dbx_test:INFORMIXSERVER=ol_gbasedbt",
jdbc_driver_class: "com.gbasedbt.jdbc.Driver",
};
const gbase8sByProfile = {
db_type: "jdbc" as const,
driver_profile: "gbase8s",
};
const gbase8sProfileWithLegacyGbaseUrl = {
db_type: "jdbc" as const,
driver_profile: "gbase8s",
connection_string: "jdbc:gbase://localhost:5258/dbx_test",
jdbc_driver_class: "cn.gbase.Driver",
};
expect(inferJdbcDialect(gbase8sByUrl)).toBe("informix");
expect(effectiveDatabaseTypeForConnection(gbase8sByUrl)).toBe("informix");
expect(inferJdbcDialect(gbase8sByProfile)).toBeUndefined();
expect(effectiveDatabaseTypeForConnection(gbase8sByProfile)).toBe("jdbc");
expect(inferJdbcDialect(gbase8sProfileWithLegacyGbaseUrl)).toBeUndefined();
expect(effectiveDatabaseTypeForConnection(gbase8sProfileWithLegacyGbaseUrl)).toBe("jdbc");
});
it("uses Hive tree and execution semantics for Inceptor JDBC metadata", () => {
const connection = {
db_type: "jdbc" as const,
@@ -26,6 +26,8 @@ const JDBC_DIALECT_MATCHERS: Array<{ type: DatabaseType; patterns: RegExp[] }> =
{ type: "jdbc", patterns: [/phoenix/i] },
{ type: "doris", patterns: [/doris/i] },
{ type: "goldendb", patterns: [/jdbc:goldendb:/i, /goldendb/i] },
// GBase 8a only: 8s (`gbasedbt`/`jdbc:gbasedbt-sqli`) is Informix-based and must stay on jdbc.
{ type: "gbase", patterns: [/jdbc:gbase:/i, /cn\.gbase\./i, /gbase(?!dbt)(?!8s).*jdbc/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] },
@@ -50,6 +52,7 @@ const JDBC_ASE_PROFILE_PATTERNS = [/(?:^|[\s_-])ase(?:$|[\s_-])/i, /\bsap[\s_-]+
export function inferJdbcDialect(connection?: JdbcDialectConnection): DatabaseType | undefined {
if (!connection || connection.db_type !== "jdbc") return undefined;
if (isGbase8sProfile(connection.driver_profile)) return undefined;
const haystack = [connection.driver_profile, connection.driver_label, connection.connection_string, connection.jdbc_driver_class, ...(connection.jdbc_driver_paths ?? []), connection.database_info?.productName, connection.database_info?.serverComment, connection.database_info?.driverName]
.filter(Boolean)
.join("\n");
@@ -17,6 +17,7 @@ const SQLSERVER_KINDS: TransferObjectKind[] = ["TABLE", "VIEW", "PROCEDURE", "FU
const FAMILY_BY_DB = new Map<DatabaseType, TransferObjectFamily>([
["mysql", TransferObjectFamily.Mysql],
["gbase", TransferObjectFamily.Mysql],
["postgres", TransferObjectFamily.Postgres],
["kingbase", TransferObjectFamily.Postgres],
["gaussdb", TransferObjectFamily.Postgres],