decode udf

This commit is contained in:
drethereum 2023-11-16 09:19:12 -07:00
parent 47f775cd85
commit 6906310939
2 changed files with 25 additions and 0 deletions

View File

@ -157,5 +157,17 @@
HANDLER = 'transform'
sql: |
{{ fsc_utils.create_udf_transform_logs() | indent(4) }}
- name: {{ schema }}.udf_base58
signature:
- [input, STRING]
return_type: TEXT
options: |
LANGUAGE PYTHON
RUNTIME_VERSION = '3.8'
HANDLER = 'base58_decode_handler'
sql: |
{{ fsc_utils.create_udf_base58() | indent(4) }}
{% endmacro %}

View File

@ -177,4 +177,17 @@ def transform(events: dict):
except:
return events
{% endmacro %}
{% macro create_udf_base58() %}
def base58_decode_handler(input):
if input is None:
return None
try:
decoded_bytes = base58.b58decode(input)
return decoded_bytes.decode('utf-8')
except Exception as e:
return str(e)
{% endmacro %}