Skip to content

Fuzzy completion: SHOW QUERY PROFILE fingerprint completion #523

Description

@apstndb

Outcome and current baseline

Ctrl+T after SHOW QUERY PROFILE or a partial fingerprint opens the fuzzy finder with available fingerprints and query-text previews. Searching can use the preview; selecting inserts only the decimal fingerprint using existing completion suffix rules.

#525 and #514 are closed, and current main already provides fzfItem{Value, Label} and bounded network completion. The profile completion itself is absent. This is independent of descriptor pulling and transaction retry work.

Implementation scope

  • Register fuzzyCompleteQueryProfile in the existing completion metadata for singular SHOW QUERY PROFILE, and wire its completion header/network classification/candidate dispatch. Inspect client_side_statement_def.go and fuzzy_finder.go; preserve matching of plural SHOW QUERY PROFILES and unrelated commands.
  • Query the current database's SPANNER_SYS.QUERY_PROFILES_TOP_HOUR, using the same data/decoding contract as ShowQueryProfilesStatement in statements_query_profile.go. Extract a small shared fetch helper if it removes duplicated fetch/admission/decoding logic. Do not call the SHOW renderer or run the profiled user query merely to collect labels.
  • Use the row's signed TextFingerprint as the inserted decimal value (including negative values); do not substitute a differently encoded JSON fingerprint. Label it with that fingerprint and a one-line query-text preview from the existing decoded QueryStats.QueryText. Normalize whitespace and cap the preview at120 Unicode runes plus an ellipsis when truncated. Empty query text falls back to the fingerprint label.
  • Deduplicate fingerprints so selection is unambiguous. When multiple intervals contain the same fingerprint, use the newest interval's preview. Return deterministic ordering (newest interval first, then fingerprint for ties).
  • Reuse the existing completion fetch timeout/cancellation/loading indicator. Current candidate caching intentionally excludes rapidly changing/context-dependent completions; keep profiles uncached in this PR rather than adding a second cache or storing rendered SHOW results. Do not alter the database/schema cache contract from Fuzzy completion: Candidate caching with TTL #514.
  • Preserve the SHOW query-profile admission boundary for active RW transactions. A missing/disconnected session, no rows, fetch failure, cancellation or finder cancellation must leave the editor unchanged and must not execute the user's partially typed statement. Do not alter LastQueryCache, PLAN_NODE state or profile rendering.

Acceptance

  1. Context tests cover singular command, partial/negative fingerprint, case/whitespace and cursor position. Plural SHOW QUERY PROFILES and unrelated commands are unaffected.
  2. Candidate tests use realistic decoded rows and verify fingerprint-only Value, searchable preview Label, Unicode-safe truncation, empty preview, duplicate intervals and deterministic order.
  3. A filter-level finder test selects by a distinctive query-text fragment and returns exactly the fingerprint, without preview text, quotes or an extra identifier.
  4. Fetch/admission tests verify the current session/database route and bounded cancellation, no rows/errors, and no active-RW query. Existing SHOW QUERY PROFILES behavior is unchanged if a shared helper is extracted.
  5. Completion integration proves the inserted statement parses as SHOW QUERY PROFILE with the selected int64 fingerprint. Cancellation/no candidates preserve the input buffer. Use existing editor/filter test seams; no interactive terminal automation is required.

Validation and delivery

Run focused new fuzzy/profile tests and existing context/filter/cache/query-profile tests. Capture output to a file and check the exit code; confirm the selected regex actually includes the added tests. Then run make check and make check-race, capture output and check exits before every push. Update the fuzzy-finder user documentation with the new context and preview behavior. One PR, Fixes #523. Keep dependencies and the CI coverage floor unchanged; no unrelated completion refactor or profile-storage feature.

Related: #509, completed prerequisites #525 and #514.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestfuzzy-finderFuzzy finder (fzf) completion features

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions