How to register a UDF in AWS Athena?

27 views Asked by At

I have created a UDF using AWS Lambda and I can run query using below syntax:

USING EXTERNAL FUNCTION ai_func(review VARCHAR) RETURNS VARCHAR LAMBDA 'xxx-ai-xxx-genai-udf'
SELECT review, ai_func(review) as ai_review from gen_ai.xxxxxxx_table;

But, is there a way to register the function like this?

CREATE OR REPLACE FUNCTION ai_func(review varchar) RETURNS VARCHAR 
LAMBDA 'arn:aws:lambda:us-east-1:XXXXXXXXXX:function:xxx-ai-xxx-genai-udf';

This errors out:

line 1:19: mismatched input 'FUNCTION'. Expecting: 'MATERIALIZED', 'MULTI', 'PROTECTED', 'VIEW'

I want to register it so that multiple users can use it and users don't like to use USING EXTERNAL FUNCTION syntax. CREATE FUNCTION is supported by Redshift, Hive and few other databases.

0

There are 0 answers