Class UserDefinedFunctionHandler

  • All Implemented Interfaces:
    com.amazonaws.services.lambda.runtime.RequestStreamHandler
    Direct Known Subclasses:
    AthenaUDFHandler, ExampleUserDefinedFuncHandler

    public abstract class UserDefinedFunctionHandler
    extends Object
    implements com.amazonaws.services.lambda.runtime.RequestStreamHandler
    Athena UDF users are expected to extend this class to create UDFs.
    • Constructor Detail

      • UserDefinedFunctionHandler

        public UserDefinedFunctionHandler​(String sourceType)
    • Method Detail

      • handleRequest

        public final void handleRequest​(InputStream inputStream,
                                        OutputStream outputStream,
                                        com.amazonaws.services.lambda.runtime.Context context)
        Specified by:
        handleRequest in interface com.amazonaws.services.lambda.runtime.RequestStreamHandler
      • processRows

        protected Block processRows​(BlockAllocator allocator,
                                    Method udfMethod,
                                    Block inputRecords,
                                    org.apache.arrow.vector.types.pojo.Schema outputSchema)
                             throws Exception
        Processes a group by rows. This method takes in a block of data (containing multiple rows), process them and returns multiple rows of the output column in a block.

        UDF methods are invoked row-by-row in a for loop. Arrow values are converted to Java Objects and then passed into the UDF java method. This is not very efficient because we might potentially be doing a lot of data copying. Advanced users could choose to override this method and directly deal with Arrow data to achieve better performance.

        Parameters:
        allocator - arrow memory allocator
        udfMethod - the extracted java method matching the User-Defined-Function defined in Athena.
        inputRecords - input data in Arrow format
        outputSchema - output data schema in Arrow format
        Returns:
        output data in Arrow format
        Throws:
        Exception
      • onPing

        protected void onPing​(PingRequest request)