Skip to content

DuckDB Extension

RapidFuzz

Compare strings and rank candidate matches in DuckDB SQL using RapidFuzz. Find similar names, match reordered words, or calculate edit distances.

1,905,713
extension loads Β· last 90 days
On this page

Find candidate matches when text differs

Exact equality misses names with typing errors, changed word order, or small spelling differences. RapidFuzz adds similarity scores and edit distances to DuckDB so you can compare values and rank possible matches in SQL.

Use it for record linkage, reviewing possible duplicates, or matching input against a known list. A high score is evidence for a candidate, not proof of identity. For large tables, narrow the candidate pairs with a rule such as a shared postcode before scoring them.

Example

Find the closest name for each record

Compare two input names with three candidates. Keep the highest-scoring candidate with a score of at least 80 for each input, using the candidate id to break ties.

Tested with DuckDB 1.5.6. Browser examples use Haybarn-Wasm 1.5.6.

INSTALL rapidfuzz FROM community;
LOAD rapidfuzz;

WITH names(id, name) AS (
  VALUES (1, 'Jon Smith'), (2, 'Jane Doe')
), candidates(id, name) AS (
  VALUES (10, 'John Smith'), (11, 'Jane Doe'), (12, 'Jon Smyth')
)
SELECT a.name AS input_name, b.name AS matched_name,
  round(rapidfuzz_ratio(a.name, b.name), 1) AS score
FROM names a CROSS JOIN candidates b
WHERE rapidfuzz_ratio(a.name, b.name) >= 80
QUALIFY row_number() OVER (
  PARTITION BY a.id
  ORDER BY rapidfuzz_ratio(a.name, b.name) DESC, b.id
) = 1
ORDER BY a.id;

Expected result

input_name matched_name score
Jon Smith John Smith 94.7
Jane Doe Jane Doe 100

A similarity score identifies a candidate, not a confirmed duplicate. This tiny example compares every pair. For larger tables, reduce the candidate pairs before scoring. Inputs with no score of at least 80 are omitted.

Common tasks

Deep Dive

Technical Details

Reference

Extension Contents

Quick reference to all available functions and settings organized by category.

