You have typed enough of a table name to know which one you mean. The completion list has other ideas. A built-in function comes first, then a system table, then the table you use every day.
Fuzzycomplete already matched abbreviated names such as cstmr_ord_hst to customer_order_history. Its DuckDB 2.0 update improves the ordering around those matches and makes the results fit the shell’s completion interface. The matcher had been calculating useful ranking bonuses all along. It just wasn’t applying them.
The same match, with a better tie-breaker
A fuzzy score measures how closely the characters match. It does not tell you whether a candidate is relevant to the query. Two equally good names can have very different uses.
The new ordering applies the existing candidate bonuses when fuzzy scores tie. Common statement keywords come before less common ones. User tables, views, catalogs and schemas come before built-in objects. Columns from tables named in the query come before other columns, and columns come before functions.
Here is a small catalog where that distinction matters:
CREATE TABLE customer_order_history ( order_total INTEGER, order_id INTEGER);CREATE TABLE store_inventory (order_quantity INTEGER);
SELECT suggestionFROM sql_auto_complete('SELECT * FROM store_inventory WHERE ordr')LIMIT 1;| suggestion |
|---|
| order_quantity |
Change the referenced table to customer_order_history, and its columns move ahead. At the start of a statement, an empty input puts SELECT first; completing D puts DELETE first.
The reported suggestion_score deliberately stays unchanged by the bonus. The shell uses that score to distinguish a clear winner from a tie. Reordering equally plausible choices should make the list more useful, without causing the shell to silently accept a choice that remains ambiguous.
Give the shell the information it expects
The 2.0 shell expects five fields from sql_auto_complete:
| Column | Purpose |
|---|---|
suggestion |
Text to insert |
suggestion_start |
Where replacement begins |
suggestion_type |
Keyword, table, column, function, file or directory |
suggestion_score |
Distance from the best fuzzy match; zero is best |
extra_char |
A following space, quote or path separator where appropriate |
Earlier output did not match that shape. The update supplies all five columns and the types the shell expects. It also reports table macros as table_function, instead of calling them tables.
You can inspect a completion directly from SQL:
SELECT suggestion, suggestion_start, suggestion_type, suggestion_scoreFROM sql_auto_complete('SELECT * FROM cstmr_ord_hst');| suggestion | suggestion_start | suggestion_type | suggestion_score |
|---|---|---|---|
| customer_order_history | 14 | table | 0 |
With the example table above, the result is customer_order_history, starting at position 14, with type table and score 0. The shell-interface tests also cover catalogs, schemas, scalar functions, filenames and trailing characters.
Loading Fuzzycomplete after the stock autocomplete extension now activates the fuzzy implementation correctly. That matters in a shell that has already loaded completion before you load this extension.
Comments should stay comments
Completion needs enough SQL awareness to recognize what you are typing. It should not try to finish a word inside a comment.
The parser now skips block comments like whitespace and returns no suggestions while a block comment is unfinished. Text after -- stays in the comment until the newline. Both forms work between a keyword and its argument:
SELECT suggestionFROM sql_auto_complete('SELECT * FROM/**/cstmr_ord')LIMIT 1;| suggestion |
|---|
| customer_order_history |
This also keeps the replacement offset correct. Recognizing the right table is only half the job; inserting it at the wrong position still breaks the statement.
A directory listing should not crash the shell
File completion exposed a less visible problem. On filesystems that permit filenames with invalid UTF-8, converting a candidate to Rust text could panic and abort the process. Such names are now skipped because they cannot be returned as a DuckDB VARCHAR. The Rust boundary also checks pointers and catches panics instead of allowing them to escape into C++.
Large suggestion limits are capped by the available candidate pool, rather than allocating a slot for every requested result. File completion respects DuckDB’s external-access setting; catalog completion continues to work when filesystem access is disabled.
These changes are covered by the ranking and robustness tests and the implementation change. They do not change fuzzy completion into a query planner. They make the suggestions it already knows how to find more useful at the cursor.
Install the 2.0 build through the Query Farm extension repository and load fuzzycomplete in your DuckDB shell. The extension page has the full setup and function reference.