feat(transwarp): add Inceptor data source with table operations
This commit is contained in:
1 parent
597b134d21
commit
6fdc338348
101 files changed
+2300
-66
No files matched your search
@@ -0,0 +1,25 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { parseConnectionUrl } from "@/lib/connection/connectionUrl";
|
||||
|
||||
describe("Transwarp JDBC URL parsing", () => {
|
||||
it("keeps the selected product when the SDK uses its other compatible URL", () => {
|
||||
const inceptor = parseConnectionUrl("jdbc:inceptor2://quark:10000/default;fetchSize=200", "transwarp-inceptor");
|
||||
expect(inceptor).toMatchObject({
|
||||
dbType: "transwarp",
|
||||
driverProfile: "transwarp-inceptor",
|
||||
host: "quark",
|
||||
port: 10000,
|
||||
database: "default",
|
||||
urlParams: "fetchSize=200",
|
||||
});
|
||||
expect(parseConnectionUrl("jdbc:transwarp2://quark:10000/default").driverProfile).toBe("transwarp-inceptor");
|
||||
});
|
||||
|
||||
it("detects Inceptor URLs without an existing product selection", () => {
|
||||
expect(parseConnectionUrl("jdbc:inceptor2://quark:10000/default")).toMatchObject({
|
||||
dbType: "transwarp",
|
||||
driverProfile: "transwarp-inceptor",
|
||||
});
|
||||
expect(parseConnectionUrl("jdbc:hive2://quark:10000/default").dbType).toBe("hive");
|
||||
});
|
||||
});
|
||||
@@ -59,6 +59,11 @@ describe("connectionUrlCopyFormats", () => {
|
||||
const formats = connectionUrlCopyFormats(config({ db_type: "hive", host: "hive.example.com", port: 10000, database: "dw" }));
|
||||
expect(formats).toEqual(["jdbcUrl", "jdbcUrlWithCredentials", "hostPort"]);
|
||||
});
|
||||
|
||||
it("uses semicolon options when copying an Inceptor JDBC URL", () => {
|
||||
const transwarp = config({ db_type: "transwarp", host: "quark.example.com", port: 10000, database: "default", username: "", password: "", url_params: "fetchSize=500" });
|
||||
expect(buildConnectionUrlCopy(transwarp, "jdbcUrl")).toBe("jdbc:inceptor2://quark.example.com:10000/default;fetchSize=500");
|
||||
});
|
||||
});
|
||||
|
||||
describe("buildConnectionUrlCopy standard URL", () => {
|
||||
|
||||
@@ -33,4 +33,11 @@ describe("database namespace creation targets", () => {
|
||||
expect(connectionNamespaceCreationTarget(postgres)).toBe("database");
|
||||
expect(databaseNodeNamespaceCreationTarget(postgres, databaseNode)).toBe("schema");
|
||||
});
|
||||
|
||||
it("offers top-level database creation for Inceptor without nested schemas", () => {
|
||||
const transwarp = { db_type: "transwarp", driver_profile: "transwarp-inceptor" } as Conn;
|
||||
|
||||
expect(connectionNamespaceCreationTarget(transwarp)).toBe("database");
|
||||
expect(databaseNodeNamespaceCreationTarget(transwarp, databaseNode)).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -667,6 +667,7 @@ describe("splitSqlStatementRanges", () => {
|
||||
expect(rangeSqlTexts(splitSqlStatementRanges(argoProcedureFixture, "argo"))).toEqual([argoProcedureFixture]);
|
||||
expect(hasMultipleExecutionTargets(argoProcedureFixture, "argo")).toBe(false);
|
||||
expect(rangeSqlTexts(executableStatementRanges(argoProcedureFixture, "argo"))).toEqual([argoProcedureFixture]);
|
||||
expect(rangeSqlTexts(splitSqlStatementRanges(argoProcedureFixture, "transwarp"))).toEqual([argoProcedureFixture]);
|
||||
});
|
||||
|
||||
it("statement at cursor inside an ArgoDB procedure body returns the whole definition", () => {
|
||||
|
||||
@@ -1,6 +1,16 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { databaseRenameMaintenanceDatabase, supportsDatabaseRename } from "@/lib/table/objectRenameSql";
|
||||
import { databaseRenameMaintenanceDatabase, supportsDatabaseRename, supportsObjectRename } from "@/lib/table/objectRenameSql";
|
||||
|
||||
describe("Inceptor object rename", () => {
|
||||
it("exposes table rename without enabling unsupported object or database renames", () => {
|
||||
expect(supportsObjectRename("transwarp", "TABLE")).toBe(true);
|
||||
expect(supportsObjectRename("transwarp", "VIEW")).toBe(false);
|
||||
expect(supportsObjectRename("transwarp", "PROCEDURE")).toBe(false);
|
||||
expect(supportsObjectRename("transwarp", "FUNCTION")).toBe(false);
|
||||
expect(supportsDatabaseRename("transwarp")).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("database rename", () => {
|
||||
it("chooses a maintenance database outside the rename target", () => {
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
editablePrimaryKeys,
|
||||
editableRowIdentifierColumns,
|
||||
hasCompleteTdengineRowIdentity,
|
||||
hiveTablePropertiesIndicateTransactional,
|
||||
isClickHouseExistingRowReadonlyColumn,
|
||||
isHiddenGridColumn,
|
||||
isSalesforceExistingRowReadonlyColumn,
|
||||
@@ -45,6 +46,17 @@ function index(columns: string[], isUnique = true, filter: string | null = null)
|
||||
}
|
||||
|
||||
describe("tableEditing", () => {
|
||||
it("allows Inceptor inserts but only edits existing rows in transactional tables", () => {
|
||||
expect(isTableDataEditable("transwarp", [], "TABLE")).toBe(true);
|
||||
expect(isTableDataEditable("transwarp", [], "VIEW")).toBe(false);
|
||||
expect(canInsertTableRows("transwarp")).toBe(true);
|
||||
expect(canEditExistingTableRows("transwarp", false)).toBe(false);
|
||||
expect(canEditExistingTableRows("transwarp", true)).toBe(true);
|
||||
expect(supportsDataGridTransaction("transwarp")).toBe(true);
|
||||
expect(hiveTablePropertiesIndicateTransactional({ rows: [["transactional", "true"]] })).toBe(true);
|
||||
expect(hiveTablePropertiesIndicateTransactional({ rows: [["true"]] })).toBe(true);
|
||||
expect(hiveTablePropertiesIndicateTransactional({ rows: [["false"]] })).toBe(false);
|
||||
});
|
||||
it("synthesizes ROWID only for Oracle-compatible base tables", () => {
|
||||
expect(editablePrimaryKeys("oracle", [column("ID"), column("NAME")])).toEqual([]);
|
||||
expect(editablePrimaryKeys("oracle", [column("ID"), column("NAME")], "VIEW")).toEqual([]);
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { buildInceptorCreateOptions, emptyTablePhysicalOptions, hasTablePhysicalOptions, pruneTablePhysicalOptions, restoreTablePhysicalOptions } from "@/lib/table/tablePhysicalOptions";
|
||||
|
||||
const columns = [
|
||||
{ id: "first", name: "id" },
|
||||
{ id: "second", name: "day" },
|
||||
{ id: "third", name: "label" },
|
||||
];
|
||||
|
||||
describe("table physical options", () => {
|
||||
it("restores a saved draft without sharing its column selections", () => {
|
||||
const saved = { physicalOptions: { partitionColumnIds: ["second"], distributionColumnIds: ["first"], bucketCount: "2", storageFormat: "ORC", transactional: true } };
|
||||
const restored = restoreTablePhysicalOptions(saved);
|
||||
expect(restored).toMatchObject({ partitionColumnIds: ["second"], distributionColumnIds: ["first"], bucketCount: "2", storageFormat: "ORC", transactional: true });
|
||||
expect(restored.partitionColumnIds).not.toBe(saved.physicalOptions.partitionColumnIds);
|
||||
expect(restored.distributionColumnIds).not.toBe(saved.physicalOptions.distributionColumnIds);
|
||||
expect(restoreTablePhysicalOptions({})).toEqual(emptyTablePhysicalOptions());
|
||||
expect(hasTablePhysicalOptions(restored)).toBe(true);
|
||||
expect(hasTablePhysicalOptions(emptyTablePhysicalOptions())).toBe(false);
|
||||
});
|
||||
|
||||
it("uses the current column name after a selected column is renamed", () => {
|
||||
const draft = { ...emptyTablePhysicalOptions(), partitionColumnIds: ["second"], distributionColumnIds: ["first"], bucketCount: "2", storageFormat: "ORC", transactional: true };
|
||||
const renamed = columns.map((column) => (column.id === "second" ? { ...column, name: "event_day" } : column));
|
||||
expect(buildInceptorCreateOptions(draft, renamed)).toEqual({
|
||||
partitionColumns: ["event_day"],
|
||||
bucketColumns: ["id"],
|
||||
bucketCount: 2,
|
||||
storageFormat: "ORC",
|
||||
transactional: true,
|
||||
});
|
||||
expect(pruneTablePhysicalOptions(draft, new Set(["first", "third"]))).toMatchObject({ partitionColumnIds: [], distributionColumnIds: ["first"] });
|
||||
});
|
||||
|
||||
it("keeps an invalid bucket count in the SQL builder's validation path", () => {
|
||||
const draft = { ...emptyTablePhysicalOptions(), distributionColumnIds: ["first"], bucketCount: "1.5" };
|
||||
expect(buildInceptorCreateOptions(draft, columns).bucketCount).toBe(0);
|
||||
});
|
||||
});
|
||||
@@ -110,6 +110,21 @@ describe("tableStructureCapabilities", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("enables only the verified Inceptor column structure operations", () => {
|
||||
expect(getTableStructureCapabilities("transwarp", "transwarp")).toMatchObject({
|
||||
dialect: "mysql",
|
||||
alterStrategy: "direct",
|
||||
createTable: true,
|
||||
addColumn: true,
|
||||
dropColumn: false,
|
||||
renameColumn: true,
|
||||
alterExistingColumn: true,
|
||||
comment: true,
|
||||
createIndex: false,
|
||||
foreignKey: false,
|
||||
});
|
||||
});
|
||||
|
||||
it("uses local-only column reordering for editable databases without physical reorder support", () => {
|
||||
for (const databaseType of ["sqlserver", "postgres", "sqlite", "oracle", "dameng", "duckdb", "informix"] as const) {
|
||||
expect(supportsLocalTableColumnReorder(databaseType, databaseType)).toBe(true);
|
||||
|
||||
@@ -28,6 +28,16 @@ describe("HiveServer2-compatible driver installation", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("Transwarp driver installation", () => {
|
||||
it("routes the single Inceptor profile to the shared Agent package", () => {
|
||||
const profile = "transwarp-inceptor";
|
||||
expect(agentDriverInstallKey("transwarp", profile)).toBe("transwarp");
|
||||
expect(showAgentDriverInstallHint("transwarp", [], profile)).toBe(true);
|
||||
expect(showAgentDriverInstallHint("transwarp", [{ db_type: "transwarp", installed: true }], profile)).toBe(false);
|
||||
expect(driverStoreFocusForInstallError("transwarp driver is not installed. Please install it from the Driver Manager.", "transwarp", profile)).toEqual({ target: "driver", driver: "transwarp" });
|
||||
});
|
||||
});
|
||||
|
||||
describe("shouldApplyDriverStoreFocus", () => {
|
||||
it("applies when the driver first appears after a list load", () => {
|
||||
expect(shouldApplyDriverStoreFocus(null, "driver:mysql", false)).toBe(true);
|
||||
|
||||
@@ -110,6 +110,7 @@ describe("AGENT_DRIVER_CATEGORY_MAP integrity", () => {
|
||||
"oceanbase-oracle",
|
||||
"oscar",
|
||||
"sundb",
|
||||
"transwarp",
|
||||
"uxdb",
|
||||
"vastbase",
|
||||
"xugu",
|
||||
|
||||
@@ -37,6 +37,7 @@ export function agentDriverInstallKey(dbType: DatabaseType | undefined, driverPr
|
||||
if (dbType === "kyuubi" || dbType === "impala") return "hive";
|
||||
if (dbType === "oracle") return "oracle";
|
||||
if (dbType === "h2") return "h2";
|
||||
if (dbType === "transwarp") return "transwarp";
|
||||
if (dbType === "mongodb") return "mongodb";
|
||||
if (dbType === "dameng") return "dameng";
|
||||
if (dbType === "gbase") return driverProfile === "gbase8s" ? "gbase8s" : "gbase8a";
|
||||
|
||||
@@ -35,6 +35,7 @@ const DRIVER_STARTUP_FLOOR_TYPES = new Set<DatabaseType>([
|
||||
"kyuubi",
|
||||
"impala",
|
||||
"argo",
|
||||
"transwarp",
|
||||
"spark",
|
||||
"db2",
|
||||
"informix",
|
||||
|
||||
@@ -265,6 +265,9 @@ export function connectionUrlPlaceholder(dbType: DatabaseType, driverProfile?: s
|
||||
case "iris":
|
||||
return driverProfile === "cache" ? "cache://user:password@host:port/namespace" : "iris://user:password@host:port/namespace";
|
||||
|
||||
case "transwarp":
|
||||
return "jdbc:inceptor2://host:10000/default";
|
||||
|
||||
case "influxdb":
|
||||
return "influxdb://user:password@host:port/database";
|
||||
|
||||
|
||||
@@ -424,8 +424,8 @@ export function connectionProfileForScheme(scheme: string, preferredProfile?: st
|
||||
return SCHEME_PROFILES[normalizedScheme];
|
||||
}
|
||||
|
||||
function parseJdbcHiveUrl(source: string): ParsedConnectionUrl | null {
|
||||
const match = /^jdbc:hive2:\/\/(?<hosts>[^/?#;]+)(?:\/(?<path>[^?#]*))?(?<query>\?[^#]*)?(?<fragment>#.*)?$/i.exec(source);
|
||||
function parseJdbcHiveUrl(source: string, preferredProfile?: string): ParsedConnectionUrl | null {
|
||||
const match = /^jdbc:(?<subprotocol>hive2|inceptor2|transwarp2):\/\/(?<hosts>[^/?#;]+)(?:\/(?<path>[^?#]*))?(?<query>\?[^#]*)?(?<fragment>#.*)?$/i.exec(source);
|
||||
if (!match?.groups) return null;
|
||||
|
||||
const firstHost = match.groups.hosts.split(",")[0]?.trim();
|
||||
@@ -442,11 +442,13 @@ function parseJdbcHiveUrl(source: string): ParsedConnectionUrl | null {
|
||||
const [rawDatabase = "", ...paramParts] = (match.groups.path || "").split(";");
|
||||
const structured = extractHiveStructuredParams(paramParts.join(";"));
|
||||
const urlParams = `${structured.urlParams}${match.groups.query || ""}${match.groups.fragment || ""}`;
|
||||
const profile = preferredProfile === "transwarp-inceptor" ? preferredProfile : match.groups.subprotocol.toLowerCase() === "hive2" ? "hive" : "transwarp-inceptor";
|
||||
const transwarp = profile !== "hive";
|
||||
|
||||
return {
|
||||
dbType: "hive",
|
||||
driverProfile: "hive",
|
||||
driverLabel: "Apache Hive",
|
||||
dbType: transwarp ? "transwarp" : "hive",
|
||||
driverProfile: profile,
|
||||
driverLabel: profile === "transwarp-inceptor" ? "星环Inceptor" : "Apache Hive",
|
||||
host: endpoint.hostname.replace(/^\[(.*)]$/, "$1"),
|
||||
port: endpoint.port ? Number(endpoint.port) : 10000,
|
||||
username: structured.username ?? decodeUrlPart(endpoint.username),
|
||||
@@ -698,7 +700,7 @@ export function parseConnectionUrl(value: string, preferredProfile?: string): Pa
|
||||
if (/^jdbc:oceanbase:(?:oracle:)?loadbalance:\/\//i.test(input)) {
|
||||
throw new Error("Unsupported OceanBase JDBC URL variant: loadbalance");
|
||||
}
|
||||
const jdbcHive = parseJdbcHiveUrl(input);
|
||||
const jdbcHive = parseJdbcHiveUrl(input, preferredProfile);
|
||||
if (jdbcHive) return jdbcHive;
|
||||
const jdbcH2 = parseH2JdbcUrl(input);
|
||||
if (jdbcH2) return jdbcH2;
|
||||
|
||||
@@ -100,6 +100,7 @@ const JDBC_URL_PREFIXES: Partial<Record<DatabaseType, string>> = {
|
||||
hive: "jdbc:hive2",
|
||||
kyuubi: "jdbc:hive2",
|
||||
argo: "jdbc:hive2",
|
||||
transwarp: "jdbc:inceptor2",
|
||||
impala: "jdbc:impala",
|
||||
trino: "jdbc:trino",
|
||||
prestosql: "jdbc:presto",
|
||||
@@ -353,6 +354,12 @@ function buildSpecialJdbcUrl(config: ConnectionUrlCopyConfig, database: string,
|
||||
const query = joinNonEmpty("&", [database && `db=${database}`, ...credentials, rawParams.replace(/^[?&]+/, "")]);
|
||||
return `jdbc:snowflake://${formatHostForUrl(host)}/${query ? `?${query}` : ""}`;
|
||||
}
|
||||
case "transwarp": {
|
||||
const portPart = shouldAppendPort(config) ? `:${config.port}` : "";
|
||||
const props = rawParams.replace(/^[?&;]+/, "").replace(/&/g, ";");
|
||||
const ssl = config.ssl && !queryHasParam(props, ["ssl"]) ? ";ssl=true" : "";
|
||||
return `jdbc:inceptor2://${formatHostForUrl(host)}${portPart}/${database || "default"}${props ? `;${props}` : ""}${ssl}`;
|
||||
}
|
||||
case "informix":
|
||||
case "gbase": {
|
||||
const prefix = config.db_type === "informix" ? "jdbc:informix-sqli" : jdbcPrefixFor(config);
|
||||
|
||||
@@ -61,6 +61,7 @@ export const AGENT_DRIVER_CATEGORY_MAP: Readonly<Record<string, DriverCategoryKe
|
||||
sundb: "domestic",
|
||||
tdengine: "timeseries",
|
||||
teradata: "analytics",
|
||||
transwarp: "domestic",
|
||||
trino: "analytics",
|
||||
uxdb: "domestic",
|
||||
vastbase: "domestic",
|
||||
|
||||
@@ -134,6 +134,7 @@ export interface DataGridConditionalUpdateSqlOptions {
|
||||
}
|
||||
|
||||
export interface HiveTablePropertiesSqlOptions {
|
||||
databaseType?: DatabaseType;
|
||||
schema?: string;
|
||||
tableName: string;
|
||||
propertyName: string;
|
||||
|
||||
@@ -4,7 +4,7 @@ import { manifestDatabaseTypes } from "@/lib/database/databaseDriverManifest";
|
||||
import { supportsTransfer } from "@/lib/database/databaseFeatureSupport";
|
||||
import type { DatabaseType } from "@/types/database";
|
||||
|
||||
const TABLE_ONLY_TRANSFER_DATABASES: DatabaseType[] = ["sqlite", "rqlite", "turso", "cloudflare-d1", "duckdb", "clickhouse", "mongodb", "highgo", "vastbase", "goldendb", "yashandb", "questdb", "h2", "hive", "argo", "kyuubi", "impala", "spark"];
|
||||
const TABLE_ONLY_TRANSFER_DATABASES: DatabaseType[] = ["sqlite", "rqlite", "turso", "cloudflare-d1", "duckdb", "clickhouse", "mongodb", "highgo", "vastbase", "goldendb", "yashandb", "questdb", "h2", "hive", "argo", "transwarp", "kyuubi", "impala", "spark"];
|
||||
|
||||
describe("transferObjectKinds", () => {
|
||||
it("groups databases into transfer families", () => {
|
||||
|
||||
@@ -70,6 +70,7 @@ export const DATABASE_NAMESPACE_CREATION_MATRIX = {
|
||||
prestosql: { database: "schema" },
|
||||
hive: { deferred: "Hive database creation needs agent metadata validation first" },
|
||||
argo: { deferred: "ArgoDB database creation needs agent metadata validation first" },
|
||||
transwarp: { connection: "database" },
|
||||
kyuubi: { deferred: "Kyuubi database creation needs dedicated metadata validation first" },
|
||||
impala: { deferred: "Impala database creation needs dedicated metadata validation first" },
|
||||
spark: { deferred: "Spark database creation needs agent metadata validation first" },
|
||||
|
||||
@@ -80,6 +80,7 @@ const DATABASE_TYPE_OBJECTS = new Map<DatabaseType, SidebarObjectKind[]>([
|
||||
// ArgoDB (Transwarp) shares the Hive agent; its catalog views
|
||||
// (system.procedures_v / system.functions_v) expose routines natively.
|
||||
["argo", ROUTINE_OBJECTS],
|
||||
["transwarp", ["TABLE", "VIEW", "PROCEDURE", "FUNCTION", "PACKAGE", "PACKAGE_BODY"]],
|
||||
["kyuubi", TABLE_VIEW_OBJECTS],
|
||||
["impala", TABLE_VIEW_OBJECTS],
|
||||
["spark", TABLE_VIEW_OBJECTS],
|
||||
|
||||
@@ -71,6 +71,7 @@ export const DATABASE_PROPERTY_EDITING_MATRIX = {
|
||||
prestosql: { deferred: "catalog properties are connector-managed" },
|
||||
hive: { deferred: "database properties need agent metadata validation first" },
|
||||
argo: { deferred: "database properties need agent metadata validation first" },
|
||||
transwarp: { deferred: "database properties need server validation first" },
|
||||
kyuubi: { deferred: "database properties need Kyuubi-specific validation first" },
|
||||
impala: { deferred: "database properties need Impala-specific validation first" },
|
||||
spark: { deferred: "database properties need agent metadata validation first" },
|
||||
|
||||
@@ -133,6 +133,16 @@ const DATABASE_CAPABILITY_OVERRIDES: Partial<Record<DatabaseType, Partial<Databa
|
||||
transaction: false,
|
||||
},
|
||||
},
|
||||
transwarp: {
|
||||
tableData: {
|
||||
insert: true,
|
||||
updateRequiresPrimaryKey: false,
|
||||
deleteRequiresPrimaryKey: false,
|
||||
keylessRowPredicate: true,
|
||||
requiresTransactionalTableForExistingRows: true,
|
||||
transaction: true,
|
||||
},
|
||||
},
|
||||
jdbc: {
|
||||
tableData: {
|
||||
insert: false,
|
||||
|
||||
@@ -15,7 +15,7 @@ const GAUSSDB_COUNT_QUERY_DOP_KEY = "gaussdbCountQueryDop";
|
||||
export const GAUSSDB_M_JDBC_DRIVER_PROFILE = "gaussdb-m";
|
||||
export const GAUSSDB_M_JDBC_DRIVER_CLASS = "com.huawei.gaussdb.jdbc.Driver";
|
||||
|
||||
const DATABASE_AS_EXECUTION_SCHEMA_TYPES = new Set<DatabaseType>(["hive", "kyuubi", "impala", "argo", "spark"]);
|
||||
const DATABASE_AS_EXECUTION_SCHEMA_TYPES = new Set<DatabaseType>(["hive", "kyuubi", "impala", "argo", "transwarp", "spark"]);
|
||||
const CONNECTION_ROOT_SCHEMA_TYPES = new Set<DatabaseType>(["oracle", "dameng", "oceanbase-oracle"]);
|
||||
|
||||
const JDBC_DIALECT_MATCHERS: Array<{ type: DatabaseType; patterns: RegExp[] }> = [
|
||||
|
||||
@@ -14,7 +14,7 @@ const SQLITE_CODEMIRROR_DATABASE_TYPES = new Set<DatabaseType>(["sqlite", "rqlit
|
||||
// literals; the mysql-family types are covered by isMysql at the define() site. Mirrors
|
||||
// BACKSLASH_ESCAPE_STRING_DIALECTS in lib/sql/sqlStatementRanges.ts so the editor
|
||||
// tokenizer and the statement splitter agree on escape semantics per dialect.
|
||||
const BACKSLASH_ESCAPE_CODEMIRROR_DATABASE_TYPES = new Set<DatabaseType>(["hive", "argo", "impala", "spark", "databend"]);
|
||||
const BACKSLASH_ESCAPE_CODEMIRROR_DATABASE_TYPES = new Set<DatabaseType>(["hive", "argo", "transwarp", "impala", "spark", "databend"]);
|
||||
|
||||
const CODEMIRROR_SQLITE_EXTENSION_KEYWORDS = new Set("abort analyze attach autoincrement conflict database detach exclusive fail glob ignore index indexed instead isnull notnull offset plan pragma query raise regexp reindex rename replace temp vacuum virtual".split(" "));
|
||||
const STANDARD_SQL_TYPES = "array binary bit boolean char character clob date decimal double float int integer interval large national nchar nclob numeric object precision real smallint time timestamp varchar varying";
|
||||
|
||||
@@ -4,7 +4,7 @@ import { qualifiedTableName, quoteTableIdentifier } from "@/lib/table/tableSelec
|
||||
import { requiresMysqlIdentifierQuote, requiresPostgresIdentifierQuote } from "@/lib/sql/sqlIdentifier.ts";
|
||||
|
||||
/** 智能引号使用反引号的方言族。 */
|
||||
const SMART_QUOTE_BACKTICK_TYPES = new Set<DatabaseType>(["mysql", "clickhouse", "hive", "argo", "kyuubi", "impala", "spark", "databricks", "databend", "tdengine", "access", "doris", "starrocks", "goldendb"]);
|
||||
const SMART_QUOTE_BACKTICK_TYPES = new Set<DatabaseType>(["mysql", "clickhouse", "hive", "argo", "transwarp", "kyuubi", "impala", "spark", "databricks", "databend", "tdengine", "access", "doris", "starrocks", "goldendb"]);
|
||||
/** 智能引号使用双引号的方言族(SQL Server 方括号除外)。 */
|
||||
const SMART_QUOTE_DOUBLE_TYPES = new Set<DatabaseType>(["postgres", "gaussdb", "opengauss"]);
|
||||
/** SQL Server 族智能引号使用方括号。 */
|
||||
|
||||
@@ -1439,7 +1439,7 @@ type SqlCompletionApplyDialect = "mysql" | "postgres" | "sqlserver" | "oracle" |
|
||||
// QueryEditor may use another dialect as a CodeMirror syntax fallback.
|
||||
// Completion apply text must still follow the connected database's identifier
|
||||
// folding and quoting rules.
|
||||
const MYSQL_LIKE_IDENTIFIER_DATABASES = new Set<DatabaseType>(["mysql", "clickhouse", "hive", "argo", "kyuubi", "impala", "spark", "databend", "tdengine", "access", "doris", "starrocks"]);
|
||||
const MYSQL_LIKE_IDENTIFIER_DATABASES = new Set<DatabaseType>(["mysql", "clickhouse", "hive", "argo", "transwarp", "kyuubi", "impala", "spark", "databend", "tdengine", "access", "doris", "starrocks"]);
|
||||
const POSTGRES_LIKE_IDENTIFIER_DATABASES = new Set<DatabaseType>(["postgres", "redshift", "gaussdb", "kingbase", "highgo", "uxdb", "vastbase", "kwdb", "opengauss"]);
|
||||
export const ORACLE_COMPAT_IDENTIFIER_DATABASES = new Set<DatabaseType>(["oracle", "oceanbase-oracle", "yashandb", "oscar", "xugu"]);
|
||||
const UPPER_FOLDING_IDENTIFIER_DATABASES = new Set<DatabaseType>(["dameng", "db2"]);
|
||||
@@ -3256,7 +3256,7 @@ function lastTopLevelKeywordIndex(sql: string, keyword: string): number {
|
||||
// unquoted token as a table reference there is a false-positive risk. Everything else defaults
|
||||
// to Unicode support (MySQL/Postgres/SQL Server/SQLite/DuckDB and the many Chinese-vendor
|
||||
// engines this product supports legitimately use non-ASCII unquoted identifiers).
|
||||
const ASCII_ONLY_UNQUOTED_IDENTIFIER_DATABASES = new Set<DatabaseType>(["clickhouse", "snowflake", "bigquery", "hive", "argo", "spark", "trino", "prestosql", "impala", "db2", "teradata"]);
|
||||
const ASCII_ONLY_UNQUOTED_IDENTIFIER_DATABASES = new Set<DatabaseType>(["clickhouse", "snowflake", "bigquery", "hive", "argo", "transwarp", "spark", "trino", "prestosql", "impala", "db2", "teradata"]);
|
||||
|
||||
// Dialects where a bare "--" needs trailing whitespace/EOL to start a comment, since MySQL
|
||||
// reserves unspaced "--" for double-negation (e.g. `SELECT 1--1`). Scoped to mysql itself plus
|
||||
|
||||
@@ -293,7 +293,7 @@ const SET_OPERATION_MODIFIER_KEYWORDS = new Set(["ALL", "DISTINCT"]);
|
||||
// in sync. ArgoDB (Transwarp Hive/Inceptor fork) ships a PL/SQL-compatible procedure
|
||||
// language (`CREATE [OR REPLACE] PROCEDURE ... IS BEGIN ... END;`), so its statement
|
||||
// ranges must stay whole instead of splitting at every body semicolon.
|
||||
const ORACLE_LIKE_PL_SQL_DATABASES: ReadonlySet<DatabaseType> = new Set(["oracle", "dameng", "gaussdb", "yashandb", "oscar", "oceanbase-oracle", "xugu", "argo"]);
|
||||
const ORACLE_LIKE_PL_SQL_DATABASES: ReadonlySet<DatabaseType> = new Set(["oracle", "dameng", "gaussdb", "yashandb", "oscar", "oceanbase-oracle", "xugu", "argo", "transwarp"]);
|
||||
const MYSQL_ROUTINE_BLOCK_DATABASES: ReadonlySet<DatabaseType> = new Set(["mysql", "doris", "starrocks", "manticoresearch", "goldendb"]);
|
||||
// PostgreSQL/openGauss are also the connection types users pick for GaussDB/openGauss instances
|
||||
// running in Oracle (A) compatibility mode, where a routine body is written in Oracle style
|
||||
@@ -305,7 +305,7 @@ const POSTGRES_FAMILY_DATABASES: ReadonlySet<DatabaseType> = new Set(["postgres"
|
||||
// escape unconditionally makes ESCAPE '\' swallow its closing quote and the following statement
|
||||
// boundary, so the next statement loses its run button (#8189). Gate it by dialect, matching the
|
||||
// tokenizer/completion side.
|
||||
export const BACKSLASH_ESCAPE_STRING_DIALECTS: ReadonlySet<DatabaseType> = new Set(["mysql", "doris", "starrocks", "hive", "argo", "impala", "spark", "databend"]);
|
||||
export const BACKSLASH_ESCAPE_STRING_DIALECTS: ReadonlySet<DatabaseType> = new Set(["mysql", "doris", "starrocks", "hive", "argo", "transwarp", "impala", "spark", "databend"]);
|
||||
function allowsBackslashStringEscape(databaseType?: DatabaseType): boolean {
|
||||
return !!databaseType && BACKSLASH_ESCAPE_STRING_DIALECTS.has(databaseType);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ export function supportsObjectRename(databaseType: DatabaseType | undefined, obj
|
||||
return false;
|
||||
}
|
||||
if (databaseType === "sqlite" || databaseType === "rqlite" || databaseType === "turso" || databaseType === "cloudflare-d1" || databaseType === "duckdb") return objectType === "TABLE";
|
||||
if (databaseType === "transwarp") return objectType === "TABLE";
|
||||
if (databaseType === "mysql" || databaseType === "goldendb") return objectType === "TABLE" || objectType === "VIEW";
|
||||
if (postgresLikeRenameTypes.has(databaseType)) return objectType === "TABLE" || objectType === "VIEW" || objectType === "MATERIALIZED_VIEW";
|
||||
if (oracleLikeRenameTypes.has(databaseType)) return objectType === "TABLE" || objectType === "VIEW" || objectType === "MATERIALIZED_VIEW";
|
||||
|
||||
@@ -92,6 +92,12 @@ export function canDeleteExistingTdengineRows(databaseType: DatabaseType | undef
|
||||
|
||||
export function hiveTablePropertiesIndicateTransactional(result: { rows: readonly (readonly unknown[])[] }): boolean {
|
||||
return result.rows.some((row) => {
|
||||
if (row.length === 1)
|
||||
return (
|
||||
String(row[0] ?? "")
|
||||
.trim()
|
||||
.toLowerCase() === "true"
|
||||
);
|
||||
const name = String(row[0] ?? "")
|
||||
.trim()
|
||||
.toLowerCase();
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
import type { EditableStructureColumn, TranswarpCreateTableOptions } from "@/lib/table/tableStructureEditorSql";
|
||||
|
||||
export interface TablePhysicalOptionsDraft {
|
||||
partitionColumnIds: string[];
|
||||
distributionColumnIds: string[];
|
||||
bucketCount: string;
|
||||
storageFormat: string;
|
||||
transactional: boolean;
|
||||
}
|
||||
|
||||
export interface TablePhysicalOptionsConfig {
|
||||
partitionColumnsLabel: string;
|
||||
distributionColumnsLabel: string;
|
||||
bucketCountLabel: string;
|
||||
storageFormatLabel: string;
|
||||
transactionalLabel?: string;
|
||||
maxBuckets: number;
|
||||
storageFormats: readonly string[];
|
||||
}
|
||||
|
||||
export const INCEPTOR_PHYSICAL_OPTIONS: TablePhysicalOptionsConfig = {
|
||||
partitionColumnsLabel: "structureEditor.transwarpPartitionColumns",
|
||||
distributionColumnsLabel: "structureEditor.transwarpBucketColumns",
|
||||
bucketCountLabel: "structureEditor.transwarpBucketCount",
|
||||
storageFormatLabel: "structureEditor.transwarpStorageFormat",
|
||||
transactionalLabel: "structureEditor.transwarpTransactional",
|
||||
maxBuckets: 4096,
|
||||
storageFormats: ["ORC", "PARQUET", "TEXTFILE"],
|
||||
};
|
||||
|
||||
export function emptyTablePhysicalOptions(): TablePhysicalOptionsDraft {
|
||||
return { partitionColumnIds: [], distributionColumnIds: [], bucketCount: "", storageFormat: "", transactional: false };
|
||||
}
|
||||
|
||||
export function hasTablePhysicalOptions(draft: TablePhysicalOptionsDraft): boolean {
|
||||
return draft.partitionColumnIds.length > 0 || draft.distributionColumnIds.length > 0 || !!draft.bucketCount.trim() || !!draft.storageFormat || draft.transactional;
|
||||
}
|
||||
|
||||
export function pruneTablePhysicalOptions(draft: TablePhysicalOptionsDraft, availableColumnIds: ReadonlySet<string>): TablePhysicalOptionsDraft {
|
||||
const partitionColumnIds = draft.partitionColumnIds.filter((id) => availableColumnIds.has(id));
|
||||
const distributionColumnIds = draft.distributionColumnIds.filter((id) => availableColumnIds.has(id));
|
||||
if (partitionColumnIds.length === draft.partitionColumnIds.length && distributionColumnIds.length === draft.distributionColumnIds.length) return draft;
|
||||
return { ...draft, partitionColumnIds, distributionColumnIds };
|
||||
}
|
||||
|
||||
export function restoreTablePhysicalOptions(saved: { physicalOptions?: TablePhysicalOptionsDraft }): TablePhysicalOptionsDraft {
|
||||
if (!saved.physicalOptions) return emptyTablePhysicalOptions();
|
||||
return {
|
||||
partitionColumnIds: [...saved.physicalOptions.partitionColumnIds],
|
||||
distributionColumnIds: [...saved.physicalOptions.distributionColumnIds],
|
||||
bucketCount: saved.physicalOptions.bucketCount,
|
||||
storageFormat: saved.physicalOptions.storageFormat,
|
||||
transactional: saved.physicalOptions.transactional,
|
||||
};
|
||||
}
|
||||
|
||||
export function buildInceptorCreateOptions(draft: TablePhysicalOptionsDraft, columns: readonly Pick<EditableStructureColumn, "id" | "name">[]): TranswarpCreateTableOptions {
|
||||
const names = (ids: readonly string[]) => ids.map((id) => columns.find((column) => column.id === id)?.name ?? id);
|
||||
const count = draft.bucketCount.trim();
|
||||
const parsedCount = Number(count);
|
||||
return {
|
||||
partitionColumns: names(draft.partitionColumnIds),
|
||||
bucketColumns: names(draft.distributionColumnIds),
|
||||
bucketCount: count ? (Number.isSafeInteger(parsedCount) && parsedCount > 0 && parsedCount <= 4096 ? parsedCount : 0) : undefined,
|
||||
storageFormat: draft.storageFormat || undefined,
|
||||
transactional: draft.transactional,
|
||||
};
|
||||
}
|
||||
@@ -109,6 +109,7 @@ export function quoteTableIdentifier(databaseType: DatabaseType | undefined, nam
|
||||
databaseType === "clickhouse" ||
|
||||
databaseType === "hive" ||
|
||||
databaseType === "argo" ||
|
||||
databaseType === "transwarp" ||
|
||||
databaseType === "kyuubi" ||
|
||||
databaseType === "impala" ||
|
||||
databaseType === "spark" ||
|
||||
@@ -152,6 +153,7 @@ function requiresIdentifierQuote(databaseType: DatabaseType | undefined, name: s
|
||||
case "clickhouse":
|
||||
case "hive":
|
||||
case "argo":
|
||||
case "transwarp":
|
||||
case "kyuubi":
|
||||
case "impala":
|
||||
case "spark":
|
||||
|
||||
@@ -268,6 +268,20 @@ const informixCapabilities = capabilities({
|
||||
rebuildIndex: true,
|
||||
});
|
||||
|
||||
// Inceptor accepts ADD COLUMNS and CHANGE. DROP COLUMN and index/constraint DDL
|
||||
// remain disabled until a safe server-supported form is verified.
|
||||
const transwarpCapabilities = capabilities({
|
||||
dialect: "mysql",
|
||||
createTable: true,
|
||||
addColumn: true,
|
||||
renameColumn: true,
|
||||
alterExistingColumn: true,
|
||||
alterType: true,
|
||||
alterNullability: true,
|
||||
alterDefault: true,
|
||||
comment: true,
|
||||
});
|
||||
|
||||
const accessCapabilities = capabilities({
|
||||
dialect: "h2",
|
||||
createTable: true,
|
||||
@@ -359,6 +373,7 @@ const capabilityByType: Partial<Record<DatabaseType, TableStructureCapabilities>
|
||||
access: accessCapabilities,
|
||||
clickhouse: clickhouseCapabilities,
|
||||
informix: informixCapabilities,
|
||||
transwarp: transwarpCapabilities,
|
||||
influxdb: influxdbCapabilities,
|
||||
manticoresearch: manticoreSearchCapabilities,
|
||||
};
|
||||
|
||||
@@ -90,6 +90,7 @@ export interface BuildTableStructureChangeSqlOptions {
|
||||
tableComment?: string;
|
||||
originalTableComment?: string;
|
||||
mysqlEngine?: string;
|
||||
transwarpCreate?: TranswarpCreateTableOptions;
|
||||
/** MySQL only: the table's current default collation. Columns whose collation merely
|
||||
* matches it inherit the table default, so the backend leaves their redundant
|
||||
* `CHARACTER SET`/`COLLATE` clauses out of the generated DDL. */
|
||||
@@ -103,6 +104,14 @@ export interface BuildTableStructureChangeSqlOptions {
|
||||
isGaussdbMMode?: boolean;
|
||||
}
|
||||
|
||||
export interface TranswarpCreateTableOptions {
|
||||
partitionColumns: string[];
|
||||
bucketColumns: string[];
|
||||
bucketCount?: number;
|
||||
storageFormat?: string;
|
||||
transactional: boolean;
|
||||
}
|
||||
|
||||
export interface TableStructureChangeSql {
|
||||
statements: string[];
|
||||
warnings: string[];
|
||||
|
||||
Reference in new issue
Block a user