[ 
https://issues.apache.org/jira/browse/OPTIQ-314?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14048005#comment-14048005
 ] 

Julian Hyde commented on OPTIQ-314:
-----------------------------------

I was thinking of automatic overloads. For example, if they specify 

{code:javascript}
functions: [ {
  name: "MY_ABS",
  className: "java.lang.Math",
  methodName: "abs"
}]
{code}

they will get SQL UDFs {{MY_ABS(INT)}}, {{MY_ABS(LONG)}}, {{MY_ABS(REAL)}}, 
{{MY_ABS(DOUBLE)}} because java.lang.Math has overloaded functions 
{{abs(int)}}, {{abs(long)}}, {{abs(float)}}, {{abs(double)}}.

if you hoped that the {{public String replace(String, String)}} of 
{{java.lang.String}} could be used to implement {{REPLACE(VARCHAR, VARCHAR, 
VARCHAR) RETURNS VARCHAR}}, you are out of luck; it actually becomes 
{{REPLACE(VARCHAR, VARCHAR) RETURNS VARCHAR)}}. Optiq does not use the "this" 
as an extra parameter. Optiq will instantiate the class before the first row 
(the class must have a public default constructor), then uses the same instance 
(in this case, the String object) for each call. The instance can be used to 
hold state variables. (Not much use in this case, because String has no mutable 
fields.)

> Allow simple UDFs based on methods
> ----------------------------------
>
>                 Key: OPTIQ-314
>                 URL: https://issues.apache.org/jira/browse/OPTIQ-314
>             Project: optiq
>          Issue Type: New Feature
>            Reporter: Julian Hyde
>            Assignee: Julian Hyde
>
> We already allow UDFs based on classes, provided that that classes have just 
> one method. This change would allow UDFs based on classes with several 
> methods.
> E.g. should be able to use 'String String.replace(String s, String s2)' as a 
> SQL UDF 'REPLACE(String, String, String) RETURNS String'.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to