Skip to content

Conversation

@scottnemes
Copy link
Contributor

@scottnemes scottnemes commented Feb 9, 2026

Description

This PR updates the suggestion logic for SELECT queries by suggesting tables that contain the given columns first before other tables that do not contain the given columns. For example:

Given the below tables:
TableA = ID, Name
TableB = ID, City
TableC = ID, School

SELECT ID FROM would suggest all three tables
SELECT School FROM would suggest TableC first (match), then TableA and TableB (no match)
SELECT City, School FROM would suggest TableB and TableC (match), then TableA (no match)

This also works for sub selects, and is based on the closest select. I.e. (using the same above tables):

SELECT * FROM (SELECT City FROM would suggest TableB first (match) since the closest select is for City and not *, followed by TableA and TableC (no match).

Checklist

  • I added this contribution to the changelog.md file.
  • I added my name to the AUTHORS file (or it's already there).
  • To lint and format the code, I ran
    uv run ruff check && uv run ruff format && uv run mypy --install-types .

@scottnemes scottnemes self-assigned this Feb 9, 2026
@scottnemes scottnemes changed the title [feat] Only return tables that include the given column(s) in a SELECT statement [feat] Suggest tables that include the given column(s) in a SELECT statement first before other tables Feb 9, 2026
Copy link
Contributor

@rolandwalker rolandwalker left a comment

Choose a reason for hiding this comment

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

Slick!

@scottnemes scottnemes merged commit f54d3ae into dbcli:main Feb 9, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants