feat(hbase): add HBase REST support

This commit is contained in:
zipg authored and GitHub committed 2026-07-28 11:28:02 +08:00
1 parent 1cdbf4fa3d
commit 44cb4acbb7
48 files changed
+2455 -19

No files matched your search

@@ -98,6 +98,7 @@ describe("database property editing", () => {
expect(editableDatabasePropertyGroups({ db_type: "mysql", read_only: true }, { type: "database", database: "app" })).toEqual([]);
expect(editableDatabasePropertyGroups({ db_type: "sqlite" }, { type: "database", database: "main" })).toEqual([]);
expect(editableDatabasePropertyGroups({ db_type: "sqlserver" }, { type: "database", database: "master" })).toEqual([]);
expect(editableDatabasePropertyGroups({ db_type: "hbase" }, { type: "database", database: "default" })).toEqual([]);
expect(editableDatabasePropertyGroups({ db_type: "postgres" }, { type: "connection" })).toEqual([]);
expect(editableSchemaPropertyGroups({ db_type: "postgres", read_only: true }, { type: "schema", database: "postgres", schema: "public" })).toEqual([]);
expect(editableSchemaPropertyGroups({ db_type: "postgres" }, { type: "database", database: "postgres" })).toEqual([]);
@@ -137,6 +138,7 @@ describe("database namespace creation", () => {
expect(connectionNamespaceCreationTarget({ db_type: "sqlite", read_only: true })).toBeNull();
expect(connectionNamespaceCreationTarget({ db_type: "jdbc" })).toBeNull();
expect(connectionNamespaceCreationTarget({ db_type: "oracle" })).toBeNull();
expect(connectionNamespaceCreationTarget({ db_type: "hbase" })).toBeNull();
});
it("allows schema creation only on writable database nodes with schema targets", () => {
@@ -6,6 +6,10 @@ describe("databaseObjectCapabilities", () => {
expect(sidebarObjectKindsForDatabase("dameng")).toContain("MATERIALIZED_VIEW");
});
it("exposes only tables for HBase namespaces", () => {
expect(sidebarObjectKindsForDatabase("hbase")).toEqual(["TABLE"]);
});
it("exposes materialized views for StarRocks only", () => {
// StarRocks has a dedicated MV listing/classification path in
// crates/dbx-core/src/db/mysql.rs (`list_starrocks_tables` +
@@ -0,0 +1,31 @@
import { describe, expect, it } from "vitest";
import { encodeHBaseTextInput, hbaseCellInput } from "@/lib/hbase/hbaseValues";
describe("HBase value conversion", () => {
it("keeps UTF-8 input unchanged", () => {
expect(encodeHBaseTextInput("customer#001")).toEqual({ value: "customer#001", encoding: "utf8" });
expect(hbaseCellInput("profile:name", "Alice")).toEqual({
column: "profile:name",
value: "Alice",
valueEncoding: "utf8",
});
});
it("removes the display prefix before sending Base64 input", () => {
expect(encodeHBaseTextInput("base64:AAEC")).toEqual({ value: "AAEC", encoding: "base64" });
expect(hbaseCellInput("profile:avatar", "base64:AP8=")).toEqual({
column: "profile:avatar",
value: "AP8=",
valueEncoding: "base64",
});
});
it("writes null cells as empty UTF-8 values", () => {
expect(hbaseCellInput("profile:note", null)).toEqual({
column: "profile:note",
value: "",
valueEncoding: "utf8",
});
});
});
+9
View File
@@ -424,6 +424,15 @@ export const zookeeperGet = forward("zookeeperGet");
export const zookeeperPut = forward("zookeeperPut");
export const zookeeperDelete = forward("zookeeperDelete");
// HBase
export const hbaseGetTableSchema = forward("hbaseGetTableSchema");
export const hbaseScanRows = forward("hbaseScanRows");
export const hbaseGetRow = forward("hbaseGetRow");
export const hbasePutRow = forward("hbasePutRow");
export const hbaseDeleteRow = forward("hbaseDeleteRow");
export const hbaseCreateTable = forward("hbaseCreateTable");
export const hbaseDeleteTable = forward("hbaseDeleteTable");
// Message Queue
export const mqTestConnection = forward("mqTestConnection");
export const mqListTenants = forward("mqListTenants");
+32
View File
@@ -2295,6 +2295,38 @@ export async function nacosRawRequest(connectionId: string, req: NacosRawRequest
return post("/api/nacos/raw", { connectionId, req });
}
// ---------------------------------------------------------------------------
// HBase
// ---------------------------------------------------------------------------
export async function hbaseGetTableSchema(connectionId: string, namespace: string, table: string): Promise<import("@/types/hbase").HBaseTableSchema> {
return post("/api/hbase/table-schema", { connectionId, namespace, table });
}
export async function hbaseScanRows(connectionId: string, namespace: string, table: string, rowKeyPrefix: string | undefined, limit: number): Promise<import("@/types/hbase").HBaseScanResult> {
return post("/api/hbase/scan-rows", { connectionId, namespace, table, rowKeyPrefix, limit });
}
export async function hbaseGetRow(connectionId: string, namespace: string, table: string, rowKey: string, rowKeyEncoding?: import("@/types/hbase").HBaseValueEncoding): Promise<import("@/types/hbase").HBaseRow | null> {
return post("/api/hbase/get-row", { connectionId, namespace, table, rowKey, rowKeyEncoding });
}
export async function hbasePutRow(connectionId: string, namespace: string, table: string, input: import("@/types/hbase").HBasePutRowInput): Promise<void> {
return post("/api/hbase/put-row", { connectionId, namespace, table, input });
}
export async function hbaseDeleteRow(connectionId: string, namespace: string, table: string, rowKey: string, rowKeyEncoding?: import("@/types/hbase").HBaseValueEncoding): Promise<void> {
return post("/api/hbase/delete-row", { connectionId, namespace, table, rowKey, rowKeyEncoding });
}
export async function hbaseCreateTable(connectionId: string, namespace: string, table: string, columnFamilies: string[]): Promise<void> {
return post("/api/hbase/create-table", { connectionId, namespace, table, columnFamilies });
}
export async function hbaseDeleteTable(connectionId: string, namespace: string, table: string): Promise<void> {
return post("/api/hbase/delete-table", { connectionId, namespace, table });
}
// ---------------------------------------------------------------------------
// MongoDB
// ---------------------------------------------------------------------------
+29
View File
@@ -2062,6 +2062,35 @@ export async function zookeeperDelete(connectionId: string, key: string): Promis
return invoke("zookeeper_delete", { connectionId, key });
}
// --- HBase ---
export async function hbaseGetTableSchema(connectionId: string, namespace: string, table: string): Promise<import("@/types/hbase").HBaseTableSchema> {
return invoke("hbase_get_table_schema", { connectionId, namespace, table });
}
export async function hbaseScanRows(connectionId: string, namespace: string, table: string, rowKeyPrefix: string | undefined, limit: number): Promise<import("@/types/hbase").HBaseScanResult> {
return invoke("hbase_scan_rows", { connectionId, namespace, table, rowKeyPrefix, limit });
}
export async function hbaseGetRow(connectionId: string, namespace: string, table: string, rowKey: string, rowKeyEncoding?: import("@/types/hbase").HBaseValueEncoding): Promise<import("@/types/hbase").HBaseRow | null> {
return invoke("hbase_get_row", { connectionId, namespace, table, rowKey, rowKeyEncoding });
}
export async function hbasePutRow(connectionId: string, namespace: string, table: string, input: import("@/types/hbase").HBasePutRowInput): Promise<void> {
return invoke("hbase_put_row", { connectionId, namespace, table, input });
}
export async function hbaseDeleteRow(connectionId: string, namespace: string, table: string, rowKey: string, rowKeyEncoding?: import("@/types/hbase").HBaseValueEncoding): Promise<void> {
return invoke("hbase_delete_row", { connectionId, namespace, table, rowKey, rowKeyEncoding });
}
export async function hbaseCreateTable(connectionId: string, namespace: string, table: string, columnFamilies: string[]): Promise<void> {
return invoke("hbase_create_table", { connectionId, namespace, table, columnFamilies });
}
export async function hbaseDeleteTable(connectionId: string, namespace: string, table: string): Promise<void> {
return invoke("hbase_delete_table", { connectionId, namespace, table });
}
// --- Document stores ---
export interface DocumentQueryResult {
documents: any[];
@@ -74,7 +74,7 @@ export function supportsClearableQuerySchema(dbType?: DatabaseType): boolean {
}
export function supportsConnectionQueryActions(dbType?: DatabaseType): boolean {
return dbType !== "nacos";
return dbType !== "nacos" && dbType !== "hbase";
}
export function usesFetchFirst(dbType?: DatabaseType): boolean {
@@ -28,6 +28,7 @@ export const DATABASE_NAMESPACE_CREATION_MATRIX = {
mongodb: { connection: "special" },
oracle: { deferred: "Oracle schemas are users; database creation is not a normal connected DDL action" },
elasticsearch: { deferred: "index creation is not modeled as database creation" },
hbase: { deferred: "namespace creation needs dedicated HBase namespace options" },
qdrant: { deferred: "collection creation is separate from database creation" },
milvus: { deferred: "collection/database lifecycle needs a dedicated vector workflow" },
weaviate: { deferred: "collection creation is separate from database creation" },
@@ -61,6 +61,7 @@ const DATABASE_TYPE_OBJECTS = new Map<DatabaseType, SidebarObjectKind[]>([
["neo4j", TABLE_VIEW_OBJECTS],
// others
["influxdb", ["TABLE"]],
["hbase", ["TABLE"]],
["questdb", ["TABLE", "VIEW", "MATERIALIZED_VIEW"]],
["manticoresearch", ["TABLE", "FUNCTION"]],
["databend", ["TABLE", "VIEW", "PROCEDURE"]],
@@ -29,6 +29,7 @@ export const DATABASE_PROPERTY_EDITING_MATRIX = {
mongodb: { deferred: "database options are not modeled as SQL database properties" },
oracle: { deferred: "Oracle database properties are instance/user/tablespace administration" },
elasticsearch: { deferred: "index settings are not database properties" },
hbase: { deferred: "namespace and table properties need a dedicated HBase workflow" },
qdrant: { deferred: "collection settings are not database properties" },
milvus: { deferred: "collection/database settings need a dedicated vector workflow" },
weaviate: { deferred: "collection settings are not database properties" },
+16
View File
@@ -0,0 +1,16 @@
import type { CellValue } from "@/lib/dataGrid/cellValue";
import type { HBaseCellInput, HBaseValueEncoding } from "@/types/hbase";
export interface HBaseEncodedText {
value: string;
encoding: HBaseValueEncoding;
}
export function encodeHBaseTextInput(value: string): HBaseEncodedText {
return value.startsWith("base64:") ? { value: value.slice(7), encoding: "base64" } : { value, encoding: "utf8" };
}
export function hbaseCellInput(column: string, value: CellValue): HBaseCellInput {
const encoded = encodeHBaseTextInput(value == null ? "" : String(value));
return { column, value: encoded.value, valueEncoding: encoded.encoding };
}
@@ -26,6 +26,12 @@ export type ActiveTabSidebarTarget =
database: string;
collectionName: string;
}
| {
type: "hbase-table";
connectionId: string;
namespace: string;
tableName: string;
}
| {
type: "etcd-root";
connectionId: string;
@@ -112,6 +118,16 @@ export function activeTabSidebarTarget(tab: QueryTab | undefined | null): Active
};
}
if (tab.mode === "hbase") {
if (!tab.sql) return null;
return {
type: "hbase-table",
connectionId: tab.connectionId,
namespace: tab.database,
tableName: tab.sql || tab.title,
};
}
if (tab.mode === "etcd") {
return { type: "etcd-root", connectionId: tab.connectionId };
}
@@ -176,6 +192,10 @@ export function matchesTarget(node: TreeNode, target: ActiveTabSidebarTarget): b
return node.type === "vector-collection" && node.connectionId === target.connectionId && node.database === target.database && node.label === target.collectionName;
}
if (target.type === "hbase-table") {
return node.type === "table" && node.connectionId === target.connectionId && node.database === target.namespace && node.label === target.tableName;
}
if (target.type === "query-context") {
if (target.schema) {
return node.type === "schema" && node.connectionId === target.connectionId && node.database === target.database && node.label === target.schema;
@@ -31,6 +31,12 @@ const capabilityByType: Partial<Record<DatabaseType, Partial<TableMetadataCapabi
triggers: false,
ddl: false,
},
hbase: {
indexes: false,
foreignKeys: false,
triggers: false,
ddl: false,
},
qdrant: {
indexes: false,
foreignKeys: false,
@@ -94,6 +94,10 @@ export function tabDisplayTitle(tab: QueryTab, t: Translate): string {
if (compact) return tab.sql;
return `${tab.sql}@${database}`;
}
if (tab.mode === "hbase" && tab.sql) {
if (compact) return tab.sql;
return `${tab.sql}@${database}`;
}
if (tab.mode === "redis") {
if (compact) return connectionDisplayName(tab.connectionId);
return `${connectionDisplayName(tab.connectionId)}@${database}`;
@@ -148,6 +152,9 @@ export function tabTooltipLines(tab: QueryTab, t: Translate): { label: string; v
if (tab.mode === "vector" && tab.sql) {
lines.push({ label: t("tabs.tooltipCollection"), value: tab.sql });
}
if (tab.mode === "hbase" && tab.sql) {
lines.push({ label: t("tabs.tooltipTable"), value: tab.sql });
}
if (tab.mode === "objects" && tab.objectBrowser?.schema) {
lines.push({ label: t("tabs.tooltipSchema"), value: tab.objectBrowser.schema });
}
@@ -333,6 +340,7 @@ export function tabModeLabel(tab: QueryTab, t: Translate): string {
if (tab.mode === "mongo") return t("tabs.mongo");
if (tab.mode === "mongo-gridfs" || tab.mode === "mongo-bucket") return t("tabs.gridfs");
if (tab.mode === "vector") return t("tabs.vector");
if (tab.mode === "hbase") return "HBase";
if (tab.mode === "redis") return t("tabs.redis");
if (tab.mode === "etcd") return t("tabs.etcd");
if (tab.mode === "etcd-dashboard") return t("tabs.etcdDashboard");