Skip to content

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

feat(sql-editor): display hover panel for table partitions (#11655)

Liu Ji5ca07b5708b8
diff --git a/frontend/src/views/sql-editor/AsidePanel/SchemaPane/HoverPanel/HoverPanel.vue b/frontend/src/views/sql-editor/AsidePanel/SchemaPane/HoverPanel/HoverPanel.vue
index 9ea0c6a2d0..3c70e4763c 100644
--- a/frontend/src/views/sql-editor/AsidePanel/SchemaPane/HoverPanel/HoverPanel.vue
+++ b/frontend/src/views/sql-editor/AsidePanel/SchemaPane/HoverPanel/HoverPanel.vue
@@ -17,6 +17,14 @@
:schema="state.schema"
:column="state.column"
/>
+ <TablePartitionInfo
+ v-else-if="state.table && state.partition"
+ :db="state.db"
+ :database="state.database"
+ :schema="state.schema"
+ :table="state.table"
+ :partition="state.partition"
+ />
<TableInfo
v-else-if="state.table"
:db="state.db"
@@ -51,6 +59,7 @@ import { minmax } from "@/utils";
import ColumnInfo from "./ColumnInfo.vue";
import ExternalTableInfo from "./ExternalTableInfo.vue";
import TableInfo from "./TableInfo.vue";
+import TablePartitionInfo from "./TablePartitionInfo.vue";
import ViewInfo from "./ViewInfo.vue";
import { useHoverStateContext } from "./hover-state";
diff --git a/frontend/src/views/sql-editor/AsidePanel/SchemaPane/HoverPanel/TablePartitionInfo.vue b/frontend/src/views/sql-editor/AsidePanel/SchemaPane/HoverPanel/TablePartitionInfo.vue
new file mode 100644
index 0000000000..b3b1edea9a
--- /dev/null
+++ b/frontend/src/views/sql-editor/AsidePanel/SchemaPane/HoverPanel/TablePartitionInfo.vue
@@ -0,0 +1,36 @@
+<template>
+ <div class="min-w-[14rem] max-w-[18rem] gap-y-1">
+ <InfoItem :title="$t('common.name')">
+ {{ partition.name }}
+ </InfoItem>
+ <InfoItem :title="$t('schema-editor.table-partition.type')">
+ {{ tablePartitionMetadata_TypeToJSON(partition.type) }}
+ </InfoItem>
+ <InfoItem :title="$t('schema-editor.table-partition.expression')">
+ <code>{{ partition.expression }}</code>
+ </InfoItem>
+ <InfoItem :title="$t('schema-editor.table-partition.value')">
+ {{ partition.value }}
+ </InfoItem>
+ </div>
+</template>
+
+<script setup lang="ts">
+import type { ComposedDatabase } from "@/types";
+import {
+ tablePartitionMetadata_TypeToJSON,
+ type DatabaseMetadata,
+ type SchemaMetadata,
+ type TableMetadata,
+ type TablePartitionMetadata,
+} from "@/types/proto/v1/database_service";
+import InfoItem from "./InfoItem.vue";
+
+defineProps<{
+ db: ComposedDatabase;
+ database: DatabaseMetadata;
+ schema: SchemaMetadata;
+ table: TableMetadata;
+ partition: TablePartitionMetadata;
+}>();
+</script>
diff --git a/frontend/src/views/sql-editor/AsidePanel/SchemaPane/HoverPanel/hover-state.ts b/frontend/src/views/sql-editor/AsidePanel/SchemaPane/HoverPanel/hover-state.ts
index 3ae1fcd2c2..a8cdba18bb 100644
--- a/frontend/src/views/sql-editor/AsidePanel/SchemaPane/HoverPanel/hover-state.ts
+++ b/frontend/src/views/sql-editor/AsidePanel/SchemaPane/HoverPanel/hover-state.ts
@@ -5,6 +5,7 @@ import type {
ExternalTableMetadata,
SchemaMetadata,
TableMetadata,
+ TablePartitionMetadata,
ViewMetadata,
} from "@/types/proto/v1/database_service";
import {
@@ -22,6 +23,7 @@ export type HoverState = {
externalTable?: ExternalTableMetadata;
view?: ViewMetadata;
column?: ColumnMetadata;
+ partition?: TablePartitionMetadata;
};
export const useHoverStateContext = () => {
diff --git a/frontend/src/views/sql-editor/AsidePanel/SchemaPane/SchemaPane.vue b/frontend/src/views/sql-editor/AsidePanel/SchemaPane/SchemaPane.vue
index 4e4a3a7113..699291e6fd 100644
--- a/frontend/src/views/sql-editor/AsidePanel/SchemaPane/SchemaPane.vue
+++ b/frontend/src/views/sql-editor/AsidePanel/SchemaPane/SchemaPane.vue
@@ -194,10 +194,11 @@ const nodeProps = ({ option }: { option: TreeOption }) => {
type === "table" ||
type === "external-table" ||
type === "column" ||
- type === "view"
+ type === "view" ||
+ type === "partition-table"
) {
const target = node.meta.target as NodeTarget<
- "table" | "external-table" | "column" | "view"
+ "table" | "external-table" | "column" | "view" | "partition-table"
>;
if (hoverState.value) {
updateHoverState(target, "before", 0 /* overrideDelay */);
diff --git a/frontend/src/views/sql-editor/AsidePanel/SchemaPane/TreeNode/PartitionTableNode.vue b/frontend/src/views/sql-editor/AsidePanel/SchemaPane/TreeNode/PartitionTableNode.vue
index 771f1e43cf..5df883f134 100644
--- a/frontend/src/views/sql-editor/AsidePanel/SchemaPane/TreeNode/PartitionTableNode.vue
+++ b/frontend/src/views/sql-editor/AsidePanel/SchemaPane/TreeNode/PartitionTableNode.vue
@@ -1,6 +1,6 @@
<template>
<div class="flex items-center max-w-full overflow-hidden gap-x-1">
- <TableIcon class="w-4 h-4" />
+ <TablePartitionIcon class="w-4 h-4 opacity-75" :stroke-width="1.75" />
<HighlightLabelText
:text="target.partition.name"
:keyword="keyword"
@@ -11,7 +11,7 @@
<script setup lang="ts">
import { computed } from "vue";
-import { TableIcon } from "@/components/Icon";
+import { TablePartitionIcon } from "@/components/Icon";
import type { TreeNode } from "../common";
import HighlightLabelText from "./HighlightLabelText.vue";
diff --git a/frontend/src/views/sql-editor/AsidePanel/SchemaPane/common.ts b/frontend/src/views/sql-editor/AsidePanel/SchemaPane/common.ts
index 0ade28f1ec..13e5cf89d0 100644
--- a/frontend/src/views/sql-editor/AsidePanel/SchemaPane/common.ts
+++ b/frontend/src/views/sql-editor/AsidePanel/SchemaPane/common.ts
@@ -149,11 +149,12 @@ export const keyForNodeTarget = <T extends NodeType>(
return [parentKey, `columns/${column.name}`].join("/");
}
if (type === "partition-table") {
- const { db, schema, parentPartition, partition } =
+ const { db, schema, table, parentPartition, partition } =
target as NodeTarget<"partition-table">;
return [
db.name,
`schemas/${schema.name}`,
+ `tables/${table.name}`,
`partitionTables/${parentPartition?.name ?? ""}/${partition.name}`,
].join("/");
}