From 2dc85270018b97d96b4c56ebddd00f38fe3936c1 Mon Sep 17 00:00:00 2001 From: drethereum Date: Mon, 22 May 2023 15:38:21 -0600 Subject: [PATCH] macro test --- macros/hex_to_string_udf.sql | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 macros/hex_to_string_udf.sql diff --git a/macros/hex_to_string_udf.sql b/macros/hex_to_string_udf.sql new file mode 100644 index 0000000..b25bfd3 --- /dev/null +++ b/macros/hex_to_string_udf.sql @@ -0,0 +1,12 @@ +{% macro create_udf_hex_to_string(schema) %} +CREATE OR REPLACE FUNCTION {{ schema }}.udf_hex_to_string(hex STRING) + RETURNS TEXT + LANGUAGE SQL + STRICT IMMUTABLE AS +$$ + SELECT + LTRIM(regexp_replace( + try_hex_decode_string(hex), + '[\x00-\x1F\x7F-\x9F\xAD]', '', 1)) +$$; +{% endmacro %} \ No newline at end of file