From a87874237b2e05cb95a8d670870166db6a2badb3 Mon Sep 17 00:00:00 2001 From: Calum McGuicken Date: Sun, 9 Jul 2023 15:53:09 +0100 Subject: [PATCH] Added Jaro Winkler for SF --- macros/jaro_winkler.sql | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 macros/jaro_winkler.sql diff --git a/macros/jaro_winkler.sql b/macros/jaro_winkler.sql new file mode 100644 index 0000000..04dc094 --- /dev/null +++ b/macros/jaro_winkler.sql @@ -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 %} \ No newline at end of file