Skip to content

Latest commit

 

History

History
211 lines (125 loc) · 6.97 KB

fuzzycomplete.md

File metadata and controls

211 lines (125 loc) · 6.97 KB
warning title excerpt docs extension repo extension_star_count extension_star_count_pretty extension_download_count extension_download_count_pretty image layout
DO NOT CHANGE THIS MANUALLY, THIS IS GENERATED BY https://github/duckdb/community-extensions repository, check README there
fuzzycomplete
DuckDB Community Extensions Fuzzy matching based autocompletion
extended_description hello_world
This `fuzzycomplete`` extension serves as an alternative to DuckDB's autocomplete extension, with several key differences: **Algorithm:** Unlike the `autocomplete`` extension, which uses edit distance as its metric, the `fuzzycomplete`` extension employs a fuzzy string matching algorithm derived from Visual Studio Code. This provides more intuitive and flexible completion suggestions. **Scope:** The `fuzzycomplete`` extension can complete table names across different databases and schemas. It respects the current search path and offers suggestions accordingly, even when multiple databases are attached. It may not yet be the best solution for SQL completion, but it has proven to be useful to the author. ## Details of the fuzzy matching algorithm This extension uses the Rust crate [`code-fuzzy-match`](https://crates.io/crates/code-fuzzy-match). The algorithm ensures that characters in the query string appear in the same order in the target string. It handles substring queries efficiently, allowing searches within the middle of the target string without significantly impacting the match score. The algorithm prioritizes matches that occur at the beginning of words, where words are defined as they commonly appear in code (e.g., letters following a separator or in camel case). Sequential matches are also given preference. In addition to the basic matching algorithm, matches then scored using this criteria if they have an equal score from `code-fuzzy-match``: 1. In the event of a tie in the match score, completion results are first ordered by the number of pseudo-words in the candidate strings, favoring shorter completions. 2. A standard lexical sorting is then applied.
# Create some example tables to demonstrate autocompletion behavior CREATE TABLE foobar(first_name text, last_name text); CREATE TABLE automobile_vehicles(serial_number text); SELECT suggestion FROM sql_auto_complete('SELECT * FROM veh'); ┌─────────────────────┐ │ suggestion │ │ varchar │ ├─────────────────────┤ │ automobile_vehicles │ └─────────────────────┘ SELECT suggestion FROM sql_auto_complete('SELECT * FROM auto'); ┌──────────────────────────────────────┐ │ suggestion │ │ varchar │ ├──────────────────────────────────────┤ │ automobile_vehicles │ │ "system".main.read_csv_auto │ │ "system".main.sql_auto_complete │ │ "system".main.duckdb_temporary_files │ │ "system".main.duckdb_extensions │ │ "system".main.duckdb_functions │ └──────────────────────────────────────┘ SELECT suggestion FROM sql_auto_complete('SELECT * FROM bar'); ┌──────────────────────────────────────┐ │ suggestion │ │ varchar │ ├──────────────────────────────────────┤ │ foobar │ │ "system".main.duckdb_temporary_files │ └──────────────────────────────────────┘ -- Demonstrate completion across databases/catalogs and schemas. SELECT suggestion FROM sql_auto_complete('SELECT * FROM table'); ┌───────────────────────────────────────────────┐ │ suggestion │ │ varchar │ ├───────────────────────────────────────────────┤ │ duckdb_tables │ │ information_schema."tables" │ │ "system".information_schema."tables" │ │ "system".main.duckdb_tables │ │ "system".main.duckdb_tables │ │ "temp".information_schema."tables" │ │ "temp".main.duckdb_tables │ │ information_schema.table_constraints │ │ pg_catalog.pg_tables │ │ pg_catalog.pg_tablespace │ │ "system".information_schema.table_constraints │ │ "system".main.pragma_table_info │ │ "system".pg_catalog.pg_tables │ │ "system".pg_catalog.pg_tablespace │ │ "temp".information_schema.table_constraints │ │ "temp".pg_catalog.pg_tables │ │ "temp".pg_catalog.pg_tablespace │ │ "system".main.duckdb_temporary_files │ ├───────────────────────────────────────────────┤ │ 18 rows │ └───────────────────────────────────────────────┘
build description language license maintainers name requires_toolchains version excluded_platforms
cmake
Fuzzy matching based autocompletion
C++
Apache-2.0
rustyconover
fuzzycomplete
rust
1.0.0
linux_amd64_musl
github ref
rustyconover/duckdb-fuzzycomplete-extension
39a61c1c39a2b028101ef635fcb04856883ab498
13
13
551
551
/images/community_extensions/social_preview/preview_community_extension_fuzzycomplete.png
community_extension_doc

Installing and Loading

INSTALL {{ page.extension.name }} FROM community;
LOAD {{ page.extension.name }};

{% if page.docs.hello_world %}

Example

{{ page.docs.hello_world }}```
{% endif %}

{% if page.docs.extended_description %}
### About {{ page.extension.name }}
{{ page.docs.extended_description }}
{% endif %}