{"id":14563643,"url":"https://github.com/rustyconover/duckdb-fuzzycomplete-extension","last_synced_at":"2025-03-26T23:31:00.449Z","repository":{"id":255762719,"uuid":"849379872","full_name":"rustyconover/duckdb-fuzzycomplete-extension","owner":"rustyconover","description":"DuckDB Extension for fuzzy string matching based autocompletion","archived":false,"fork":false,"pushed_at":"2025-02-07T21:58:46.000Z","size":8394,"stargazers_count":12,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-19T20:59:34.660Z","etag":null,"topics":["autocomplete","autocompletion","duckdb","duckdb-extension","fuzzy-matching","fuzzy-string-matching"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rustyconover.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-29T13:46:00.000Z","updated_at":"2025-03-10T01:08:23.000Z","dependencies_parsed_at":"2024-09-07T02:42:28.773Z","dependency_job_id":"c7c8877f-5936-472f-a99c-471eb26d9b77","html_url":"https://github.com/rustyconover/duckdb-fuzzycomplete-extension","commit_stats":null,"previous_names":["rustyconover/duckdb-fuzzycomplete-extension"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustyconover%2Fduckdb-fuzzycomplete-extension","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustyconover%2Fduckdb-fuzzycomplete-extension/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustyconover%2Fduckdb-fuzzycomplete-extension/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustyconover%2Fduckdb-fuzzycomplete-extension/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rustyconover","download_url":"https://codeload.github.com/rustyconover/duckdb-fuzzycomplete-extension/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245753873,"owners_count":20666827,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["autocomplete","autocompletion","duckdb","duckdb-extension","fuzzy-matching","fuzzy-string-matching"],"created_at":"2024-09-07T02:04:19.041Z","updated_at":"2025-03-26T23:31:00.007Z","avatar_url":"https://github.com/rustyconover.png","language":"C++","funding_links":[],"categories":["others","Extensions"],"sub_categories":["[Community Extensions](https://duckdb.org/community_extensions/)"],"readme":"# fuzzycomplete Extension for DuckDB\n\n![A duck trying to complete a crossword puzzle](./docs/duckdb-fuzzycompletion.jpeg)\n\nThis `fuzzycomplete` extension serves as an alternative to DuckDB's [autocomplete](https://duckdb.org/docs/api/cli/autocomplete.html) extension, with several key differences:\n\n**Algorithm:** Unlike the [autocomplete extension](https://duckdb.org/docs/extensions/autocomplete.html), 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.\n\n**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.\n\nIt may not yet be the best solution for SQL completion, but it has proven to be useful to the author.\n\n## Installation\n\n**`fuzzycomplete` will hopefully soon be a [DuckDB Community Extension](https://github.com/duckdb/community-extensions).**\n\nYou can now use this by using this SQL:\n\n```sql\ninstall fuzzycomplete from community;\nload fuzzycomplete;\n```\n\n## Details of the fuzzy matching algorithm\n\nThis extension uses the Rust crate [`code-fuzzy-match`](https://crates.io/crates/code-fuzzy-match)\n\nThe 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.\n\nIn addition to the basic matching algorithm, matches then scored using this criteria if they have an equal score from `code-fuzzy-match`:\n\n1. 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.\n2. A standard lexical sorting is then applied.\n\n## When would I use this?\n\nIf you're looking to try a different completion algorithm or need to complete table names from various databases and schemas, you might find this extension beneficial.\n\n### Build Architecture\n\nFor the DuckDB extension to call the Rust code a tool called `cbindgen` is used to write the C++ headers for the exposed Rust interface.\n\nThe headers can be updated by running `make rust_binding_headers`.\n\n### Build steps\nNow to build the extension, run:\n```sh\nmake\n```\nThe main binaries that will be built are:\n```sh\n./build/release/duckdb\n./build/release/test/unittest\n./build/release/extension/fuzzycomplete/fuzzycomplete.duckdb_extension\n```\n- `duckdb` is the binary for the duckdb shell with the extension code automatically loaded.\n- `unittest` is the test runner of duckdb. Again, the extension is already linked into the binary.\n- `fuzzycomplete.duckdb_extension` is the loadable binary as it would be distributed.\n\n## Running the extension\nTo run the extension code, simply start the shell with `./build/release/duckdb`.\n\nNow we can use the features from the extension directly in DuckDB.\n\n### Installing the deployed binaries\nTo install your extension binaries from S3, you will need to do two things. Firstly, DuckDB should be launched with the\n`allow_unsigned_extensions` option set to true. How to set this will depend on the client you're using. Some examples:\n\nCLI:\n```shell\nduckdb -unsigned\n```\n\nPython:\n```python\ncon = duckdb.connect(':memory:', config={'allow_unsigned_extensions' : 'true'})\n```\n\nNodeJS:\n```js\ndb = new duckdb.Database(':memory:', {\"allow_unsigned_extensions\": \"true\"});\n```\n\nSecondly, you will need to set the repository endpoint in DuckDB to the HTTP url of your bucket + version of the extension\nyou want to install. To do this run the following SQL query in DuckDB:\n```sql\nSET custom_extension_repository='bucket.s3.us-east-1.amazonaws.com/fuzzycomplete/latest';\n```\nNote that the `/latest` path will allow you to install the latest extension version available for your current version of\nDuckDB. To specify a specific version, you can pass the version instead.\n\nAfter running these steps, you can install and load your extension using the regular INSTALL/LOAD commands in DuckDB:\n```sql\nINSTALL fuzzycomplete\nLOAD fuzzycomplete\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frustyconover%2Fduckdb-fuzzycomplete-extension","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frustyconover%2Fduckdb-fuzzycomplete-extension","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frustyconover%2Fduckdb-fuzzycomplete-extension/lists"}