Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix: column catalog (#15002)

ecmadao91d3e9b4c361
diff --git a/frontend/src/components/ColumnDataTable/utils.ts b/frontend/src/components/ColumnDataTable/utils.ts
index d5664b0c1c..df5741d2a8 100644
--- a/frontend/src/components/ColumnDataTable/utils.ts
+++ b/frontend/src/components/ColumnDataTable/utils.ts
@@ -3,8 +3,10 @@ import { t } from "@/plugins/i18n";
import { pushNotification, useDatabaseCatalogV1Store } from "@/store";
import { Engine } from "@/types/proto/v1/common";
import {
+ SchemaCatalog,
ColumnCatalog,
TableCatalog,
+ TableCatalog_Columns,
} from "@/types/proto/v1/database_catalog_service";
export const supportClassificationFromCommentFeature = (engine: Engine) => {
@@ -46,15 +48,21 @@ export const updateColumnConfig = async ({
(s) => s.name === schema
);
if (!targetSchema) {
- targetSchema = { name: schema, tables: [] };
+ targetSchema = SchemaCatalog.fromPartial({ name: schema, tables: [] });
pendingUpdateCatalog.schemas.push(targetSchema);
}
let targetTable = targetSchema.tables.find((t) => t.name === table);
if (!targetTable) {
- targetTable = TableCatalog.fromPartial({ name: table });
+ targetTable = TableCatalog.fromPartial({
+ name: table,
+ columns: TableCatalog_Columns.fromPartial({}),
+ });
targetSchema.tables.push(targetTable);
}
+ if (!targetTable.columns) {
+ targetTable.columns = TableCatalog_Columns.fromPartial({});
+ }
const columns = targetTable.columns?.columns || [];
const columnIndex = columns.findIndex((c) => c.name === column);
diff --git a/frontend/src/components/SchemaEditorLite/Panels/TableColumnEditor/components/SemanticTypeCell.vue b/frontend/src/components/SchemaEditorLite/Panels/TableColumnEditor/components/SemanticTypeCell.vue
index 6efb7157ca..5fda1e79f9 100644
--- a/frontend/src/components/SchemaEditorLite/Panels/TableColumnEditor/components/SemanticTypeCell.vue
+++ b/frontend/src/components/SchemaEditorLite/Panels/TableColumnEditor/components/SemanticTypeCell.vue
@@ -1,6 +1,7 @@
<template>
<div class="flex flex-row flex-wrap whitespace-nowrap">
- {{ semanticType?.title }}
+ <span v-if="semanticType?.title">{{ semanticType?.title }}</span>
+ <span v-else class="text-control-placeholder italic">N/A</span>
<template v-if="!readonly && !disabled">
<MiniActionButton
v-if="semanticType"
@@ -52,6 +53,7 @@ defineEmits<{
const { getColumnConfig } = useSchemaEditorContext();
const columnConfig = computed(() => {
+ // TODO: use catalog
return getColumnConfig(props.db, {
database: props.database,
schema: props.schema,
diff --git a/frontend/src/components/SchemaEditorLite/context/config.ts b/frontend/src/components/SchemaEditorLite/context/config.ts
index aec3769c6e..67667edcdc 100644
--- a/frontend/src/components/SchemaEditorLite/context/config.ts
+++ b/frontend/src/components/SchemaEditorLite/context/config.ts
@@ -64,7 +64,7 @@ export const useEditConfigs = (targets: Ref<EditTarget[]>) => {
Object.assign(maps, buildMaps(targets));
},
{
- deep: false,
+ deep: true,
}
);
diff --git a/frontend/src/components/SchemaTemplate/FieldTemplateTable.vue b/frontend/src/components/SchemaTemplate/FieldTemplateTable.vue
index 46e5c11be9..b1e722955c 100644
--- a/frontend/src/components/SchemaTemplate/FieldTemplateTable.vue
+++ b/frontend/src/components/SchemaTemplate/FieldTemplateTable.vue
@@ -14,6 +14,15 @@
<EngineIcon :engine="item.engine" custom-class="ml-0 mr-1" />
{{ item.column?.name }}
</div>
+ <div class="bb-grid-cell flex gap-x-1">
+ {{
+ item.catalog?.semanticType
+ ? (semanticTypeList.find(
+ (data) => data.id === item.catalog?.semanticType
+ )?.title ?? "N/A")
+ : "N/A"
+ }}
+ </div>
<div v-if="classificationConfig" class="bb-grid-cell flex gap-x-1">
<ClassificationLevelBadge
:classification="item.catalog?.classification"
@@ -100,6 +109,11 @@ const columnList = computed((): BBGridColumn[] => {
width: "minmax(min-content, auto)",
class: "capitalize",
},
+ {
+ title: t("settings.sensitive-data.semantic-types.table.semantic-type"),
+ width: "minmax(min-content, auto)",
+ class: "capitalize",
+ },
{
title: t("schema-template.classification.self"),
width: "minmax(min-content, auto)",
@@ -164,4 +178,11 @@ const deleteTemplate = async (id: string) => {
});
}
};
+
+const semanticTypeList = computed(() => {
+ return (
+ settingStore.getSettingByName("bb.workspace.semantic-types")?.value
+ ?.semanticTypeSettingValue?.types ?? []
+ );
+});
</script>
diff --git a/frontend/src/components/SchemaTemplate/TableTemplateForm.vue b/frontend/src/components/SchemaTemplate/TableTemplateForm.vue
index a070ef7f3b..6f07224911 100644
--- a/frontend/src/components/SchemaTemplate/TableTemplateForm.vue
+++ b/frontend/src/components/SchemaTemplate/TableTemplateForm.vue
@@ -111,6 +111,7 @@
{{ $t("schema-editor.actions.add-from-template") }}
</NButton>
</div>
+
<TableColumnEditor
:readonly="!!readonly"
:show-foreign-key="false"
@@ -206,13 +207,12 @@ import {
pushNotification,
} from "@/store";
import { unknownProject } from "@/types";
-import {
- ColumnMetadata,
-} from "@/types/proto/v1/database_service";
import {
SchemaCatalog,
TableCatalog,
+ TableCatalog_Columns,
} from "@/types/proto/v1/database_catalog_service";
+import { ColumnMetadata } from "@/types/proto/v1/database_service";
import {
SchemaTemplateSetting_TableTemplate,
type SchemaTemplateSetting_FieldTemplate,
@@ -308,6 +308,7 @@ const tableClassificationId = computed({
tableCatalog = TableCatalog.fromPartial({
name: table.name,
classification: id,
+ columns: TableCatalog_Columns.fromPartial({}),
});
schemaCatalog.tables.push(tableCatalog);
}
diff --git a/frontend/src/store/modules/v1/databaseCatalog.ts b/frontend/src/store/modules/v1/databaseCatalog.ts
index 2999cdd267..e42a89af01 100644
--- a/frontend/src/store/modules/v1/databaseCatalog.ts
+++ b/frontend/src/store/modules/v1/databaseCatalog.ts
@@ -8,6 +8,7 @@ import {
ColumnCatalog,
DatabaseCatalog,
TableCatalog,
+ TableCatalog_Columns,
} from "@/types/proto/v1/database_catalog_service";
import { extractDatabaseResourceName, hasProjectPermissionV2 } from "@/utils";
import { useDatabaseV1Store } from "./database";
@@ -138,6 +139,7 @@ export const getTableCatalog = (
schemaCatalog?.tables.find((t) => t.name === table) ??
TableCatalog.fromPartial({
name: table,
+ columns: TableCatalog_Columns.fromPartial({}),
})
);
};
@@ -148,10 +150,7 @@ export const getColumnCatalog = (
table: string,
column: string
) => {
- const schemaConfig = catalog.schemas.find((s) => s.name === schema);
- const tableCatalog =
- schemaConfig?.tables.find((t) => t.name === table) ??
- TableCatalog.fromPartial({});
+ const tableCatalog = getTableCatalog(catalog, schema, table);
return (
tableCatalog.columns?.columns.find((c) => c.name === column) ??
ColumnCatalog.fromPartial({