Skip to content

Commit

Permalink
Added Jaro Winkler for SF
Browse files Browse the repository at this point in the history
  • Loading branch information
calum-mcg committed Jul 9, 2023
1 parent c055c85 commit a878742
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions macros/jaro_winkler.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{% macro jaro_winkler(str1, str2) %}
-- Check inputs are not None or empty
-- Max can be empty
{% if str1 is none or str2 is none or str1 == "" or str2 == ""%}
{{ exceptions.raise_compiler_error("Both input strings must contain text.") }}
{% endif %}
-- Use Dispatch to handle nuances in syntax across DWs
{{ return(adapter.dispatch('jaro_winkler', 'fuzzy_text')(str1, str2)) }}
{% endmacro %}

-- For non-supported adapters
{% macro default__jaro_winkler() %}
{{ exceptions.raise_compiler_error("Jaccard index is not yet implemented for this adapter. Currently it is only available for Snowflake and BigQuery. Please raise an issue on the Github repo to request expanding coverage.") }}
{% endmacro %}

{% macro snowflake__jaro_winkler(str1, str2) %}
-- Built-in support for Snowflake
JAROWINKLER_SIMILARITY({{str1}}, {{str2}})
{% endmacro %}

-- {% macro bigquery__jaro_winkler(str1, str2) %}
-- -- TODO
-- {% endmacro %}

0 comments on commit a878742

Please sign in to comment.