Skip to content

feat(fuzzy-finder): add per-type fuzzy completion for SHOW CREATE#528

Merged
apstndb merged 1 commit intomainfrom
issue-519-show-create-hidden
Feb 26, 2026
Merged

feat(fuzzy-finder): add per-type fuzzy completion for SHOW CREATE#528
apstndb merged 1 commit intomainfrom
issue-519-show-create-hidden

Conversation

@apstndb
Copy link
Owner

@apstndb apstndb commented Feb 26, 2026

Summary

Add per-type fuzzy completion for SHOW CREATE <type> so that pressing Ctrl+T after the type keyword suggests matching schema objects. Supports 5 types: VIEW, INDEX, CHANGE STREAM, SEQUENCE, and MODEL.

Key Changes

  • client_side_statement_def.go: Add 5 new fuzzyCompletionType constants and Completion entries on the existing SHOW CREATE definition with prefix patterns (CHANGE STREAM ordered first since it's multi-word)
  • fuzzy_finder.go: Extract fetchSchemaObjectCandidates shared helper for INFORMATION_SCHEMA queries, refactor fetchTableCandidates to use it, add 5 new fetch functions (fetchViewCandidates, fetchIndexCandidates, fetchChangeStreamCandidates, fetchSequenceCandidates, fetchModelCandidates), 5 cache fields with schema-generation awareness, and update all switch statements (requiresNetwork, getCachedCandidates, setCachedCandidates, fetchCandidates, completionHeader)
  • fuzzy_finder_test.go: Add 15 test cases (3 per type) to TestDetectFuzzyContext covering trailing space, partial name, and case-insensitive matching

Development Insights

Design Decision

Instead of the original "hidden statement definitions" approach from the issue, we add multiple Completion entries to the existing SHOW CREATE clientSideStatementDef. This follows the established pattern (USE has database+role, SET has variable+value) and avoids new infrastructure.

INFORMATION_SCHEMA Column Names

Each table has different naming conventions: VIEWS uses TABLE_SCHEMA/TABLE_NAME, INDEXES uses TABLE_SCHEMA/INDEX_NAME, CHANGE_STREAMS uses CHANGE_STREAM_SCHEMA/CHANGE_STREAM_NAME, SEQUENCES uses SCHEMA/NAME, MODELS uses MODEL_SCHEMA/MODEL_NAME.

Not in Scope

TABLE (#512/#518), ROLE (#513), SCHEMA (#520) — tracked separately.

Test Plan

  • make check passes (test + lint + fmt-check)
  • Unit tests: TestDetectFuzzyContext covers prefix pattern matching for all 5 types
  • Manual testing: verified all 5 completion types work with live Spanner connection

Fixes #519

Add argument completion for SHOW CREATE <type> so that pressing Ctrl+T
after the type keyword suggests matching schema objects from
INFORMATION_SCHEMA. Supports VIEW, INDEX, CHANGE STREAM, SEQUENCE,
and MODEL with TTL-based caching and schema-generation awareness.

Extract fetchSchemaObjectCandidates shared helper to reduce boilerplate
across all INFORMATION_SCHEMA-based fetch functions, and refactor
fetchTableCandidates to use it.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@apstndb apstndb added enhancement New feature or request fuzzy-finder Fuzzy finder (fzf) completion features labels Feb 26, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @apstndb, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly improves the user experience for SHOW CREATE statements by implementing type-specific fuzzy completion. Users can now receive relevant suggestions for views, indexes, change streams, sequences, and models directly within the command line interface, making schema exploration and command construction more efficient and less prone to errors.

Highlights

  • Enhanced SHOW CREATE Fuzzy Completion: Added per-type fuzzy completion for SHOW CREATE statements, now supporting VIEW, INDEX, CHANGE STREAM, SEQUENCE, and MODEL types, allowing for intelligent suggestions of schema objects.
  • Code Structure and Reusability: Refactored the fuzzy finder's candidate fetching logic by introducing a shared fetchSchemaObjectCandidates helper, which streamlines queries to INFORMATION_SCHEMA and improves maintainability for similar object types.
  • Comprehensive Test Coverage: Expanded unit tests with 15 new cases in fuzzy_finder_test.go to ensure robust and accurate detection of fuzzy contexts for all newly supported SHOW CREATE object types, covering various input scenarios.
Changelog
  • internal/mycli/client_side_statement_def.go
    • Added fuzzyCompleteView, fuzzyCompleteIndex, fuzzyCompleteChangeStream, fuzzyCompleteSequence, and fuzzyCompleteModel constants to fuzzyCompletionType.
    • Updated the String() method for fuzzyCompletionType to return descriptive names for the new completion types.
    • Introduced new Completion entries for the SHOW CREATE statement definition, each with a specific PrefixPattern regex to trigger fuzzy completion for the new object types.
  • internal/mycli/fuzzy_finder.go
    • Added new cache fields (viewCache, indexCache, changeStreamCache, sequenceCache, modelCache) to fuzzyFinderCommand for network-dependent candidates.
    • Updated completionHeader to provide appropriate display headers for the new fuzzy completion types.
    • Modified requiresNetwork to include the new completion types, indicating they require a network call to fetch candidates.
    • Extended getCachedCandidates and setCachedCandidates to manage caching for the newly introduced object types.
    • Updated fetchCandidates to dispatch to dedicated fetch functions for each new SHOW CREATE object type.
    • Extracted fetchSchemaObjectCandidates as a shared helper function for querying INFORMATION_SCHEMA for schema-qualified objects.
    • Refactored fetchTableCandidates to utilize the new fetchSchemaObjectCandidates helper.
    • Implemented new functions: fetchViewCandidates, fetchIndexCandidates, fetchChangeStreamCandidates, fetchSequenceCandidates, and fetchModelCandidates to retrieve candidates for their respective types using INFORMATION_SCHEMA.
  • internal/mycli/fuzzy_finder_test.go
    • Added 15 new test cases to TestDetectFuzzyContext, covering SHOW CREATE VIEW, SHOW CREATE INDEX, SHOW CREATE CHANGE STREAM, SHOW CREATE SEQUENCE, and SHOW CREATE MODEL.
    • Each new test case includes scenarios for trailing spaces, partial names, and case-insensitive matching to ensure robust fuzzy context detection.
Activity
  • The make check command passed, indicating that all tests, linting, and formatting checks were successful.
  • Unit tests, specifically TestDetectFuzzyContext, were implemented and passed, verifying prefix pattern matching for all 5 new SHOW CREATE types.
  • Manual testing was conducted and confirmed that all 5 new completion types function correctly with a live Spanner connection.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link

Code Metrics Report

📊 View detailed coverage report (available for 7 days)

main (1955708) #528 (400078b) +/-
Coverage 67.9% 67.5% -0.4%
Code to Test Ratio 1:1.2 1:1.2 -0.1
Test Execution Time 2m8s 1m10s -58s
Details
  |                     | main (1955708) | #528 (400078b) |  +/-  |
  |---------------------|----------------|----------------|-------|
- | Coverage            |          67.9% |          67.5% | -0.4% |
  |   Files             |             55 |             55 |     0 |
  |   Lines             |           6039 |           6074 |   +35 |
  |   Covered           |           4101 |           4101 |     0 |
- | Code to Test Ratio  |          1:1.2 |          1:1.2 |  -0.1 |
  |   Code              |          13819 |          13939 |  +120 |
+ |   Test              |          17235 |          17340 |  +105 |
+ | Test Execution Time |           2m8s |          1m10s |  -58s |

Code coverage of files in pull request scope (53.0% → 49.6%)

Files Coverage +/- Status
internal/mycli/client_side_statement_def.go 77.2% -1.9% modified
internal/mycli/fuzzy_finder.go 31.9% -3.3% modified

Reported by octocov

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds fuzzy completion for several SHOW CREATE object types, including views, indexes, change streams, sequences, and models. This is achieved by adding new completion definitions and corresponding data-fetching logic. The implementation introduces a generic fetchSchemaObjectCandidates function to query INFORMATION_SCHEMA tables, which is then used by specific fetchers for each object type. Caching is extended to support the new object types. The changes also include unit tests for the new completion contexts. The implementation is consistent with the existing fuzzy-finder architecture. No issues were found during the review.

@apstndb apstndb merged commit 2db3383 into main Feb 26, 2026
2 checks passed
@apstndb apstndb deleted the issue-519-show-create-hidden branch February 26, 2026 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request fuzzy-finder Fuzzy finder (fzf) completion features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fuzzy completion: SHOW CREATE hidden expansion and object type completions

1 participant