Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: filter and pagination for query history (#15942)
ecmadao9fd880f1edd6
diff --git a/backend/api/v1/sql_service.go b/backend/api/v1/sql_service.goindex 3c9d07dbd5..9cc659fdb5 100644--- a/backend/api/v1/sql_service.go+++ b/backend/api/v1/sql_service.go@@ -14,6 +14,10 @@ import ("log/slog""github.com/alexmullins/zip"+ "github.com/google/cel-go/cel"+ celast "github.com/google/cel-go/common/ast"+ celoperators "github.com/google/cel-go/common/operators"+ celoverloads "github.com/google/cel-go/common/overloads""github.com/pkg/errors""google.golang.org/grpc/codes""google.golang.org/grpc/status"@@ -995,6 +999,93 @@ func (s *SQLService) createQueryHistory(ctx context.Context, database *store.Datreturn nil}+func getListQueryHistoryFilter(filter string) (*store.ListResourceFilter, error) {+ if filter == "" {+ return nil, nil+ }++ e, err := cel.NewEnv()+ if err != nil {+ return nil, status.Errorf(codes.Internal, "failed to create cel env")+ }+ ast, iss := e.Parse(filter)+ if iss != nil {+ return nil, status.Errorf(codes.InvalidArgument, "failed to parse filter %v, error: %v", filter, iss.String())+ }++ var getFilter func(expr celast.Expr) (string, error)+ var positionalArgs []any++ parseToSQL := func(variable, value any) (string, error) {+ switch variable {+ case "project":+ projectID, err := common.GetProjectID(value.(string))+ if err != nil {+ return "", status.Errorf(codes.InvalidArgument, "invalid project filter %q", value)+ }+ positionalArgs = append(positionalArgs, projectID)+ return fmt.Sprintf("query_history.project_id = $%d", len(positionalArgs)), nil+ case "database":+ positionalArgs = append(positionalArgs, value.(string))+ return fmt.Sprintf("query_history.database = $%d", len(positionalArgs)), nil+ case "instance":+ positionalArgs = append(positionalArgs, value.(string))+ return fmt.Sprintf("query_history.database LIKE $%d", len(positionalArgs)), nil+ case "type":+ historyType := store.QueryHistoryType(value.(string))+ positionalArgs = append(positionalArgs, historyType)+ return fmt.Sprintf("query_history.type = $%d", len(positionalArgs)), nil+ default:+ return "", status.Errorf(codes.InvalidArgument, "unsupport variable %q", variable)+ }+ }++ getFilter = func(expr celast.Expr) (string, error) {+ switch expr.Kind() {+ case celast.CallKind:+ functionName := expr.AsCall().FunctionName()+ switch functionName {+ case celoperators.LogicalOr:+ return getSubConditionFromExpr(expr, getFilter, "OR")+ case celoperators.LogicalAnd:+ return getSubConditionFromExpr(expr, getFilter, "AND")+ case celoperators.Equals:+ variable, value := getVariableAndValueFromExpr(expr)+ return parseToSQL(variable, value)+ case celoverloads.Matches:+ variable := expr.AsCall().Target().AsIdent()+ args := expr.AsCall().Args()+ if len(args) != 1 {+ return "", status.Errorf(codes.InvalidArgument, `invalid args for %q`, variable)+ }+ value := args[0].AsLiteral().Value()+ if variable != "statement" {+ return "", status.Errorf(codes.InvalidArgument, `only "statement" support %q operator, but found %q`, celoverloads.Matches, variable)+ }+ strValue, ok := value.(string)+ if !ok {+ return "", status.Errorf(codes.InvalidArgument, "expect string, got %T, hint: filter literals should be string", value)+ }+ return "query_history.statement LIKE '%" + strValue + "%'", nil+ default:+ return "", status.Errorf(codes.InvalidArgument, "unexpected function %v", functionName)+ }+ default:+ return "", status.Errorf(codes.InvalidArgument, "unexpected expr kind %v", expr.Kind())+ }+ }++ where, err := getFilter(ast.NativeRep().Expr())+ if err != nil {+ return nil, err+ }++ return &store.ListResourceFilter{+ Args: positionalArgs,+ Where: "(" + where + ")",+ }, nil+}+// SearchQueryHistories lists query histories.func (s *SQLService) SearchQueryHistories(ctx context.Context, request *v1pb.SearchQueryHistoriesRequest) (*v1pb.SearchQueryHistoriesResponse, error) {offset, err := parseLimitAndOffset(&pageSize{@@ -1017,30 +1108,11 @@ func (s *SQLService) SearchQueryHistories(ctx context.Context, request *v1pb.SeaLimit: &limitPlusOne,Offset: &offset.offset,}-- filters, err := ParseFilter(request.Filter)+ filter, err := getListQueryHistoryFilter(request.Filter)if err != nil {- return nil, status.Error(codes.InvalidArgument, err.Error())- }-- for _, spec := range filters {- if spec.Operator != ComparatorTypeEqual {- return nil, status.Errorf(codes.InvalidArgument, `only support "=" operation for "%v" filter`, spec.Key)- }- switch spec.Key {- case "database":- database := spec.Value- find.Database = &database- case "instance":- instance := spec.Value- find.Instance = &instance- case "type":- historyType := store.QueryHistoryType(spec.Value)- find.Type = &historyType- default:- return nil, status.Errorf(codes.InvalidArgument, "invalid filter %s", spec.Key)- }+ return nil, err}+ find.Filter = filterhistoryList, err := s.store.ListQueryHistories(ctx, find)if err != nil {diff --git a/backend/store/query_history.go b/backend/store/query_history.goindex 8bc535ee60..bf0583d515 100644--- a/backend/store/query_history.go+++ b/backend/store/query_history.go@@ -54,6 +54,7 @@ type FindQueryHistoryMessage struct {Limit *intOffset *int+ Filter *ListResourceFilter}// CreateQueryHistory creates the query history.@@ -105,6 +106,10 @@ func (s *Store) CreateQueryHistory(ctx context.Context, create *QueryHistoryMess// ListQueryHistories lists the query history.func (s *Store) ListQueryHistories(ctx context.Context, find *FindQueryHistoryMessage) ([]*QueryHistoryMessage, error) {where, args := []string{"TRUE"}, []any{}+ if filter := find.Filter; filter != nil {+ where = append(where, filter.Where)+ args = append(args, filter.Args...)+ }if v := find.CreatorUID; v != nil {where, args = append(where, fmt.Sprintf("query_history.creator_id = $%d", len(args)+1)), append(args, *v)diff --git a/frontend/src/composables/useExecuteSQL.ts b/frontend/src/composables/useExecuteSQL.tsindex 478b149db6..e75900b051 100644--- a/frontend/src/composables/useExecuteSQL.ts+++ b/frontend/src/composables/useExecuteSQL.ts@@ -58,6 +58,7 @@ const useExecuteSQL = () => {const databaseStore = useDatabaseV1Store();const tabStore = useSQLEditorTabStore();const sqlEditorStore = useSQLEditorStore();+ const queryHistoryStore = useSQLEditorQueryHistoryStore();const sqlCheckStyle = useAppFeature("bb.feature.sql-editor.sql-check-style");const notify = (@@ -368,16 +369,23 @@ const useExecuteSQL = () => {}} else {queryResultMap.set(database.name, markRaw(resultSet));+ // After all the queries are executed, we update the tab with the latest query result map.+ // Refresh the query history list when the query executed successfully+ // (with or without warnings).+ queryHistoryStore.resetPageToken({+ project: sqlEditorStore.project,+ database: database.name,+ });+ queryHistoryStore.fetchQueryHistoryList({+ project: sqlEditorStore.project,+ database: database.name,+ });}} catch (error: any) {fail(database, error.response?.data?.message ?? String(error));}}- // After all the queries are executed, we update the tab with the latest query result map.- // Refresh the query history list when the query executed successfully- // (with or without warnings).- useSQLEditorQueryHistoryStore().fetchQueryHistoryList();cleanup();};diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex d1480159ab..e3999a5e3c 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -1736,7 +1736,7 @@"rows": "row | rows","vertical-display": "Vertical display","no-history-found": "No history found",- "search-history": "Search History",+ "search-history-by-statement": "Search by statement","binary-format": "Binary format","hex-format": "Hexadecimal format","boolean-format": "Boolean format",diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex bdc9f6a4e8..2d02c098e9 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -1736,7 +1736,7 @@"rows": "fila | filas","vertical-display": "Pantalla vertical","no-history-found": "No se encontró historial",- "search-history": "Historial de búsqueda",+ "search-history-by-statement": "Búsqueda por enunciado","binary-format": "Formato binario","hex-format": "Formato hexadecimal","boolean-format": "Formato booleano",@@ -2602,4 +2602,4 @@"last-visit": "Última visita","changelog-for-version": "Registro de cambios para {version}"}-}+}\ No newline at end of filediff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.jsonindex fbb68bdabd..eaa27ca2ea 100644--- a/frontend/src/locales/ja-JP.json+++ b/frontend/src/locales/ja-JP.json@@ -1736,7 +1736,7 @@"rows": "記録","vertical-display": "縦型表示","no-history-found": "まだ履歴がありません",- "search-history": "履歴の検索",+ "search-history-by-statement": "ステートメントで検索","binary-format": "バイナリ形式","hex-format": "16進形式","boolean-format": "ブール形式",@@ -2602,4 +2602,4 @@"last-visit": "最終訪問","changelog-for-version": "{version} の変更履歴"}-}+}\ No newline at end of filediff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.jsonindex a93be4bb32..fc98924c02 100644--- a/frontend/src/locales/vi-VN.json+++ b/frontend/src/locales/vi-VN.json@@ -1736,7 +1736,7 @@"rows": "dòng | dòng","vertical-display": "Hiển thị dọc","no-history-found": "Không tìm thấy lịch sử",- "search-history": "Tìm kiếm Lịch sử",+ "search-history-by-statement": "Tìm kiếm theo câu lệnh","binary-format": "Định dạng nhị phân","hex-format": "Định dạng thập lục phân","boolean-format": "Định dạng Boolean",@@ -2602,4 +2602,4 @@"last-visit": "Lần truy cập cuối","changelog-for-version": "Nhật ký thay đổi cho phiên bản {version}"}-}+}\ No newline at end of filediff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex 98a2f587b4..72d70d69a2 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -1736,7 +1736,7 @@"rows": "条记录","vertical-display": "竖向展示","no-history-found": "暂无历史记录",- "search-history": "搜索历史记录",+ "search-history-by-statement": "搜索 SQL 语句","binary-format": "二进制格式","hex-format": "十六进制格式","boolean-format": "布尔格式",@@ -2602,4 +2602,4 @@"last-visit": "上次访问","changelog-for-version": "{version} 的更新日志"}-}+}\ No newline at end of filediff --git a/frontend/src/store/modules/sqlEditor/queryHistory.ts b/frontend/src/store/modules/sqlEditor/queryHistory.tsindex 323c511607..a08e4502cf 100644--- a/frontend/src/store/modules/sqlEditor/queryHistory.ts+++ b/frontend/src/store/modules/sqlEditor/queryHistory.ts@@ -1,28 +1,94 @@import { defineStore } from "pinia";-import { ref } from "vue";+import { reactive } from "vue";import { sqlServiceClient } from "@/grpcweb";+import { isValidProjectName, isValidDatabaseName } from "@/types";import type { QueryHistory } from "@/types/proto/v1/sql_service";+export interface QueryHistoryFilter {+ statement?: string;+ project?: string;+ database?: string;+}++const getListQueryHistoryFilter = (filter: QueryHistoryFilter) => {+ const params = [`type == "QUERY"`];+ if (isValidProjectName(filter.project)) {+ params.push(`project == "${filter.project}"`);+ }+ if (isValidDatabaseName(filter.database)) {+ params.push(`database == "${filter.database}"`);+ }+ if (filter.statement) {+ params.push(`statement.matches("${filter.statement}")`);+ }+ return params.join(" && ");+};++const getCacheKey = (filter: QueryHistoryFilter) => {+ const params = [];+ if (isValidProjectName(filter.project)) {+ params.push(filter.project);+ }+ if (isValidDatabaseName(filter.database)) {+ params.push(filter.database);+ }+ return params.join(".");+};+export const useSQLEditorQueryHistoryStore = defineStore("sqlEditorQueryHistory",() => {- const isFetching = ref(false);- const queryHistoryList = ref<QueryHistory[]>([]);+ const queryHistoryMap = reactive(+ new Map<+ string,+ { nextPageToken?: string; queryHistories: QueryHistory[] }+ >()+ );++ const fetchQueryHistoryList = async (+ filter: QueryHistoryFilter+ ): Promise<{+ queryHistories: QueryHistory[];+ nextPageToken?: string;+ }> => {+ const key = getCacheKey(filter);+ if (!queryHistoryMap.has(key)) {+ queryHistoryMap.set(key, { queryHistories: [] });+ }+ const pageToken = queryHistoryMap.get(key)?.nextPageToken;- const fetchQueryHistoryList = async () => {- isFetching.value = true;const resp = await sqlServiceClient.searchQueryHistories({- pageSize: 20,- filter: `type = "QUERY"`,+ pageSize: 5,+ pageToken,+ filter: getListQueryHistoryFilter(filter),});- queryHistoryList.value = resp.queryHistories;- isFetching.value = false;++ queryHistoryMap.get(key)!.nextPageToken = resp.nextPageToken;+ if (pageToken) {+ queryHistoryMap.get(key)!.queryHistories.push(...resp.queryHistories);+ } else {+ queryHistoryMap.get(key)!.queryHistories = resp.queryHistories;+ }+ return resp;+ };++ const getQueryHistoryList = (filter: QueryHistoryFilter) => {+ const key = getCacheKey(filter);+ return queryHistoryMap.get(key) ?? { queryHistories: [] };+ };++ const resetPageToken = (filter: QueryHistoryFilter) => {+ const key = getCacheKey(filter);+ if (!queryHistoryMap.has(key)) {+ queryHistoryMap.set(key, { queryHistories: [] });+ }+ queryHistoryMap.get(key)!.nextPageToken = "";};return {- isFetching,- queryHistoryList,+ resetPageToken,fetchQueryHistoryList,+ getQueryHistoryList,};});diff --git a/frontend/src/types/proto/v1/sql_service.ts b/frontend/src/types/proto/v1/sql_service.tsindex f42ad9d069..2f9d571a86 100644--- a/frontend/src/types/proto/v1/sql_service.ts+++ b/frontend/src/types/proto/v1/sql_service.ts@@ -537,16 +537,22 @@ export interface SearchQueryHistoriesRequest {*/pageToken: string;/**- * filter is the filter to apply on the search query history,- * follow the- * [ebnf](https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form)- * syntax. Support filter by:- * - database, for example:- * database = "instances/{instance}/databases/{database}"- * - instance, for example:- * instance = "instances/{instance}"- * - type, for example:- * type = "QUERY"+ * Filter is the filter to apply on the search query history+ * Supported filter:+ * - project+ * - database+ * - instance+ * - type+ * - statement+ *+ * For example:+ * project == "projects/{project}"+ * database == "instances/{instance}/databases/{database}"+ * instance == "instances/{instance}"+ * type == "QUERY"+ * type == "EXPORT"+ * statement.matches("select")+ * type == "QUERY" && statement.matches("select")*/filter: string;}diff --git a/frontend/src/views/sql-editor/AsidePanel/HistoryPane/HistoryPane.vue b/frontend/src/views/sql-editor/AsidePanel/HistoryPane/HistoryPane.vueindex 775b1163a6..484fc83863 100644--- a/frontend/src/views/sql-editor/AsidePanel/HistoryPane/HistoryPane.vue+++ b/frontend/src/views/sql-editor/AsidePanel/HistoryPane/HistoryPane.vue@@ -3,15 +3,16 @@<div class="relative w-full h-full flex flex-col justify-start items-start"><div class="w-full px-1"><SearchBox- v-model:value="state.search"+ :value="state.search"size="small"- :placeholder="$t('sql-editor.search-history')"+ :placeholder="$t('sql-editor.search-history-by-statement')"style="max-width: 100%"+ @update:value="onSearchUpdate"/></div><div class="w-full flex flex-col justify-start items-start overflow-y-auto"><div- v-for="history in data"+ v-for="history in queryHistoryData.queryHistories":key="history.name"class="w-full p-2 space-y-1 border-b flex flex-col justify-start items-start cursor-pointer hover:bg-gray-50"@click="handleQueryHistoryClick(history)"@@ -33,32 +34,45 @@</div><pclass="max-w-full text-xs break-words font-mono line-clamp-3"- v-html="history.formattedStatement"+ v-html="getFormattedStatement(history.statement)"></p></div>+ <div+ v-if="queryHistoryData.nextPageToken"+ class="w-full flex flex-col items-center my-2"+ >+ <NButton+ quaternary+ :size="'small'"+ :loading="state.loading"+ @click="fetchQueryHistoryListList"+ >+ <span class="textinfolabel">+ {{ $t("common.load-more") }}+ </span>+ </NButton>+ </div></div>- <div- v-show="notifyMessage"- class="absolute w-full h-full flex justify-center items-center transition-all bg-transparent"- >- {{ notifyMessage }}- </div>-- <MaskSpinner- v-show="isFetching && queryHistoryList.length === 0"- class="!bg-white/75"- />+ <template v-if="queryHistoryData.queryHistories.length === 0">+ <MaskSpinner v-if="state.loading" class="!bg-white/75" />+ <div+ v-else+ class="w-full flex items-center justify-center py-8 textinfolabel"+ >+ {{ $t("sql-editor.no-history-found") }}+ </div>+ </template></div></template><script lang="ts" setup>+import { useDebounceFn } from "@vueuse/core";import { useClipboard } from "@vueuse/core";import dayjs from "dayjs";-import { escape, uniqBy } from "lodash-es";+import { escape } from "lodash-es";import { NButton, useDialog } from "naive-ui";-import { storeToRefs } from "pinia";-import { computed, h, onMounted, reactive } from "vue";+import { computed, h, reactive, watch } from "vue";import { useI18n } from "vue-i18n";import MaskSpinner from "@/components/misc/MaskSpinner.vue";import { SearchBox } from "@/components/v2";@@ -66,6 +80,8 @@ import {pushNotification,useSQLEditorQueryHistoryStore,useSQLEditorTabStore,+ useSQLEditorStore,+ type QueryHistoryFilter,} from "@/store";import { getDateForPbTimestamp, type SQLEditorTab } from "@/types";import type { QueryHistory } from "@/types/proto/v1/sql_service";@@ -73,66 +89,77 @@ import { getHighlightHTMLByKeyWords, defer } from "@/utils";interface State {search: string;- currentActionHistory: QueryHistory | null;+ loading: boolean;}const { t } = useI18n();const tabStore = useSQLEditorTabStore();+const editorStore = useSQLEditorStore();const queryHistoryStore = useSQLEditorQueryHistoryStore();-const { isFetching, queryHistoryList } = storeToRefs(queryHistoryStore);const $d = useDialog();const state = reactive<State>({search: "",- currentActionHistory: null,+ loading: false,});-const { copy: copyTextToClipboard, isSupported } = useClipboard({- legacy: true,+const historyQuery = computed((): QueryHistoryFilter => {+ const tab = tabStore.currentTab;+ return {+ database: tab?.connection.database,+ project: editorStore.project,+ statement: state.search,+ };});-const data = computed(() => {- const tempData = queryHistoryList.value.filter((history) => {- let t = false;+const onSearchUpdate = async (search: string) => {+ queryHistoryStore.resetPageToken(historyQuery.value);+ state.search = search;+ await fetchQueryHistoryListList();+};++const queryHistoryData = computed(() =>+ queryHistoryStore.getQueryHistoryList(historyQuery.value)+);- if (history.statement.includes(state.search)) {- t = true;+const fetchQueryHistoryListList = useDebounceFn(async () => {+ state.loading = true;+ try {+ await queryHistoryStore.fetchQueryHistoryList(historyQuery.value);+ } finally {+ state.loading = false;+ }+}, 500);++watch(+ () => historyQuery.value,+ async () => {+ if (queryHistoryData.value.queryHistories.length === 0) {+ await fetchQueryHistoryListList();}+ },+ {+ immediate: true,+ deep: true,+ }+);- return t;- });- const distinctData = uniqBy(tempData, (history) => history.statement);-- return distinctData.map((history) => {- return {- ...history,- formattedStatement: state.search- ? getHighlightHTMLByKeyWords(- escape(history.statement),- escape(state.search)- )- : escape(history.statement),- };- });+const { copy: copyTextToClipboard, isSupported } = useClipboard({+ legacy: true,});+const getFormattedStatement = (statement: string) => {+ return state.search+ ? getHighlightHTMLByKeyWords(escape(statement), escape(state.search))+ : escape(statement);+};+const titleOfQueryHistory = (history: QueryHistory) => {return dayjs(getDateForPbTimestamp(history.createTime)).format("YYYY-MM-DD HH:mm:ss");};-const notifyMessage = computed(() => {- if (isFetching.value) {- return "";- }- if (queryHistoryList.value.length === 0) {- return t("sql-editor.no-history-found");- }-- return "";-});-const handleCopy = (history: QueryHistory) => {if (!isSupported.value) {pushNotification({@@ -143,7 +170,6 @@ const handleCopy = (history: QueryHistory) => {return;}- state.currentActionHistory = history;copyTextToClipboard(history.statement);pushNotification({module: "bytebase",@@ -240,8 +266,4 @@ const handleQueryHistoryClick = async (queryHistory: QueryHistory) => {openInNewTab();}};--onMounted(async () => {- await queryHistoryStore.fetchQueryHistoryList();-});</script>diff --git a/proto/gen/grpc-doc/openapi.yaml b/proto/gen/grpc-doc/openapi.yamlindex 57964172d3..be7d0e4186 100644--- a/proto/gen/grpc-doc/openapi.yaml+++ b/proto/gen/grpc-doc/openapi.yaml@@ -12603,16 +12603,22 @@ components:filter:type: stringdescription: |-- filter is the filter to apply on the search query history,- follow the- [ebnf](https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form)- syntax. Support filter by:- - database, for example:- database = "instances/{instance}/databases/{database}"- - instance, for example:- instance = "instances/{instance}"- - type, for example:- type = "QUERY"+ Filter is the filter to apply on the search query history+ Supported filter:+ - project+ - database+ - instance+ - type+ - statement++ For example:+ project == "projects/{project}"+ database == "instances/{instance}/databases/{database}"+ instance == "instances/{instance}"+ type == "QUERY"+ type == "EXPORT"+ statement.matches("select")+ type == "QUERY" && statement.matches("select")SearchQueryHistoriesResponse:type: objectproperties:diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.mdindex 4eb433b1a6..ebcf172b41 100644--- a/proto/gen/grpc-doc/v1/README.md+++ b/proto/gen/grpc-doc/v1/README.md@@ -8853,7 +8853,9 @@ for field description.| ----- | ---- | ----- | ----------- || page_size | [int32](#int32) | | The maximum number of histories to return. The service may return fewer than this value. If unspecified, at most 10 history entries will be returned. The maximum value is 1000; values above 1000 will be coerced to 1000. || page_token | [string](#string) | | A page token, received from a previous `ListQueryHistory` call. Provide this to retrieve the subsequent page. |-| filter | [string](#string) | | filter is the filter to apply on the search query history, follow the [ebnf](https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form) syntax. Support filter by: - database, for example: database = "instances/{instance}/databases/{database}" - instance, for example: instance = "instances/{instance}" - type, for example: type = "QUERY" |+| filter | [string](#string) | | Filter is the filter to apply on the search query history Supported filter: - project - database - instance - type - statement++For example: project == "projects/{project}" database == "instances/{instance}/databases/{database}" instance == "instances/{instance}" type == "QUERY" type == "EXPORT" statement.matches("select") type == "QUERY" && statement.matches("select") |diff --git a/proto/gen/grpc-doc/v1/index.html b/proto/gen/grpc-doc/v1/index.htmlindex 2c2559331d..6c66160b84 100644--- a/proto/gen/grpc-doc/v1/index.html+++ b/proto/gen/grpc-doc/v1/index.html@@ -24571,16 +24571,22 @@ Provide this to retrieve the subsequent page. </p></td><td>filter</td><td><a href="#string">string</a></td><td></td>- <td><p>filter is the filter to apply on the search query history,-follow the-[ebnf](https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form)-syntax. Support filter by:-- database, for example:- database = "instances/{instance}/databases/{database}"-- instance, for example:- instance = "instances/{instance}"-- type, for example:- type = "QUERY" </p></td>+ <td><p>Filter is the filter to apply on the search query history+Supported filter:+- project+- database+- instance+- type+- statement++For example:+project == "projects/{project}"+database == "instances/{instance}/databases/{database}"+instance == "instances/{instance}"+type == "QUERY"+type == "EXPORT"+statement.matches("select")+type == "QUERY" && statement.matches("select") </p></td></tr></tbody>diff --git a/proto/generated-go/v1/sql_service.pb.go b/proto/generated-go/v1/sql_service.pb.goindex 5dc0a4c51f..9c2e2cb27c 100644--- a/proto/generated-go/v1/sql_service.pb.go+++ b/proto/generated-go/v1/sql_service.pb.go@@ -1735,16 +1735,22 @@ type SearchQueryHistoriesRequest struct {// A page token, received from a previous `ListQueryHistory` call.// Provide this to retrieve the subsequent page.PageToken string `protobuf:"bytes,2,opt,name=page_token,json=pageToken,proto3" json:"page_token,omitempty"`- // filter is the filter to apply on the search query history,- // follow the- // [ebnf](https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form)- // syntax. Support filter by:- // - database, for example:- // database = "instances/{instance}/databases/{database}"- // - instance, for example:- // instance = "instances/{instance}"- // - type, for example:- // type = "QUERY"+ // Filter is the filter to apply on the search query history+ // Supported filter:+ // - project+ // - database+ // - instance+ // - type+ // - statement+ //+ // For example:+ // project == "projects/{project}"+ // database == "instances/{instance}/databases/{database}"+ // instance == "instances/{instance}"+ // type == "QUERY"+ // type == "EXPORT"+ // statement.matches("select")+ // type == "QUERY" && statement.matches("select")Filter string `protobuf:"bytes,3,opt,name=filter,proto3" json:"filter,omitempty"`unknownFields protoimpl.UnknownFieldssizeCache protoimpl.SizeCachediff --git a/proto/v1/sql_service.proto b/proto/v1/sql_service.protoindex cda63ac33e..e3ce7add15 100644--- a/proto/v1/sql_service.proto+++ b/proto/v1/sql_service.proto@@ -461,16 +461,22 @@ message SearchQueryHistoriesRequest {// Provide this to retrieve the subsequent page.string page_token = 2;- // filter is the filter to apply on the search query history,- // follow the- // [ebnf](https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form)- // syntax. Support filter by:- // - database, for example:- // database = "instances/{instance}/databases/{database}"- // - instance, for example:- // instance = "instances/{instance}"- // - type, for example:- // type = "QUERY"+ // Filter is the filter to apply on the search query history+ // Supported filter:+ // - project+ // - database+ // - instance+ // - type+ // - statement+ //+ // For example:+ // project == "projects/{project}"+ // database == "instances/{instance}/databases/{database}"+ // instance == "instances/{instance}"+ // type == "QUERY"+ // type == "EXPORT"+ // statement.matches("select")+ // type == "QUERY" && statement.matches("select")string filter = 3;}