Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejava
@PublicEvolving

@Retention(RetentionPolicy.RUNTIME)

@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER})

public @interface DataTypeHint {   // UDF Development

public static class NamedArgumentsTableFunction extends TableFunction<Object> {




   // Method overloads with different parameter sets

   // Example usage: SELECT * FROM TABLE(my_table_function(in1 => 'value1', in2 => 'value2'))

   @FunctionHint(

           input = {@DataTypeHint("STRING"), @DataTypeHint("STRING")},

           output = @DataTypeHint("STRING"),

           argumentNames = {"in1", "in2"})

   public void eval(String arg1, String arg2) {

       collect(arg1 + ", " + arg2);

   }




   // Example usage: SELECT * FROM TABLE(my_table_function(in1 => 'value1', in2 => 'value2', in3 => 'value3'))

   @FunctionHint(

           input = {@DataTypeHint("STRING"), @DataTypeHint("STRING"), @DataTypeHint("STRING")},

           output 

     output = @DataTypeHint("STRING"),

           argumentNames = {"in1", "in2", "in3"})

   public void eval(String arg1, String arg2, String arg3) {

       collect(arg1 + ", " + arg2);

   }

}







// Call Procedure Development

public static class NamedArgumentsProcedure implements Procedure {




   // Method overloads with different parameter sets

   // Example usage: CALL myNamedProcedure(in1 => 'value1', d => 100)

   @ProcedureHint(

           input = {@DataTypeHint("STRING"), @DataTypeHint("INT")},

           output = @DataTypeHint("STRING"),

           argumentNames = {"in1", "in2"})

   public String[] call(ProcedureContext procedureContext, String arg1, Integer arg2) {

       return new String[]{arg1 + ", " + arg2};

   }




   // Example usage: CALL myNamedProcedure(in1 => 100, in2 => 200)

   @ProcedureHint(

           input = {@DataTypeHint("INT"), @DataTypeHint("INT")},

           output = @DataTypeHint("STRING"),

           argumentNames = {"in1", "in2"})

   public String[] call(ProcedureContext procedureContext, Integer arg1, Integer arg2) {

       return new String[]{arg1 + ", " + arg2};

   }

}
     /**

     *   Used to indicate whether the parameter is optional or not.

     */


   boolean   
    boolean isOptional() default true;




}




For function developer and call procedure developer 

...