Class UserDefinedFunction


  • public class UserDefinedFunction
    extends Object
    Encapsulates a user defined lambda or function that is returned by UDFRegistration.registerTemporary, UDFRegistration.registerPermanent, or Functions.udf.

    Use UserDefinedFunction.apply to generate Column expressions from an instance.

    
     import com.snowflake.snowpark_java.functions;
     import com.snowflake.snowpark_java.types.DataTypes;
    
     UserDefinedFunction myUdf = Functions.udf(
       (Integer x, Integer y) -> x + y,
       new DataType[]{DataTypes.IntegerType, DataTypes.IntegerType},
       DataTypes.IntegerType
     );
     df.select(myUdf.apply(df.col("col2"), df.col("col2")));
     
    Since:
    0.12.0
    • Method Detail

      • apply

        public Column apply​(Column... exprs)
        Apply the UDF to one or more columns to generate a Column expression.
        Parameters:
        exprs - The list of expression.
        Returns:
        The result column
        Since:
        0.12.0