Help in creating the most simple Athena UDF

0

Hi, could someone please give me an example in using a very simple UDF . From that simple UDF I could make it a more complex one, but I just need a very simple start in returning a substring from a database field. I have 2 problems:

  1. How to define a correct UDF in my query. My query now is:
    USING EXTERNAL FUNCTION test(ID VARCHAR) RETURNS VARCHAR LAMBDA 'test'
    select test(ID) FROM "BibleLinkDynDB"."default"."bible_link_statistics" limit 10;
    ID is the database field.

  2. How to use the input from the UDF in the lambda function. Based on the lambda template my function looks like this:
    index.js
    exports.handler = async (event) => {
    let response = substring(event.arguments,1,10);
    return response;
    };

I know this is not correct. I don't now how to get and process the input string because I think event is an object.

If someone could please give me a hint or a simple example, then this beginner would be very grateful.

kind regards Reyer

Reyer
질문됨 2년 전1842회 조회
2개 답변
0

Have you looked at this workshop lab on using Athena UDF?

It shows you how to deploy an Athena UDF handler with the Serverless Application Repository and then add a function to it.

AWS
전문가
답변함 2년 전
0

Thanks Fabrizio, I will study it.

Reyer
답변함 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