Skip to content

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

fix: visualize explain cannot handle multiple query results (#15164)

ecmadao898b529a6372
diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/ResultViewV1.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/ResultViewV1.vue
index 1fcb6584bb..5ffc89a889 100644
--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/ResultViewV1.vue
+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/ResultViewV1.vue
@@ -6,11 +6,18 @@
>
<template v-if="executeParams && resultSet && !showPlaceholder">
<template v-if="viewMode === 'SINGLE-RESULT'">
+ <ErrorView
+ v-if="resultSet.results[0]?.error"
+ :error="resultSet.results[0]?.error"
+ :execute-params="executeParams"
+ :result-set="resultSet"
+ />
<SingleResultViewV1
+ v-else
:params="executeParams"
:database="database"
- :sql-result-set="resultSet"
:result="resultSet.results[0]"
+ :allow-export="resultSet.allowExport"
:set-index="0"
/>
</template>
@@ -34,11 +41,18 @@
class="ml-2 text-yellow-600 w-4 h-auto"
/>
</template>
+ <ErrorView
+ v-if="result.error"
+ :error="result.error"
+ :execute-params="executeParams"
+ :result-set="resultSet"
+ />
<SingleResultViewV1
+ v-else
:params="executeParams"
- :sql-result-set="resultSet"
:database="database"
:result="result"
+ :allow-export="resultSet.allowExport"
:set-index="i"
/>
</NTabPane>
diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vue
index f1b2f051c2..e978161c0b 100644
--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vue
+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vue
@@ -80,7 +80,7 @@
</NTooltip>
<template v-if="!disallowExportQueryData">
<DataExportButton
- v-if="allowToExportData"
+ v-if="allowExport"
size="small"
:file-type="'zip'"
:disabled="props.result === null || isEmpty(props.result)"
@@ -157,13 +157,6 @@
<template v-else-if="viewMode === 'EMPTY'">
<EmptyView />
</template>
- <template v-else-if="viewMode === 'ERROR'">
- <ErrorView
- :error="result.error"
- :execute-params="params"
- :result-set="sqlResultSet"
- />
- </template>
</template>
<script lang="ts" setup>
@@ -208,11 +201,7 @@ import {
useStorageStore,
} from "@/store";
import { useExportData } from "@/store/modules/export";
-import type {
- ComposedDatabase,
- SQLEditorQueryParams,
- SQLResultSetV1,
-} from "@/types";
+import type { ComposedDatabase, SQLEditorQueryParams } from "@/types";
import { isValidDatabaseName, isValidInstanceName } from "@/types";
import { ExportFormat } from "@/types/proto/v1/common";
import { Engine } from "@/types/proto/v1/common";
@@ -256,9 +245,9 @@ const storedPageSize = useLocalStorage<number>(
const props = defineProps<{
params: SQLEditorQueryParams;
database?: ComposedDatabase;
- sqlResultSet: SQLResultSetV1;
result: QueryResult;
setIndex: number;
+ allowExport: boolean;
}>();
const state = reactive<LocalState>({
@@ -314,10 +303,6 @@ const showSearchFeature = computed(() => {
return instanceV1HasStructuredQueryResult(connectedInstance.value);
});
-const allowToExportData = computed(() => {
- return props.sqlResultSet?.allowExport || false;
-});
-
const allowToRequestExportData = computed(() => {
const { database } = props;
if (!database) {
@@ -515,13 +500,14 @@ const showVisualizeButton = computed((): boolean => {
const visualizeExplain = () => {
try {
- const { params, sqlResultSet } = props;
- if (!sqlResultSet) return;
-
+ const { params, result } = props;
const { statement } = params;
if (!statement) return;
- const explain = explainFromSQLResultSetV1(sqlResultSet);
+ const lines = result.rows.map((row) =>
+ row.values.map((value) => String(extractSQLRowValuePlain(value)))
+ );
+ const explain = lines.map((line) => line[0]).join("\n");
if (!explain) return;
const token = createExplainToken(statement, explain);
@@ -536,15 +522,6 @@ const handleChangePage = (page: number) => {
table.setPageIndex(page - 1);
};
-const explainFromSQLResultSetV1 = (resultSet: SQLResultSetV1 | undefined) => {
- if (!resultSet) return "";
- const lines = resultSet.results[0].rows.map((row) =>
- row.values.map((value) => String(extractSQLRowValuePlain(value)))
- );
- const explain = lines.map((line) => line[0]).join("\n");
- return explain;
-};
-
const queryTime = computed(() => {
const { latency } = props.result;
if (!latency) return "-";