Hamming
rapidfuzz_hamming_distance() Object type: Scalar function Number of differing positions between two equal-length strings.
rapidfuzz_hamming_normalized_distance() Object type: Scalar function Number of differing positions between two equal-length strings.
rapidfuzz_hamming_normalized_similarity() Object type: Scalar function Number of differing positions between two equal-length strings.
rapidfuzz_hamming_similarity() Object type: Scalar function Number of matching positions between two strings of equal length.
Indel
rapidfuzz_indel_distance() Object type: Scalar function Insertions+deletions to transform one string into another (no substitutions).
rapidfuzz_indel_normalized_distance() Object type: Scalar function Insertions+deletions to transform one string into another (no substitutions).
rapidfuzz_indel_normalized_similarity() Object type: Scalar function Insertions+deletions to transform one string into another (no substitutions).
rapidfuzz_indel_similarity() Object type: Scalar function Insertions+deletions to transform one string into another (no substitutions).
Jaro
rapidfuzz_jaro_distance() Object type: Scalar function Jaro similarity β€” character matches and transpositions.
rapidfuzz_jaro_normalized_distance() Object type: Scalar function Jaro similarity β€” character matches and transpositions.
rapidfuzz_jaro_normalized_similarity() Object type: Scalar function Jaro similarity β€” character matches and transpositions.
rapidfuzz_jaro_similarity() Object type: Scalar function Jaro similarity β€” character matches and transpositions.
Jaro Winkler
rapidfuzz_jaro_winkler_distance() Object type: Scalar function Jaro-Winkler β€” Jaro with extra weight on common prefixes.
rapidfuzz_jaro_winkler_normalized_distance() Object type: Scalar function Jaro-Winkler β€” Jaro with extra weight on common prefixes.
rapidfuzz_jaro_winkler_normalized_similarity() Object type: Scalar function Jaro-Winkler β€” Jaro with extra weight on common prefixes.
rapidfuzz_jaro_winkler_similarity() Object type: Scalar function Jaro-Winkler β€” Jaro with extra weight on common prefixes.
Lcs Seq
rapidfuzz_lcs_seq_distance() Object type: Scalar function Longest common subsequence β€” preserves character order but not adjacency.
rapidfuzz_lcs_seq_normalized_distance() Object type: Scalar function Longest common subsequence β€” preserves character order but not adjacency.
rapidfuzz_lcs_seq_normalized_similarity() Object type: Scalar function Longest common subsequence β€” preserves character order but not adjacency.
rapidfuzz_lcs_seq_similarity() Object type: Scalar function Longest common subsequence β€” preserves character order but not adjacency.
Osa
rapidfuzz_osa_distance() Object type: Scalar function Optimal string alignment β€” Levenshtein with adjacent transpositions counted as one edit.
rapidfuzz_osa_normalized_distance() Object type: Scalar function Optimal string alignment β€” Levenshtein with adjacent transpositions counted as one edit.
rapidfuzz_osa_normalized_similarity() Object type: Scalar function Optimal string alignment β€” Levenshtein with adjacent transpositions counted as one edit.
rapidfuzz_osa_similarity() Object type: Scalar function Optimal string alignment β€” Levenshtein with adjacent transpositions counted as one edit.
Postfix
rapidfuzz_postfix_distance() Object type: Scalar function Edit distance considering only matching suffixes.
rapidfuzz_postfix_normalized_distance() Object type: Scalar function Edit distance considering only matching suffixes.
rapidfuzz_postfix_normalized_similarity() Object type: Scalar function Edit distance considering only matching suffixes.
rapidfuzz_postfix_similarity() Object type: Scalar function Edit distance considering only matching suffixes.
Prefix
rapidfuzz_prefix_distance() Object type: Scalar function Edit distance considering only matching prefixes.
rapidfuzz_prefix_normalized_distance() Object type: Scalar function Edit distance considering only matching prefixes.
rapidfuzz_prefix_normalized_similarity() Object type: Scalar function Edit distance considering only matching prefixes.
rapidfuzz_prefix_similarity() Object type: Scalar function Edit distance considering only matching prefixes.
Ratio Scores
rapidfuzz_partial_ratio() Object type: Scalar function Best similarity score for any substring of the longer input against the shorter β€” useful when one string is a fragment of the other.
rapidfuzz_partial_token_set_ratio() Object type: Scalar function Token-set comparison with a partial-ratio fallback β€” best when one string is a subset/partial match of the other.
rapidfuzz_ratio() Object type: Scalar function Levenshtein-based similarity (0–100).
rapidfuzz_token_set_ratio() Object type: Scalar function Compare token sets (deduped, unordered).
rapidfuzz_token_sort_ratio() Object type: Scalar function Compare after sorting tokens (words).

API Reference

Function Reference

Practical Examples

Cookbook

Real-world recipes and patterns for common use cases.

Platform Support

Compatibility

Extension availability may vary by platform and DuckDB version. Check below to ensure this extension supports your environment before installation.

Quick Facts

Release status Stable
Software License MIT
Pricing Free
Written In C++
Source Available Yes
View on GitHub
Usage
1,905,713
loads Β· last 90 days

Platforms

DuckDB 2.0.0

  • Linux x86_64 aarch64
  • Linux (musl) Not available
  • macOS Apple Silicon
  • Windows x86_64 x86_64 (MinGW)
  • WASM Not available
Compiled binary sizes
Platform Architecture Size
Linux x86_64 4.05 MB
Linux aarch64 3.39 MB
macOS Apple Silicon 2.86 MB
Windows x86_64 10.25 MB
Windows x86_64 (MinGW) 17.89 MB

Compressed download sizes for the release shown above.

DuckDB & Haybarn

Release calendar
  • DuckDB v2.0.0 Query.Farm repository Supported
  • Haybarn v1.5.6 Built-in community repository Supported

Browser examples use Haybarn-Wasm 1.5.6.

Checked .