feat(databend): support agent driver

This commit is contained in:
t8y2 committed 2026-06-07 16:39:22 +08:00
1 parent 3403819658
commit 74e19ec6a3
18 files changed
+127 -14

No files matched your search

@@ -332,6 +332,7 @@ const driverProfiles: Record<
icon: "oceanbase",
},
goldendb: { type: "goldendb", port: 3306, user: "root", label: "GoldenDB", icon: "goldendb" },
databend: { type: "databend", port: 8000, user: "databend", label: "Databend", icon: "databend" },
tdsql: { type: "mysql", port: 3306, user: "root", label: "TDSQL", icon: "tdsql" },
polardb: { type: "mysql", port: 3306, user: "root", label: "PolarDB", icon: "polardb" },
greatsql: { type: "mysql", port: 3306, user: "root", label: "GreatSQL", icon: "greatsql" },
@@ -600,6 +601,7 @@ function defaultDatabaseForProfile() {
if (form.value.db_type === "redshift") return "dev";
if (form.value.db_type === "gaussdb") return "postgres";
if (form.value.db_type === "kwdb") return "defaultdb";
if (form.value.db_type === "databend") return "default";
if (selectedType.value === "cockroachdb") return "defaultdb";
if (form.value.db_type === "highgo") return "highgo";
if (form.value.db_type === "yashandb") return "yasdb";
@@ -636,6 +638,7 @@ const iconTypeMap: Record<string, string> = {
oceanbase: "oceanbase",
"oceanbase-oracle": "oceanbase",
goldendb: "goldendb",
databend: "databend",
tdsql: "tdsql",
polardb: "polardb",
greatsql: "greatsql",
@@ -699,6 +702,7 @@ const dbOptions = [
{ value: "tidb", label: "TiDB" },
{ value: "oceanbase", label: "OceanBase" },
{ value: "goldendb", label: "GoldenDB" },
{ value: "databend", label: "Databend" },
{ value: "tdsql", label: "TDSQL" },
{ value: "polardb", label: "PolarDB" },
{ value: "greatsql", label: "GreatSQL" },
@@ -33,6 +33,7 @@ const assetIcons: Record<string, string> = {
kingbase: "kingbase",
highgo: "highgo.png",
goldendb: "goldendb.png",
databend: "databend",
vastbase: "vastbase.png",
yashandb: "yashandb.png",
snowflake: "snowflake",
@@ -117,6 +117,7 @@ import { buildRoutineRenameObjectSourceStatements, supportsSourceBackedRoutineRe
import { buildViewDdl } from "@/lib/viewDdl";
import { getTableStructureCapabilities } from "@/lib/tableStructureCapabilities";
import {
connectionObjectTreeNodeSchema,
connectionObjectTreeQuerySchema,
connectionUsesDatabaseObjectTreeMode,
effectiveDatabaseTypeForConnection,
@@ -753,7 +754,7 @@ async function openData() {
table: node.label,
dbType: config?.db_type,
});
const tableSchema = connectionUsesDatabaseObjectTreeMode(config) ? undefined : node.schema;
const tableSchema = connectionObjectTreeNodeSchema(config, node.database, node.schema);
const tabId = (() => {
if (settingsStore.editorSettings.reuseDataTab) {
const existing = queryStore.tabs.find(
@@ -25,6 +25,7 @@ export const SCHEMA_AWARE_TYPES = new Set<DatabaseType>([
"snowflake",
"trino",
"hive",
"databend",
"db2",
"tdengine",
"xugu",
@@ -242,6 +243,7 @@ export const AGENT_DRIVER_TYPES = new Set<DatabaseType>([
"vastbase",
"yashandb",
"goldendb",
"databend",
"databricks",
"saphana",
"teradata",
+9
View File
@@ -2,6 +2,7 @@ import type { ConnectionConfig, DatabaseType } from "@/types/database";
import { isSchemaAware, usesDatabaseObjectTreeMode } from "@/lib/databaseFeatureSupport";
const JDBC_DIALECT_MATCHERS: Array<{ type: DatabaseType; patterns: RegExp[] }> = [
{ type: "databend", patterns: [/jdbc:databend:/i, /com\.databend\.jdbc\.DatabendDriver/i, /databend-jdbc/i] },
{ type: "starrocks", patterns: [/starrocks/i] },
{ type: "doris", patterns: [/doris/i] },
{ type: "hive", patterns: [/org\.apache\.hive\.jdbc\.HiveDriver/i, /hive-jdbc/i] },
@@ -45,6 +46,12 @@ export function connectionUsesDatabaseObjectTreeMode(
return true;
}
export function connectionUsesSchemaExecutionContext(
connection?: Pick<ConnectionConfig, "db_type" | "connection_string" | "jdbc_driver_class" | "jdbc_driver_paths">,
): boolean {
return connection?.db_type === "jdbc" && inferJdbcDialect(connection) === "databend";
}
export function connectionObjectTreeQuerySchema(
connection:
| Pick<ConnectionConfig, "db_type" | "connection_string" | "jdbc_driver_class" | "jdbc_driver_paths">
@@ -52,6 +59,7 @@ export function connectionObjectTreeQuerySchema(
database: string,
schema?: string,
): string {
if (connection?.db_type === "jdbc" && inferJdbcDialect(connection) === "databend") return schema || database;
if (connectionUsesDatabaseObjectTreeMode(connection)) return "";
return schema || database;
}
@@ -63,6 +71,7 @@ export function connectionObjectTreeNodeSchema(
database: string,
schema?: string,
): string | undefined {
if (connection?.db_type === "jdbc" && inferJdbcDialect(connection) === "databend") return schema || database;
if (connectionUsesDatabaseObjectTreeMode(connection)) return undefined;
if (schema) return schema;
const type = connection?.db_type === "jdbc" ? effectiveDatabaseTypeForConnection(connection) : connection?.db_type;
+7 -1
View File
@@ -19,7 +19,13 @@ export interface BuildTableSelectSqlOptions {
export function quoteTableIdentifier(databaseType: DatabaseType | undefined, name: string): string {
if (databaseType === "iotdb") return name;
if (databaseType === "jdbc") return quoteJdbcIdentifier(name);
if (databaseType === "mysql" || databaseType === "hive" || databaseType === "tdengine" || databaseType === "access")
if (
databaseType === "mysql" ||
databaseType === "hive" ||
databaseType === "databend" ||
databaseType === "tdengine" ||
databaseType === "access"
)
return `\`${name.replace(/`/g, "``")}\``;
if (databaseType === "informix" && /^[A-Za-z_][A-Za-z0-9_$]*$/.test(name)) return name;
if (databaseType === "neo4j") return quoteCypherIdentifier(name);
+10 -3
View File
@@ -30,7 +30,11 @@ import { editablePrimaryKeys } from "@/lib/tableEditing";
import { TABLE_DATA_EXPORT_PAGE_SIZE } from "@/lib/tableDataExport";
import { tableMetaForDataTab } from "@/lib/tableDataTabMeta";
import { quoteTableIdentifier } from "@/lib/tableSelectSql";
import { connectionUsesDatabaseObjectTreeMode, effectiveDatabaseTypeForConnection } from "@/lib/jdbcDialect";
import {
connectionUsesDatabaseObjectTreeMode,
connectionUsesSchemaExecutionContext,
effectiveDatabaseTypeForConnection,
} from "@/lib/jdbcDialect";
import { queryTimeoutSecsForConnection } from "@/lib/queryTimeout";
import { clearDataGridPendingSnapshotsForTab } from "@/composables/useDataGridEditor";
import {
@@ -1161,8 +1165,11 @@ export const useQueryStore = defineStore("query", () => {
...(clientSessionId ? { clientSessionId } : {}),
timeoutSecs: queryTimeoutSecs,
};
const executionSchema =
tab.mode === "data" || connectionUsesDatabaseObjectTreeMode(conn) ? undefined : tab.schema;
const executionSchema = connectionUsesSchemaExecutionContext(conn)
? tab.schema || tab.database
: tab.mode === "data" || connectionUsesDatabaseObjectTreeMode(conn)
? undefined
: tab.schema;
const executionPromise = api.executeMulti(
tab.connectionId,
tab.database,
+1
View File
@@ -12,6 +12,7 @@ export type DatabaseType =
| "elasticsearch"
| "doris"
| "starrocks"
| "databend"
| "redshift"
| "dameng"
| "gaussdb"