From a1b89ae0eed3bc76344b8287eeb3f365fc92fdfd Mon Sep 17 00:00:00 2001 From: drethereum <71602799+drethereum@users.noreply.github.com> Date: Tue, 14 Mar 2023 13:55:47 -0600 Subject: [PATCH] add/udf-hex-to-string (#6) * added hex_to_string udf * added udf to name --- macros/streamline/configs.yaml.sql | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/macros/streamline/configs.yaml.sql b/macros/streamline/configs.yaml.sql index dfb8575..59d0949 100644 --- a/macros/streamline/configs.yaml.sql +++ b/macros/streamline/configs.yaml.sql @@ -68,6 +68,20 @@ sql: | {{ python_udf_hex_to_int_with_encoding() | indent(4) }} +- name: utils.udf_hex_to_string + signature: + - [hex, STRING] + return_type: TEXT + options: | + NULL + LANGUAGE SQL + STRICT IMMUTABLE + sql: | + SELECT + LTRIM(regexp_replace( + try_hex_decode_string(hex), + '[\x00-\x1F\x7F-\x9F\xAD]', '', 1)) + {# LIVE SCHEMA #} @@ -105,6 +119,5 @@ secret_name ) - {% endmacro %}