Skip to content

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

chore: column catalog (#14778)

Danny Xu44e5b86e3556
diff --git a/frontend/src/components/ColumnDataTable/LabelsCell.vue b/frontend/src/components/ColumnDataTable/LabelsCell.vue
index a2036ed34a..522a98e278 100644
--- a/frontend/src/components/ColumnDataTable/LabelsCell.vue
+++ b/frontend/src/components/ColumnDataTable/LabelsCell.vue
@@ -25,7 +25,7 @@
import { computed } from "vue";
import { reactive } from "vue";
import { DatabaseLabelsCell } from "@/components/v2/Model/DatabaseV1Table/cells";
-import { useDBSchemaV1Store } from "@/store";
+import { useDatabaseCatalog, getColumnCatalog } from "@/store";
import type { ComposedDatabase } from "@/types";
import type {
ColumnMetadata,
@@ -46,21 +46,17 @@ const props = defineProps<{
readonly?: boolean;
}>();
-const dbSchemaV1Store = useDBSchemaV1Store();
const state = reactive<LocalState>({
showLabelsDrawer: false,
});
-const columnConfig = computed(() =>
- dbSchemaV1Store.getColumnConfig({
- database: props.database.name,
- schema: props.schema,
- table: props.table.name,
- column: props.column.name,
- })
+const databaseCatalog = useDatabaseCatalog(props.database.name, false);
+
+const columnCatalog = computed(() =>
+ getColumnCatalog(databaseCatalog.value, props.schema, props.table.name, props.column.name)
);
-const labels = computed(() => columnConfig.value?.labels ?? {});
+const labels = computed(() => columnCatalog.value?.labels ?? {});
const openLabelsDrawer = () => {
state.showLabelsDrawer = true;
diff --git a/frontend/src/components/ColumnDataTable/index.vue b/frontend/src/components/ColumnDataTable/index.vue
index b177b5c7bd..e2773ec32a 100644
--- a/frontend/src/components/ColumnDataTable/index.vue
+++ b/frontend/src/components/ColumnDataTable/index.vue
@@ -19,7 +19,8 @@ import { getColumnDefaultValuePlaceholder } from "@/components/SchemaEditorLite"
import {
useSettingV1Store,
useSubscriptionV1Store,
- useDBSchemaV1Store,
+ useDatabaseCatalog,
+ getColumnCatalog,
} from "@/store";
import type { ComposedDatabase } from "@/types";
import { Engine } from "@/types/proto/v1/common";
@@ -65,7 +66,6 @@ const engine = computed(() => {
return props.database.instanceResource.engine;
});
const subscriptionV1Store = useSubscriptionV1Store();
-const dbSchemaStore = useDBSchemaV1Store();
const settingStore = useSettingV1Store();
const hasSensitiveDataFeature = computed(() => {
@@ -124,6 +124,8 @@ const hasSensitiveDataPermission = computed(() => {
);
});
+const databaseCatalog = useDatabaseCatalog(props.database.name, false);
+
const columns = computed(() => {
const columns: (DataTableColumn<ColumnMetadata> & { hide?: boolean })[] = [
{
@@ -175,14 +177,9 @@ const columns = computed(() => {
width: 140,
resizable: true,
render: (column) => {
- const columnConfig = dbSchemaStore.getColumnConfig({
- database: props.database.name,
- schema: props.schema,
- table: props.table.name,
- column: column.name,
- });
+ const columnCatalog = getColumnCatalog(databaseCatalog.value, props.schema, props.table.name, column.name);
return h(ClassificationCell, {
- classification: columnConfig.classificationId,
+ classification: columnCatalog.classificationId,
classificationConfig:
props.classificationConfig ??
DataClassificationConfig.fromPartial({}),
diff --git a/frontend/src/components/SensitiveData/useColumnMasking.ts b/frontend/src/components/SensitiveData/useColumnMasking.ts
index b4ef28fcbd..79793badec 100644
--- a/frontend/src/components/SensitiveData/useColumnMasking.ts
+++ b/frontend/src/components/SensitiveData/useColumnMasking.ts
@@ -1,5 +1,5 @@
import { computed } from "vue";
-import { useDBSchemaV1Store, useSettingV1Store } from "@/store";
+import { useDatabaseCatalog, useSettingV1Store, getColumnCatalog } from "@/store";
import { MaskingAlgorithmSetting_Algorithm as Algorithm } from "@/types/proto/v1/setting_service";
export const useColumnMasking = ({
@@ -14,7 +14,6 @@ export const useColumnMasking = ({
column: string;
}) => {
const settingV1Store = useSettingV1Store();
- const dbSchemaV1Store = useDBSchemaV1Store();
const rawAlgorithmList = computed((): Algorithm[] => {
return (
@@ -23,22 +22,19 @@ export const useColumnMasking = ({
);
});
- const columnConfig = computed(() =>
- dbSchemaV1Store.getColumnConfig({
- database,
- schema,
- table,
- column,
- })
+ const databaseCatalog = useDatabaseCatalog(database, false);
+
+ const columnCatalog = computed(() =>
+ getColumnCatalog(databaseCatalog.value, schema, table, column)
);
- const maskingLevel = computed(() => columnConfig.value.maskingLevel);
+ const maskingLevel = computed(() => columnCatalog.value.maskingLevel);
const fullMaskingAlgorithm = computed(() => {
- const id = columnConfig.value.fullMaskingAlgorithmId;
+ const id = columnCatalog.value.fullMaskingAlgorithmId;
return rawAlgorithmList.value.find((a) => a.id === id);
});
const partialMaskingAlgorithm = computed(() => {
- const id = columnConfig.value.partialMaskingAlgorithmId;
+ const id = columnCatalog.value.partialMaskingAlgorithmId;
return rawAlgorithmList.value.find((a) => a.id === id);
});
diff --git a/frontend/src/components/SensitiveData/useSemanticType.ts b/frontend/src/components/SensitiveData/useSemanticType.ts
index f6fdcbd868..65f3608f03 100644
--- a/frontend/src/components/SensitiveData/useSemanticType.ts
+++ b/frontend/src/components/SensitiveData/useSemanticType.ts
@@ -1,5 +1,5 @@
import { computed } from "vue";
-import { useDBSchemaV1Store, useSettingV1Store } from "@/store";
+import { useSettingV1Store, useDatabaseCatalog, getColumnCatalog } from "@/store";
export const useSemanticType = ({
database,
@@ -13,7 +13,6 @@ export const useSemanticType = ({
column: string;
}) => {
const settingV1Store = useSettingV1Store();
- const dbSchemaV1Store = useDBSchemaV1Store();
const semanticTypeList = computed(() => {
return (
@@ -22,18 +21,15 @@ export const useSemanticType = ({
);
});
+ const databaseCatalog = useDatabaseCatalog(database, false);
+
const semanticType = computed(() => {
- const config = dbSchemaV1Store.getColumnConfig({
- database,
- schema,
- table,
- column,
- });
- if (!config.semanticTypeId) {
+ const columnCatalog = getColumnCatalog(databaseCatalog.value, schema, table, column)
+ if (!columnCatalog.semanticTypeId) {
return;
}
return semanticTypeList.value.find(
- (data) => data.id === config.semanticTypeId
+ (data) => data.id === columnCatalog.semanticTypeId
);
});
diff --git a/frontend/src/store/modules/v1/dbSchema.ts b/frontend/src/store/modules/v1/dbSchema.ts
index c757cb5c96..fb8cb667f4 100644
--- a/frontend/src/store/modules/v1/dbSchema.ts
+++ b/frontend/src/store/modules/v1/dbSchema.ts
@@ -8,9 +8,6 @@ import {
TableMetadata,
DatabaseMetadata,
DatabaseMetadataView,
- ColumnConfig,
- SchemaConfig,
- TableConfig,
} from "@/types/proto/v1/database_service";
import { extractDatabaseResourceName } from "@/utils";
@@ -187,62 +184,6 @@ export const useDBSchemaV1Store = defineStore("dbSchema_v1", () => {
}
};
- const updateDatabaseSchemaConfigs = async (metadata: DatabaseMetadata) => {
- await databaseServiceClient.updateDatabaseMetadata({
- databaseMetadata: metadata,
- updateMask: ["schema_configs"],
- });
- // updateDatabaseMetadata actually returns basic view
- // so we cannot setCache(updated) here
- mergeCache(metadata, VIEW_FULL, true);
- };
-
- const getSchemaConfig = (database: string, schema: string) => {
- const metadata = getDatabaseMetadata(
- database,
- DatabaseMetadataView.DATABASE_METADATA_VIEW_FULL
- );
-
- return (
- metadata.schemaConfigs.find((config) => config.name === schema) ??
- SchemaConfig.fromPartial({
- name: schema,
- tableConfigs: [],
- })
- );
- };
-
- const getTableConfig = (database: string, schema: string, table: string) => {
- const schemaConfig = getSchemaConfig(database, schema);
-
- return (
- schemaConfig.tableConfigs.find((config) => config.name === table) ??
- TableConfig.fromPartial({
- name: table,
- columnConfigs: [],
- })
- );
- };
-
- const getColumnConfig = ({
- database,
- schema,
- table,
- column,
- }: {
- database: string;
- schema: string;
- table: string;
- column: string;
- }) => {
- const tableConfig = getTableConfig(database, schema, table);
-
- return (
- tableConfig.columnConfigs.find((config) => config.name === column) ??
- ColumnConfig.fromPartial({})
- );
- };
-
const getDatabaseMetadataWithoutDefault = (
database: string,
view?: DatabaseMetadataView
@@ -504,9 +445,6 @@ export const useDBSchemaV1Store = defineStore("dbSchema_v1", () => {
};
return {
- updateDatabaseSchemaConfigs,
- getSchemaConfig,
- getColumnConfig,
getDatabaseMetadataWithoutDefault,
getDatabaseMetadata,
getOrFetchDatabaseMetadata,