walterddr opened a new issue, #8610:
URL: https://github.com/apache/pinot/issues/8610

   Background
   ===
   Following #8597 to support argument-type-based function lookup, it is 
possible that argument types themselves is not sufficient to determine the 
result type, for example `CAST(intCol AS 'long')` and `CAST(intCol AS 'int')` 
will have the same argument types `int, string` but different return type 
`long` vs. `int`.
   
   
   Proposal
   ===
   Propose to allow annotation of `@ScalarFunction` to annotate classes which 
have various function/method name, signature, class will look like this 
   ```
   @ScalarFunction(name = 'cast')
   public class CastFunction implements FunctionDefinition {
   
     @Override
     public Method getMethod(Collection<DataType> argumentType, 
Collection<Literal> literalArguments) {
       // ... 
     }
   
     // actual function methods:
     public int castToInt(Object o, String literalCastType) { // ... }
     public long castToLong(Object o , String literalCastType) { // ... }
   }
   ```
   Similar architecture is adopted in many sql-like systems to support 
UDF/UDAF/UDTF etc. thus I think the design should be sufficient. 
   
   
   Note
   ====
   * type inference is not discussed in this document
   * whether to use codegen or hand-written method is up for discussion.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to